Skip to content

Use pre-built container image from ghcr.io #731

Use pre-built container image from ghcr.io

Use pre-built container image from ghcr.io #731

Workflow file for this run

# Run test file with command:
# act pull_request -e testdata/act/pull-request.json
name: Test and Generate Docs
on: pull_request
jobs:
go-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '18.x'
- name: Install datadog-ci
run: |
ddci_release="_$(uname -s | tr A-Z a-z)-$(uname -m | sed -e 's/^x86_64$/x64/' -e 's/^aarch64$/arm64/')"
gh release download --repo datadog/datadog-ci --pattern "*$ddci_release*" --clobber -O /usr/local/bin/datadog-ci
chmod +x /usr/local/bin/datadog-ci
env:
GH_TOKEN: ${{ github.token }}
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.x'
- name: Set up Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: go.mod
- name: Install pre-commit
run: |
python -m pip install --upgrade pip
pip install pre-commit
- name: Run pre-commit hooks
run: pre-commit run --all-files
- name: Install dependencies
run: go mod tidy
- name: Install gotestsum
run: |
gotestsum_release="_$(uname -s | tr A-Z a-z)_$(uname -m | sed -e 's/^x86_64$/amd64/' -e 's/^aarch64$/arm64/')"
gh release download --repo gotestyourself/gotestsum --pattern "*$gotestsum_release*" --clobber -O /tmp/gotestsum.tar.gz
gh release download --repo gotestyourself/gotestsum --pattern "*-checksums.txt*" --clobber -O /tmp/gotestsum_checksums.txt
if [[ "$(sha256sum /tmp/gotestsum.tar.gz | cut -d ' ' -f 1)" != "$(grep -F "$gotestsum_release" /tmp/gotestsum_checksums.txt | cut -d ' ' -f 1)" ]]; then
echo "Checksum mismatch for gotestsum"
exit 1
fi
tar -xzf /tmp/gotestsum.tar.gz -C /usr/local/bin gotestsum
chmod +x /usr/local/bin/gotestsum
env:
GH_TOKEN: ${{ github.token }}
- name: Run tests with gotestsum
run: |
mkdir -p ${{ github.workspace }}/artifacts
mkdir -p ${{ github.workspace }}/reports
GONFALON_MODE=test \
gotestsum --packages="./..." \
--junitfile ${{ github.workspace }}/reports/go-test_go_tests.xml \
--jsonfile ${{ github.workspace }}/artifacts/go-test_go_tests.json \
--rerun-fails=2 \
--rerun-fails-max-failures=10 \
--rerun-fails-report ${{ github.workspace }}/artifacts/rerun_tests_go_tests.txt \
-- -tags=launchdarkly_easyjson -p=1
- name: Publish JUnit Tests
uses: ./.github/actions/publish-junit
env:
DD_API_KEY: ${{ secrets.DATADOG_API_KEY }}
with:
files: ${{ github.workspace }}/reports/go-test_go_tests.xml
name: find-code-references-in-pull-request
datadog: 'true'
github: 'true'
e2e-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Find LaunchDarkly feature flags in diff
uses: ./ # Uses an action in the root directory
id: find-flags
with:
project-key: demo-dan-042021-2
environment-key: development
access-token: ${{ secrets.LD_ACCESS_TOKEN_WRITER }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
base-uri: https://app.launchdarkly.com
max-flags: 200
create-flag-links: true
- name: Find flags summary
run: |
echo "flags addded or modified ${{ steps.find-flags.outputs.modified-flags-count }}"
echo "flags removed ${{ steps.find-flags.outputs.removed-flags-count }}"
- name: Added or modified flags
if: steps.find-flags.outputs.any-modified == 'true'
run: |
for flag in ${{ steps.find-flags.outputs.modified-flags }}; do
echo "$flag was added or modified"
done
- name: Removed flags
if: steps.find-flags.outputs.any-removed == 'true'
run: |
for flag in ${{ steps.find-flags.outputs.removed-flags }}; do
echo "$flag was removed"
done
- name: Add label
if: ${{ steps.find-flags.outputs.any-changed == 'true' && github.actor != 'dependabot[bot]' }}
run: gh pr edit $PR_NUMBER --add-label ld-flags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
- name: Remove label
if: ${{ steps.find-flags.outputs.any-changed == 'false' && github.actor != 'dependabot[bot]' }}
run: gh pr edit $PR_NUMBER --remove-label ld-flags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
generate-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.x'
- name: Install pre-commit
run: |
python -m pip install --upgrade pip
pip install pre-commit
- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '18.8.0'
- name: Install action-docs
run: npm install action-docs
- name: Run pre-commit for GitHub Actions Docs
run: pre-commit run -a github-action-docs
build-image:
needs: [go-test, e2e-tests, generate-docs]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
- name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
- name: Docker Bake Action
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
file: ./Dockerfile
tags: |
ghcr.io/launchdarkly/find-code-references-in-pull-request:latest
ghcr.io/launchdarkly/find-code-references-in-pull-request:${{ github.sha }}
push: ${{ github.ref == 'refs/heads/main' }}