Skip to content

Commit 36fcb92

Browse files
committed
Factorize run-tests into its own composite action
1 parent 04f5780 commit 36fcb92

2 files changed

Lines changed: 48 additions & 13 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Run Tests
2+
description: Run unit and doc tests with coverage
3+
4+
inputs:
5+
ignores:
6+
description: 'Space-separated list of test files to ignore'
7+
required: false
8+
default: ''
9+
dtype:
10+
description: 'Torch dtype to use for tests'
11+
required: false
12+
default: 'float32'
13+
device:
14+
description: 'Torch device to use for tests'
15+
required: false
16+
default: 'cpu'
17+
18+
runs:
19+
using: composite
20+
steps:
21+
- name: Run unit and doc tests with coverage report
22+
shell: bash
23+
env:
24+
PYTEST_TORCH_DTYPE: ${{ inputs.dtype }}
25+
PYTEST_TORCH_DEVICE: ${{ inputs.device }}
26+
run: |
27+
# Build the pytest command
28+
cmd="uv run pytest -W error tests/unit tests/doc"
29+
30+
# Add ignore flags for each file
31+
if [ -n "${{ inputs.ignores }}" ]; then
32+
for file in ${{ inputs.ignores }}; do
33+
cmd="$cmd --ignore $file"
34+
done
35+
fi
36+
37+
# Add coverage options
38+
cmd="$cmd --cov=src --cov-report=xml"
39+
40+
# Execute the command
41+
eval $cmd

.github/workflows/tests.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ jobs:
3232
options: full
3333
groups: test
3434

35-
- name: Run unit and doc tests with coverage report
36-
run: uv run pytest -W error tests/unit tests/doc --cov=src --cov-report=xml
35+
- uses: ./.github/actions/run-tests
3736

3837
- &upload-codecov
3938
name: Upload results to Codecov
@@ -54,13 +53,9 @@ jobs:
5453
with:
5554
groups: test
5655

57-
- name: Run unit and doc tests with coverage report
58-
run: |
59-
uv run pytest -W error tests/unit tests/doc \
60-
--ignore tests/unit/aggregation/test_cagrad.py \
61-
--ignore tests/unit/aggregation/test_nash_mtl.py \
62-
--ignore tests/doc/test_aggregation.py \
63-
--cov=src --cov-report=xml
56+
- uses: ./.github/actions/run-tests
57+
with:
58+
ignores: tests/unit/aggregation/test_cagrad.py tests/unit/aggregation/test_nash_mtl.py tests/doc/test_aggregation.py
6459

6560
- *upload-codecov
6661

@@ -78,10 +73,9 @@ jobs:
7873
options: full
7974
groups: test
8075

81-
- name: Run unit and doc tests with coverage report
82-
run: uv run pytest -W error tests/unit tests/doc --cov=src --cov-report=xml
83-
env:
84-
PYTEST_TORCH_DTYPE: float64
76+
- uses: ./.github/actions/run-tests
77+
with:
78+
dtype: float64
8579

8680
- *upload-codecov
8781

0 commit comments

Comments
 (0)