Debian Codegraph @

.github/workflows/go.yml

raw
1 ---
2 name: Go
3 on:
4 pull_request:
5 push:
6 branches:
7 - main
8 - "release-*"
9
10 # Modified to avoid canceling all matrix jobs when one fails
11 # Each job type will have its own concurrency group
12 concurrency:
13 group: ${{ github.workflow }}-${{ github.job }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }}
14 cancel-in-progress: true
15
16 # Minimal permissions to be inherited by any job that don't declare it's own permissions
17 permissions:
18 contents: read
19
20 jobs:
21 supportedVersions:
22 name: Fetch supported Go versions
23 runs-on: ubuntu-latest
24 outputs:
25 supported_versions: ${{ steps.matrix.outputs.supported_versions }}
26 steps:
27 - name: Checkout code
28 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
29 - name: Read supported_go_versions.txt
30 id: matrix
31 run: |
32 versions=$(cat supported_go_versions.txt)
33 matrix="[$(echo "$versions" | sed 's/\(.*\)/"\1"/' | paste -s -d,)]"
34 echo "supported_versions=$matrix" >> $GITHUB_OUTPUT
35
36 test:
37 name: Tests (${{ matrix.go_version }})
38 runs-on: ubuntu-latest
39 needs: supportedVersions
40 # Set fail-fast to false to ensure all Go versions are tested regardless of failures
41 strategy:
42 fail-fast: false
43 matrix:
44 go_version: ${{ fromJSON(needs.supportedVersions.outputs.supported_versions) }}
45 # Define concurrency at the job level for matrix jobs
46 concurrency:
47 group: ${{ github.workflow }}-test-${{ matrix.go_version }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }}
48 cancel-in-progress: true
49
50 steps:
51 - name: Checkout code
52 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
53
54 - name: Set up Go ${{ matrix.go_version }}
55 uses: actions/[email protected]
56 with:
57 go-version: ${{ matrix.go_version }}
58 check-latest: true
59 cache-dependency-path: go.sum
60
61 - name: Run tests and check license
62 run: make check_license test
63 env:
64 CI: true
65
66 - name: Run style and unused
67 if: ${{ matrix.go_version == '1.22' }}
68 run: make style unused