|
1 | | ---- |
2 | | -name: Go |
3 | | -on: |
4 | | - pull_request: |
5 | | - push: |
6 | | - branches: |
7 | | - - main |
8 | | - - "release-*" |
9 | | - |
10 | | -concurrency: |
11 | | - group: ${{ github.workflow }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }} |
12 | | - cancel-in-progress: true |
13 | | - |
14 | | -# Minimal permissions to be inherited by any job that don't declare it's own permissions |
15 | | -permissions: |
16 | | - contents: read |
17 | | - |
18 | | -jobs: |
19 | | - |
20 | | - supportedVersions: |
21 | | - name: Fetch supported Go versions |
22 | | - runs-on: ubuntu-latest |
23 | | - outputs: |
24 | | - supported_versions: ${{ steps.matrix.outputs.supported_versions }} |
25 | | - steps: |
26 | | - - name: Checkout code |
27 | | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
28 | | - - name: Read supported_go_versions.txt |
29 | | - id: matrix |
30 | | - run: | |
31 | | - versions=$(cat supported_go_versions.txt) |
32 | | - matrix="[$(echo "$versions" | sed 's/\(.*\)/"\1"/' | paste -s -d,)]" |
33 | | - echo "supported_versions=$matrix" >> $GITHUB_OUTPUT |
34 | | -
|
35 | | - test: |
36 | | - name: Tests |
37 | | - runs-on: ubuntu-latest |
38 | | - needs: supportedVersions |
39 | | - |
40 | | - strategy: |
41 | | - matrix: |
42 | | - go_version: ${{ fromJSON(needs.supportedVersions.outputs.supported_versions) }} |
43 | | - |
44 | | - steps: |
45 | | - - name: Checkout code |
46 | | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
47 | | - |
48 | | - - name: Run tests and check license |
49 | | - uses: dagger/dagger-for-github@847ae4458ef34fe9b5f566655957bde6d4891112 # v7.0.3 |
50 | | - with: |
51 | | - version: "latest" |
52 | | - verb: call |
53 | | - args: -vvv --src . make --go-version ${{matrix.go_version}} --args 'check_license test' |
54 | | - |
55 | | - - name: Run style and unused |
56 | | - uses: dagger/dagger-for-github@847ae4458ef34fe9b5f566655957bde6d4891112 # v7.0.3 |
57 | | - if: ${{ matrix.go_version == '1.21' }} |
58 | | - with: |
59 | | - version: "latest" |
60 | | - verb: call |
61 | | - args: -vvv --src . make --args 'check_license test' |
| 1 | +--- |
| 2 | +name: Go |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + - "release-*" |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +# Minimal permissions to be inherited by any job that don't declare it's own permissions |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + |
| 18 | +jobs: |
| 19 | + supportedVersions: |
| 20 | + name: Fetch supported Go versions |
| 21 | + runs-on: ubuntu-latest |
| 22 | + outputs: |
| 23 | + supported_versions: ${{ steps.matrix.outputs.supported_versions }} |
| 24 | + steps: |
| 25 | + - name: Checkout code |
| 26 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 27 | + - name: Read supported_go_versions.txt |
| 28 | + id: matrix |
| 29 | + run: | |
| 30 | + versions=$(cat supported_go_versions.txt) |
| 31 | + matrix="[$(echo "$versions" | sed 's/\(.*\)/"\1"/' | paste -s -d,)]" |
| 32 | + echo "supported_versions=$matrix" >> $GITHUB_OUTPUT |
| 33 | +
|
| 34 | + test: |
| 35 | + name: Tests |
| 36 | + runs-on: ubuntu-latest |
| 37 | + needs: supportedVersions |
| 38 | + |
| 39 | + strategy: |
| 40 | + matrix: |
| 41 | + go_version: ${{ fromJSON(needs.supportedVersions.outputs.supported_versions) }} |
| 42 | + |
| 43 | + steps: |
| 44 | + - name: Checkout code |
| 45 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 46 | + |
| 47 | + - name: Set up Go ${{ matrix.go_version }} |
| 48 | + uses: actions/setup-go@v5.0.2 |
| 49 | + with: |
| 50 | + go-version: ${{ matrix.go_version }} |
| 51 | + |
| 52 | + - name: Cache Go modules |
| 53 | + id: cache |
| 54 | + uses: actions/cache@v4 |
| 55 | + with: |
| 56 | + path: ~/go/pkg/mod |
| 57 | + key: v1-go${{ matrix.go_version }} |
| 58 | + |
| 59 | + - name: Run tests and check license |
| 60 | + run: make check_license test |
| 61 | + env: |
| 62 | + CI: true |
| 63 | + |
| 64 | + - name: Run style and unused |
| 65 | + if: ${{ matrix.go_version == '1.21' }} |
| 66 | + run: make style unused |
0 commit comments