Skip to content

Commit

Permalink
test: separate example tests from e2e and display example names
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmetNSimsek committed Oct 17, 2024
1 parent 14757d1 commit b5232c0
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
41 changes: 41 additions & 0 deletions .github/workflows/_run_examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: example test
on:
workflow_call:
inputs:
os:
required: true
type: string
python-version:
required: true
type: string
use-cfg:
required: false
type: string
default: ''

jobs:
test_examples:
runs-on: ${{ inputs.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}

- if: ${{ inputs.use-cfg != '' }}
uses: './.github/workflows/setup-custom-cfg'
with:
siibra-cfg-ref: ${{ inputs.use-cfg }}

- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install -U .
pip install -r requirements-test.txt
- name: Install test dependencies
run: pip install pytest pytest-cov coverage
- name: Run test with pytest
shell: bash
run: pytest -rx examples/test_examples.py
8 changes: 8 additions & 0 deletions .github/workflows/siibra-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,11 @@ jobs:
os: ubuntu-latest
python-version: "3.8"
use-cfg: ${{ needs.use-custom-cfg.outputs.USE_REF }}

test-examples:
needs: 'use-custom-cfg'
uses: ./.github/workflows/_run_examples.yaml
with:
os: ubuntu-latest
python-version: "3.8"
use-cfg: ${{ needs.use-custom-cfg.outputs.USE_REF }}
5 changes: 4 additions & 1 deletion e2e/test_examples.py → examples/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@


@pytest.mark.parametrize('example', examples)
def test_script_execution(example):
def test_script_execution(example: pathlib.Path):
if example.name == "test_examples.py":
print("Skipping:", example)
return
print("Running:", example)
runpy.run_path(example)

0 comments on commit b5232c0

Please sign in to comment.