Skip to content

Commit b5232c0

Browse files
committed
test: separate example tests from e2e and display example names
1 parent 14757d1 commit b5232c0

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

.github/workflows/_run_examples.yaml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: example test
2+
on:
3+
workflow_call:
4+
inputs:
5+
os:
6+
required: true
7+
type: string
8+
python-version:
9+
required: true
10+
type: string
11+
use-cfg:
12+
required: false
13+
type: string
14+
default: ''
15+
16+
jobs:
17+
test_examples:
18+
runs-on: ${{ inputs.os }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up Python ${{ inputs.python-version }}
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: ${{ inputs.python-version }}
25+
26+
- if: ${{ inputs.use-cfg != '' }}
27+
uses: './.github/workflows/setup-custom-cfg'
28+
with:
29+
siibra-cfg-ref: ${{ inputs.use-cfg }}
30+
31+
- name: Install dependencies
32+
shell: bash
33+
run: |
34+
python -m pip install --upgrade pip
35+
python -m pip install -U .
36+
pip install -r requirements-test.txt
37+
- name: Install test dependencies
38+
run: pip install pytest pytest-cov coverage
39+
- name: Run test with pytest
40+
shell: bash
41+
run: pytest -rx examples/test_examples.py

.github/workflows/siibra-testing.yml

+8
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,11 @@ jobs:
9898
os: ubuntu-latest
9999
python-version: "3.8"
100100
use-cfg: ${{ needs.use-custom-cfg.outputs.USE_REF }}
101+
102+
test-examples:
103+
needs: 'use-custom-cfg'
104+
uses: ./.github/workflows/_run_examples.yaml
105+
with:
106+
os: ubuntu-latest
107+
python-version: "3.8"
108+
use-cfg: ${{ needs.use-custom-cfg.outputs.USE_REF }}

e2e/test_examples.py examples/test_examples.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99

1010
@pytest.mark.parametrize('example', examples)
11-
def test_script_execution(example):
11+
def test_script_execution(example: pathlib.Path):
12+
if example.name == "test_examples.py":
13+
print("Skipping:", example)
14+
return
1215
print("Running:", example)
1316
runpy.run_path(example)

0 commit comments

Comments
 (0)