[release-v0.44.x] CI: Use goinstall mode for golangci-lint action #736
Workflow file for this run
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: [pull_request] # yamllint disable-line rule:truthy | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull-request.number || github.ref }} | |
| cancel-in-progress: true | |
| defaults: | |
| run: | |
| shell: bash | |
| permissions: | |
| contents: read | |
| checks: write # Used to annotate code in the PR | |
| jobs: | |
| build: | |
| name: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 | |
| with: | |
| go-version-file: "go.mod" | |
| - name: build | |
| run: | | |
| go build -v ./... | |
| linting: | |
| needs: [build] | |
| name: lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 | |
| with: | |
| go-version-file: "go.mod" | |
| - name: gofmt | |
| run: | | |
| gofmt_out=$(gofmt -d $(find * -name '*.go' ! -path 'vendor/*' ! -path 'third_party/*')) | |
| if [[ -n "$gofmt_out" ]]; then | |
| failed=1 | |
| fi | |
| echo "$gofmt_out" | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@82606bf257cbaff209d206a39f5134f0cfbfd2ee # v9.2.1 | |
| with: | |
| version: v2.12.2 | |
| install-mode: goinstall | |
| args: --new-from-merge-base=origin/${{ github.base_ref }} --timeout=10m | |
| - name: yamllint | |
| run: | | |
| apt update && apt install -y yamllint | |
| yamllint -c .yamllint $(find . -path ./vendor -prune -o -type f -regex ".*y[a]ml" -print | tr '\n' ' ') | |
| - name: check-license | |
| run: | | |
| go install github.com/google/go-licenses@v1.0.0 | |
| go-licenses check ./... | |
| tests: | |
| needs: [build] | |
| name: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 | |
| with: | |
| go-version-file: "go.mod" | |
| - name: build | |
| run: | | |
| make test-unit-verbose-and-race | |
| generated: | |
| needs: [build] | |
| name: Check generated code | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 | |
| with: | |
| go-version-file: "go.mod" | |
| - name: generated | |
| run: | | |
| go install github.com/google/go-licenses@v1.0.0 # Not sure why it is needed here | |
| ./hack/verify-codegen.sh | |
| multi-arch-build: | |
| needs: [build] | |
| name: Multi-arch build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 | |
| with: | |
| go-version-file: "go.mod" | |
| - name: Free disk space | |
| run: | | |
| echo "--- Disk space before cleanup ---" | |
| df -h | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /usr/local/lib/android | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /opt/hostedtoolcache/CodeQL | |
| sudo docker image prune -a -f | |
| echo "--- Disk space after cleanup ---" | |
| df -h | |
| - name: make cross | |
| run: | | |
| make cross | |
| e2e-tests: | |
| needs: [build] | |
| uses: ./.github/workflows/e2e-matrix.yml | |
| ci-summary: | |
| name: CI summary | |
| needs: [build, linting, tests, generated, multi-arch-build, e2e-tests] | |
| runs-on: ubuntu-latest | |
| if: always() | |
| steps: | |
| - name: Block merge for draft PRs | |
| if: ${{ github.event.pull_request.draft == true }} | |
| run: | | |
| echo "::warning::Draft PR — only minimal e2e tests were run" | |
| echo "Mark as 'Ready for Review' to run the full CI matrix." | |
| exit 1 | |
| env: | |
| IS_DRAFT: ${{ github.event.pull_request.draft }} | |
| - name: Check CI results | |
| if: ${{ github.event.pull_request.draft == false }} | |
| run: | | |
| results=( | |
| "build=${NEEDS_BUILD_RESULT}" | |
| "linting=${NEEDS_LINTING_RESULT}" | |
| "tests=${NEEDS_TESTS_RESULT}" | |
| "generated=${NEEDS_GENERATED_RESULT}" | |
| "multi-arch-build=${NEEDS_MULTI_ARCH_BUILD_RESULT}" | |
| "e2e-tests=${NEEDS_E2E_TESTS_RESULT}" | |
| ) | |
| failed=0 | |
| for r in "${results[@]}"; do | |
| name="${r%%=*}" | |
| result="${r#*=}" | |
| echo "${name}: ${result}" | |
| if [ "$result" != "success" ] && [ "$result" != "skipped" ]; then | |
| failed=1 | |
| fi | |
| done | |
| if [ "$failed" -eq 1 ]; then | |
| echo "" | |
| echo "Some CI jobs failed or were cancelled" | |
| exit 1 | |
| fi | |
| echo "" | |
| echo "All CI checks passed" | |
| env: | |
| NEEDS_BUILD_RESULT: ${{ needs.build.result }} | |
| NEEDS_LINTING_RESULT: ${{ needs.linting.result }} | |
| NEEDS_TESTS_RESULT: ${{ needs.tests.result }} | |
| NEEDS_GENERATED_RESULT: ${{ needs.generated.result }} | |
| NEEDS_MULTI_ARCH_BUILD_RESULT: ${{ needs.multi-arch-build.result }} | |
| NEEDS_E2E_TESTS_RESULT: ${{ needs.e2e-tests.result }} |