diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index b721f1d0..6bd985a2 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -13,7 +13,27 @@ defaults: shell: bash jobs: + + download-task-template: + runs-on: ubuntu-latest + steps: + + - name: Download task template + run: | + LATEST=$(curl -s https://api.github.com/repos/nipype/pydra-tasks-template/releases/latest | grep tag_name | awk -F\" '{print $4}') + curl -Lo pydra-tasks-template.tar.gz https://github.com/nipype/pydra-tasks-template/archive/refs/tags/$LATEST.tar.gz + tar xzf pydra-tasks-template.tar.gz + rm pydra-tasks-template.tar.gz + mv pydra-tasks-template-${LATEST#v} pydra-tasks-template + tar czf pydra-tasks-template.tar.gz pydra-tasks-template + + - uses: actions/upload-artifact@v4 + with: + name: tasks-template + path: pydra-tasks-template.tar.gz + test: + needs: [download-task-template] strategy: matrix: os: [macos-latest, ubuntu-latest] @@ -28,6 +48,15 @@ jobs: - name: Checkout uses: actions/checkout@v2 + - name: Download the pydra-tasks-template artefact + uses: actions/download-artifact@v4 + with: + name: tasks-template + path: . + + - name: Extract the pydra-tasks-template + run: tar xzf pydra-tasks-template.tar.gz + - name: Unset header # checkout@v2 adds a header that makes branch protection report errors # because the Github action bot is not a collaborator on the repo @@ -64,7 +93,9 @@ jobs: run: python3 -m pip install --break-system-packages .[test] - name: Pytest - run: pytest -vvs --cov nipype2pydra --cov-config .coveragerc --cov-report xml + run: >- + NIPYPE2PYDRA_PYDRA_TASK_TEMPLATE=$PWD/pydra-tasks-template + pytest -vvs --cov nipype2pydra --cov-config .coveragerc --cov-report xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v2 diff --git a/conftest.py b/conftest.py index cce075c8..101906ab 100644 --- a/conftest.py +++ b/conftest.py @@ -40,6 +40,14 @@ def invoke(*args, catch_exceptions=catch_cli_exceptions, **kwargs): return invoke +@pytest.fixture +def tasks_template_args(): + template = os.environ.get("NIPYPE2PYDRA_PYDRA_TASK_TEMPLATE", None) + if template: + return ["--task-template", template] + return [] + + # For debugging in IDE's don't catch raised exceptions and let the IDE # break at it if os.getenv("_PYTEST_RAISE", "0") != "0": diff --git a/nipype2pydra/pkg_gen/tests/test_pkg_gen.py b/nipype2pydra/pkg_gen/tests/test_pkg_gen.py index 21115f5c..83a0c16a 100644 --- a/nipype2pydra/pkg_gen/tests/test_pkg_gen.py +++ b/nipype2pydra/pkg_gen/tests/test_pkg_gen.py @@ -15,7 +15,7 @@ def pkg_gen_spec_file(request): return EXAMPLE_PKG_GEN_DIR.joinpath(*request.param.split("-")).with_suffix(".yaml") -def test_pkg_gen(pkg_gen_spec_file, cli_runner, tmp_path): +def test_pkg_gen(pkg_gen_spec_file, cli_runner, tmp_path, tasks_template_args): outputs_dir = tmp_path / "output-dir" outputs_dir.mkdir() @@ -24,6 +24,7 @@ def test_pkg_gen(pkg_gen_spec_file, cli_runner, tmp_path): [ str(pkg_gen_spec_file), str(outputs_dir), - ], + ] + + tasks_template_args, ) assert result.exit_code == 0, show_cli_trace(result) diff --git a/nipype2pydra/tests/test_package.py b/nipype2pydra/tests/test_package.py index be625c2a..1b8865b2 100644 --- a/nipype2pydra/tests/test_package.py +++ b/nipype2pydra/tests/test_package.py @@ -33,7 +33,7 @@ def package_spec(request): @pytest.mark.xfail(reason="Fails due to missing dependencies on PyPI") -def test_package_complete(package_spec, cli_runner, tmp_path): +def test_package_complete(package_spec, cli_runner, tmp_path, tasks_template_args): pkg_name = package_spec.stem repo_output = tmp_path / "repo" repo_output.mkdir() @@ -43,7 +43,8 @@ def test_package_complete(package_spec, cli_runner, tmp_path): [ str(package_spec), str(repo_output), - ], + ] + + tasks_template_args, ) assert result.exit_code == 0, show_cli_trace(result) pkg_root = repo_output / f"pydra-{pkg_name}"