|
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 |
| 1 | +--- |
| 2 | +name: Validate |
| 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 | + supported_versions: |
| 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 | 28 | uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
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 |
| 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: supported_versions |
| 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.supported_versions.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 | 52 | uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
53 | | - |
54 | | - - name: Set up Go ${{ matrix.go_version }} |
55 | | - |
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 |
| 53 | + |
| 54 | + - name: Check for CRLF line endings |
| 55 | + run: make check-crlf |
| 56 | + |
| 57 | + - name: Set up Go ${{ matrix.go_version }} |
| 58 | + |
| 59 | + with: |
| 60 | + go-version: ${{ matrix.go_version }} |
| 61 | + check-latest: true |
| 62 | + cache-dependency-path: go.sum |
| 63 | + |
| 64 | + - name: Run tests and check license |
| 65 | + run: make check_license test |
| 66 | + env: |
| 67 | + CI: true |
| 68 | + |
| 69 | + - name: Run style and unused |
| 70 | + if: ${{ matrix.go_version == '1.22' }} |
| 71 | + run: make style unused |
0 commit comments