From b5232c02100c4f725bd3eb397e24ea9e015d16fd Mon Sep 17 00:00:00 2001 From: Ahmet Nihat Simsek Date: Thu, 17 Oct 2024 16:12:33 +0200 Subject: [PATCH] test: separate example tests from e2e and display example names --- .github/workflows/_run_examples.yaml | 41 ++++++++++++++++++++++++++++ .github/workflows/siibra-testing.yml | 8 ++++++ {e2e => examples}/test_examples.py | 5 +++- 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/_run_examples.yaml rename {e2e => examples}/test_examples.py (64%) diff --git a/.github/workflows/_run_examples.yaml b/.github/workflows/_run_examples.yaml new file mode 100644 index 000000000..d65d7696e --- /dev/null +++ b/.github/workflows/_run_examples.yaml @@ -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 diff --git a/.github/workflows/siibra-testing.yml b/.github/workflows/siibra-testing.yml index 53c92177b..b7d343ea8 100644 --- a/.github/workflows/siibra-testing.yml +++ b/.github/workflows/siibra-testing.yml @@ -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 }} \ No newline at end of file diff --git a/e2e/test_examples.py b/examples/test_examples.py similarity index 64% rename from e2e/test_examples.py rename to examples/test_examples.py index 09e078d79..ade3109c4 100644 --- a/e2e/test_examples.py +++ b/examples/test_examples.py @@ -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)