@@ -24,19 +24,42 @@ jobs:
2424 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2525 - run : mise run lint
2626
27- test :
28- runs-on : ${{ matrix.os }}
29- name : Test (${{ matrix.os}}, Git ${{ matrix.git-version }})
27+ test-matrix :
28+ name : Generate test matrix
29+ runs-on : ubuntu-latest
30+ steps :
31+ - uses : actions/checkout@v4
32+ name : Check out repository
33+ - uses : jdx/mise-action@v2
34+ env :
35+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
36+ - name : Go cache
37+ uses : ./.github/actions/go-cache
38+ - name : Generate test matrix
39+ id : generate
40+ run : echo "matrix=$(go run ./tools/ci/test-matrix)" >> "$GITHUB_OUTPUT"
41+ outputs :
42+ matrix : ${{ steps.generate.outputs.matrix }}
3043
44+ test :
45+ needs : [test-matrix]
3146 strategy :
32- matrix :
33- os : ["ubuntu-latest", "windows-latest"]
34- git-version : ["system"]
35- include :
36- # On Linux, also test against specific versions built from source.
37- - {os: ubuntu-latest, git-version: "2.38.0"}
38- # On Windows, run without coverage.
39- - {os: windows-latest, no-cover: true}
47+ fail-fast : true
48+ matrix : ${{ fromJson(needs.test-matrix.outputs.matrix) }}
49+ # Schema of matrix:
50+ # name: string
51+ # os: ubuntu-latest | windows-latest
52+ # git-version: system | 2.38.0 | ...
53+ # suite: default | script
54+ # race: bool
55+ # cover: bool
56+ #
57+ # If suite is 'script', then:
58+ # shard-index: int
59+ # shard-count: int
60+
61+ runs-on : ${{ matrix.os }}
62+ name : Test / ${{ matrix.name }}
4063
4164 steps :
4265 - uses : actions/checkout@v4
@@ -56,21 +79,35 @@ jobs:
5679 run :
5780 git --version
5881
82+ # TODO: can probably generate the exact test command in the matrix
5983 - name : Test
84+ if : ${{ matrix.suite == 'default' }}
6085 run : >- # join lines with spaces
6186 mise run
62- ${{ ( matrix.no- cover == true) && 'test ' || 'cover ' }}
63- ${{ ( matrix.os != 'windows-latest') && '--race' || '' }}
87+ ${{ matrix.cover && 'cover:default ' || 'test:default ' }}
88+ ${{ matrix.race && '--race' || '' }}
6489 # NB:
6590 # Windows tests are already slow.
6691 # Run them without race detection to avoid slowing them further.
6792 shell : bash
6893 env :
6994 GOTESTSUM_FORMAT : github-actions
7095
96+ - name : Script tests
97+ if : ${{ matrix.suite == 'script' }}
98+ run : |
99+ mise run \
100+ ${{ matrix.cover && 'cover:script' || 'test:script' }} \
101+ ${{ matrix.race && '--race' || '' }} \
102+ --shard-index "${{ matrix.shard-index || '0' }}" \
103+ --shard-count "${{ matrix.shard-count || '1' }}"
104+ shell : bash
105+ env :
106+ GOTESTSUM_FORMAT : github-actions
107+
71108 - name : Upload coverage
72109 uses : codecov/codecov-action@v5.4.3
73- if : ${{ matrix.no-cover != true }}
110+ if : ${{ matrix.os != 'windows-latest' }}
74111 with :
75112 files : ./cover.out
76113 token : ${{ secrets.CODECOV_TOKEN }}
0 commit comments