Skip to content

Commit 9c010e7

Browse files
committed
Use a test setup matrix like TensorKit
1 parent 03d21cf commit 9c010e7

1 file changed

Lines changed: 57 additions & 20 deletions

File tree

.github/workflows/Tests.yml

Lines changed: 57 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,70 @@ on:
99
paths-ignore:
1010
- 'docs/**'
1111
pull_request:
12+
types: [opened, synchronize, reopened, ready_for_review, converted_to_draft]
1213
workflow_dispatch:
1314

1415
concurrency:
1516
group: ${{ github.workflow }}-${{ github.ref }}
1617
# Cancel intermediate builds: only if it is a pull request build.
1718
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
18-
19+
1920
jobs:
20-
tests:
21-
name: "Tests"
21+
setup-matrix:
22+
runs-on: ubuntu-latest
23+
outputs:
24+
groups: ${{ steps.mk.outputs.groups }}
25+
version: ${{ steps.mk.outputs.version }}
26+
os: ${{ steps.mk.outputs.os }}
27+
steps:
28+
- uses: actions/checkout@v6
29+
- id: mk
30+
shell: bash
31+
run: |
32+
# Auto-discover test groups from all subdirectory names.
33+
groups=$(find test -mindepth 1 -maxdepth 1 -type d \
34+
| xargs -I{} basename {} | sort \
35+
| jq -R -s -c '[split("\n")[] | select(length > 0)]')
36+
37+
echo "groups=${groups}" >> "$GITHUB_OUTPUT"
38+
39+
# Draft PR: only run ubuntu-latest + version=1
40+
if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.draft }}" == "true" ]]; then
41+
echo 'version=["1"]' >> "$GITHUB_OUTPUT"
42+
echo 'os=["ubuntu-latest"]' >> "$GITHUB_OUTPUT"
43+
else
44+
echo 'version=["lts","1"]' >> "$GITHUB_OUTPUT"
45+
echo 'os=["ubuntu-latest","macOS-latest","windows-latest"]' >> "$GITHUB_OUTPUT"
46+
fi
47+
48+
test:
49+
name: "Tests (${{ matrix.group }}, ${{ matrix.os }}, Julia ${{ matrix.version }})"
50+
needs: setup-matrix
2251
strategy:
2352
fail-fast: false
2453
matrix:
25-
version:
26-
- 'lts' # minimal supported version
27-
- '1' # latest released Julia version
28-
# group:
29-
os:
30-
- ubuntu-latest
31-
- macOS-latest
32-
- windows-latest
33-
uses: "QuantumKitHub/QuantumKitHubActions/.github/workflows/Tests.yml@main"
34-
with:
35-
group: "${{ matrix.group }}"
36-
nthreads: 4
37-
julia-version: "${{ matrix.version }}"
38-
os: "${{ matrix.os }}"
39-
timeout-minutes: 120
40-
secrets:
41-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
54+
version: ${{ fromJSON(needs.setup-matrix.outputs.version) }}
55+
os: ${{ fromJSON(needs.setup-matrix.outputs.os) }}
56+
group: ${{ fromJSON(needs.setup-matrix.outputs.groups) }}
57+
runs-on: ${{ matrix.os }}
58+
timeout-minutes: 120
59+
steps:
60+
- uses: actions/checkout@v6
61+
- uses: julia-actions/setup-julia@v2
62+
with:
63+
version: ${{ matrix.version }}
64+
- uses: julia-actions/cache@v3
65+
- uses: julia-actions/julia-buildpkg@v1
66+
- uses: julia-actions/julia-runtest@v1
67+
with:
68+
test_args: '${{ matrix.group }}${{ github.event.pull_request.draft == true && '' --fast'' || '''' }}'
69+
env:
70+
JULIA_NUM_THREADS: "4"
71+
- uses: julia-actions/julia-processcoverage@v1
72+
with:
73+
directories: 'src,ext'
74+
- uses: codecov/codecov-action@v6
75+
with:
76+
files: lcov.info
77+
token: ${{ secrets.CODECOV_TOKEN }}
78+
fail_ci_if_error: false

0 commit comments

Comments
 (0)