feat(ci): add lint, tidy, and formatting CI jobs #338
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| types: | |
| - opened | |
| - reopened | |
| - synchronize | |
| - labeled | |
| - unlabeled | |
| merge_group: | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| # --------------------------------------------------------------------------- | |
| # LINT (all tools from Bazel — gofmt via Go SDK, yamllint via Go binary) | |
| # --------------------------------------------------------------------------- | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/setup | |
| - name: Run linters | |
| run: make lint | |
| # --------------------------------------------------------------------------- | |
| # TIDY (module files + BUILD files in sync) | |
| # --------------------------------------------------------------------------- | |
| tidy: | |
| name: Tidy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/setup | |
| - name: Check module files are tidy | |
| run: make check-tidy | |
| - name: Check BUILD files are up to date | |
| run: make check-gazelle | |
| # --------------------------------------------------------------------------- | |
| # BUILD AND UNIT TESTS | |
| # --------------------------------------------------------------------------- | |
| build-and-unit-test: | |
| name: Build and Unit Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| # Full history needed for diff coverage (git merge-base origin/main HEAD). | |
| fetch-depth: 0 | |
| - uses: ./.github/actions/setup | |
| - name: Build project | |
| run: make build | |
| - name: Run unit tests with coverage | |
| if: "!contains(github.event.pull_request.labels.*.name, 'COVERAGE_EXEMPTION')" | |
| run: make check-coverage | |
| - name: Run unit tests (coverage exempted) | |
| if: contains(github.event.pull_request.labels.*.name, 'COVERAGE_EXEMPTION') | |
| run: make coverage | |
| - name: Coverage summary | |
| if: always() | |
| run: | | |
| if [ -f .coverage-html/summary.txt ]; then | |
| echo "### Coverage Report" >> "$GITHUB_STEP_SUMMARY" | |
| echo "" >> "$GITHUB_STEP_SUMMARY" | |
| cat .coverage-html/summary.txt >> "$GITHUB_STEP_SUMMARY" | |
| fi | |
| - name: Notify coverage exemption | |
| if: >- | |
| github.event_name == 'pull_request' && | |
| contains(github.event.pull_request.labels.*.name, 'COVERAGE_EXEMPTION') | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| SUMMARY="" | |
| if [ -f .coverage-html/summary.txt ]; then | |
| SUMMARY=$(cat .coverage-html/summary.txt) | |
| fi | |
| ARTIFACT_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#artifacts" | |
| BODY=$(cat <<EOF | |
| > [!CAUTION] | |
| > **Coverage enforcement has been exempted** for this PR via the \`COVERAGE_EXEMPTION\` label. | |
| > Reviewers: please verify this exemption is justified before approving. | |
| ${SUMMARY} | |
| [View full coverage report](${ARTIFACT_URL}) | |
| EOF | |
| ) | |
| gh pr comment ${{ github.event.pull_request.number }} --body "$BODY" | |
| - name: Upload coverage report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: .coverage-html/ | |
| if-no-files-found: ignore | |
| retention-days: 14 | |
| # --------------------------------------------------------------------------- | |
| # INTEGRATION TESTS (e2e, gateway, orchestrator) | |
| # --------------------------------------------------------------------------- | |
| e2e: | |
| name: E2E Integration Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/setup | |
| - name: Run E2E tests | |
| run: make e2e-test | |
| gateway-integration-test: | |
| name: Gateway Integration Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/setup | |
| - name: Run Gateway integration tests | |
| run: make integration-test-gateway | |
| orchestrator-integration-test: | |
| name: Orchestrator Integration Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/setup | |
| - name: Run Orchestrator integration tests | |
| run: make integration-test-orchestrator | |
| # --------------------------------------------------------------------------- | |
| # EXTENSION TESTS | |
| # --------------------------------------------------------------------------- | |
| counter-integration-test: | |
| name: Counter Extension Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/setup | |
| - uses: ./.github/actions/run-bazel-test | |
| with: | |
| target: //test/integration/extension/counter/... | |
| queue-integration-test: | |
| name: Queue Extension Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/setup | |
| - uses: ./.github/actions/run-bazel-test | |
| with: | |
| target: //test/integration/extension/queue/... | |
| storage-integration-test: | |
| name: Storage Extension Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/setup | |
| - uses: ./.github/actions/run-bazel-test | |
| with: | |
| target: //test/integration/extension/storage/... | |
| # --------------------------------------------------------------------------- | |
| # REQUIRED CHECKS GATE | |
| # --------------------------------------------------------------------------- | |
| required-checks: | |
| name: Required Checks | |
| runs-on: ubuntu-latest | |
| needs: | |
| - lint | |
| - tidy | |
| - build-and-unit-test | |
| - e2e | |
| - gateway-integration-test | |
| - orchestrator-integration-test | |
| - counter-integration-test | |
| - queue-integration-test | |
| - storage-integration-test | |
| steps: | |
| - name: All required checks passed | |
| run: | | |
| echo "All required checks passed!" >&2 |