From 0abecbd306b414c20b680bb003f0f840e11c4669 Mon Sep 17 00:00:00 2001 From: fbdtemme Date: Tue, 10 Oct 2023 14:01:24 +0200 Subject: [PATCH 1/4] ci: update workflow tests style: add whitespace --- ...tegration-tests.yml => workflow-tests.yml} | 35 ++++++++----------- src/pixelator/test_utils/collector.py | 32 ++++++++++++----- tests/integration/external_tests/readme.md | 1 + tests/integration/test_full_D21.yaml | 23 ++++++++++++ 4 files changed, 61 insertions(+), 30 deletions(-) rename .github/workflows/{integration-tests.yml => workflow-tests.yml} (78%) create mode 100644 tests/integration/external_tests/readme.md create mode 100644 tests/integration/test_full_D21.yaml diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/workflow-tests.yml similarity index 78% rename from .github/workflows/integration-tests.yml rename to .github/workflows/workflow-tests.yml index 675d267c..5f211694 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/workflow-tests.yml @@ -13,18 +13,16 @@ on: container-tag: description: 'Container tag' required: true - default: 'latest-dev' + default: 'dev' keep-workdirs: description: 'Keep working directories for debugging' required: false default: 'false' push: branches: - - main - tags: - - 'v*' + - fix/ci-integration-tests schedule: - # 01:00 every day + # 01:00 every day, using last commit on default branch - cron: "0 1 * * *" jobs: @@ -51,6 +49,7 @@ jobs: - 'poetry.lock' paths_ignore: - 'tests/**/*.md' + setup: runs-on: ubuntu-latest needs: pre_job @@ -74,19 +73,20 @@ jobs: mask-password: 'false' test: - runs-on: [ "self-hosted", "linux", "x64", "ubuntu-latest" ] + runs-on: [ "self-hosted", "Linux", "X64" ] needs: [setup] container: - image: 890888997283.dkr.ecr.eu-north-1.amazonaws.com/pixelator:${{ github.event.inputs.container-tag || 'latest-dev' }} + image: 890888997283.dkr.ecr.eu-north-1.amazonaws.com/pixelator:${{ github.event.inputs.container-tag || 'dev' }} credentials: username: ${{ needs.setup.outputs.docker_username }} password: ${{ needs.setup.outputs.docker_password }} volumes: - - /mnt/github-actions-data:/data + - /mnt/pixelgen-github-actions-data:/mnt/pixelgen-github-actions-data + - /mnt/pixelgen-technologies-datasets:/mnt/pixelgen-technologies-datasets strategy: fail-fast: false matrix: - test: [ "small", "single-cell", "tissue" ] + test: [ "test_small_D21", "test_full_D21" ] steps: - name: Install poetry @@ -96,25 +96,18 @@ jobs: pipx install poetry poetry self add poetry-plugin-export + - name: Checkout code + uses: actions/checkout@v4 + - name: Install dev dependencies - working-directory: /pixelator run: | poetry export -f requirements.txt --output requirements_only_dev.txt --only dev pip3 install -r requirements_only_dev.txt - - name: Prepare test case string - uses: actions/github-script@v6 - id: test_case_file - with: - script: | - const test_name = "${{ matrix.test }}" - const test_file_name = `test_${test_name.replace(/-/g, '_')}.py` - core.setOutput('filename', test_file_name) - - name: Test pixelator run: | - CMD="pytest /pixelator/tests/integration/${{ steps.test_case_file.outputs.filename }} --log-cli-level=DEBUG" + CMD="pytest --log-cli-level=DEBUG" if [[ "${{ github.event.inputs.keep-workdirs }}" == "true" ]]; then CMD="$CMD --keep-workdirs" fi - $CMD -m "workflow_test" + $CMD -m "workflow_test" "${{ matrix.test }}" diff --git a/src/pixelator/test_utils/collector.py b/src/pixelator/test_utils/collector.py index a50f785b..fb635951 100644 --- a/src/pixelator/test_utils/collector.py +++ b/src/pixelator/test_utils/collector.py @@ -1,30 +1,44 @@ -""" +"""Custom pytest collector utilities to generate tests from yaml files. + Copyright (c) 2023 Pixelgen Technologies AB. """ - import pytest from pixelator.test_utils import PixelatorWorkflowTest, WorkflowConfig +class NoModuleClass(pytest.Class): # noqa + """Mock pytest.Class that does not require a module as a parent.""" + + class MockModule: + """Fake module with a None obj.""" + + def __init__(self): # noqa + self.obj = None + + def getparent(self, cls): # noqa + parent = super().getparent(cls) + if parent is None: + return self.MockModule() + return parent + + class YamlIntegrationTestsCollector(pytest.File): - """ - Custom pytest collector generating tests from yaml files. - """ + """Custom pytest collector generating tests from yaml files.""" - def collect(self, parent_module=None): - # We need a yaml parser, e.g. PyYAML. + def collect(self): + """Convert yaml files to test cases.""" config = WorkflowConfig(self.path) for case in config.keys(): name = case.split("-")[1] wf = type( - f"TestSmallWorkflow{name}", + f"TestWorkflow{name}", (PixelatorWorkflowTest,), {"test_id": case, **config.get_test_config(case)}, ) - collector = pytest.Class.from_parent(parent=self, name=name) + collector = NoModuleClass.from_parent(parent=self, name=self.path.stem) # Need to add this explicitly since the constructor does not set obj collector.obj = wf diff --git a/tests/integration/external_tests/readme.md b/tests/integration/external_tests/readme.md new file mode 100644 index 00000000..bc66fa95 --- /dev/null +++ b/tests/integration/external_tests/readme.md @@ -0,0 +1 @@ +External workflow test YAML files can be mounted or symlinked here and will be run as part of the workflow test suite. diff --git a/tests/integration/test_full_D21.yaml b/tests/integration/test_full_D21.yaml new file mode 100644 index 00000000..68aefb95 --- /dev/null +++ b/tests/integration/test_full_D21.yaml @@ -0,0 +1,23 @@ +full-D21: + design: D21 + panel: "human-sc-immunology-spatial-proteomics" + panel_file: null + input_files: + - /mnt/pixelgen-technologies-datasets/mpx-datasets/scsp/1.0/1k-human-pbmcs-v1.0-immunology-I/Sample01_human_pbmcs_unstimulated_R1_001.fastq.gz + - /mnt/pixelgen-technologies-datasets/mpx-datasets/scsp/1.0/1k-human-pbmcs-v1.0-immunology-I/Sample01_human_pbmcs_unstimulated_R2_001.fastq.gz + options: + common: + verbose: true + graph: + params: [ + "--multiplet-recovery" + ] + annotate: + params: [] + + analysis: + params: [ + "--compute-polarization", + "--compute-colocalization", + "--use-full-bipartite" + ] From 86bfd48de48d504c1ba533ec542373f651d5be4c Mon Sep 17 00:00:00 2001 From: fbdtemme Date: Wed, 11 Oct 2023 13:58:28 +0200 Subject: [PATCH 2/4] ci: add missing -k in pytest invocation --- .github/workflows/workflow-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow-tests.yml b/.github/workflows/workflow-tests.yml index 5f211694..f1698d96 100644 --- a/.github/workflows/workflow-tests.yml +++ b/.github/workflows/workflow-tests.yml @@ -110,4 +110,4 @@ jobs: if [[ "${{ github.event.inputs.keep-workdirs }}" == "true" ]]; then CMD="$CMD --keep-workdirs" fi - $CMD -m "workflow_test" "${{ matrix.test }}" + $CMD -m "workflow_test" -k "${{ matrix.test }}" From dc74624266ca349263d4e6042aa67e16d41e515e Mon Sep 17 00:00:00 2001 From: fbdtemme Date: Thu, 12 Oct 2023 11:48:25 +0200 Subject: [PATCH 3/4] tweak full test execution parameters --- src/pixelator/test_utils/collector.py | 3 ++- tests/integration/test_full_D21.yaml | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pixelator/test_utils/collector.py b/src/pixelator/test_utils/collector.py index fb635951..c7292990 100644 --- a/src/pixelator/test_utils/collector.py +++ b/src/pixelator/test_utils/collector.py @@ -32,10 +32,11 @@ def collect(self): for case in config.keys(): name = case.split("-")[1] + case_config = config.get_test_config(case) wf = type( f"TestWorkflow{name}", (PixelatorWorkflowTest,), - {"test_id": case, **config.get_test_config(case)}, + {"test_id": case, **case_config}, ) collector = NoModuleClass.from_parent(parent=self, name=self.path.stem) diff --git a/tests/integration/test_full_D21.yaml b/tests/integration/test_full_D21.yaml index 68aefb95..6a699a89 100644 --- a/tests/integration/test_full_D21.yaml +++ b/tests/integration/test_full_D21.yaml @@ -13,11 +13,13 @@ full-D21: "--multiplet-recovery" ] annotate: - params: [] + params: [ + "--dynamic-filter", "min", + "--aggregate-calling" + ] analysis: params: [ "--compute-polarization", "--compute-colocalization", - "--use-full-bipartite" ] From 1fe4c4bb34d82428111ce4be2d514aec61098888 Mon Sep 17 00:00:00 2001 From: fbdtemme Date: Fri, 13 Oct 2023 10:14:05 +0200 Subject: [PATCH 4/4] chore: remove trigger on test branch --- .github/workflows/workflow-tests.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/workflow-tests.yml b/.github/workflows/workflow-tests.yml index f1698d96..b4fa54f7 100644 --- a/.github/workflows/workflow-tests.yml +++ b/.github/workflows/workflow-tests.yml @@ -18,9 +18,6 @@ on: description: 'Keep working directories for debugging' required: false default: 'false' - push: - branches: - - fix/ci-integration-tests schedule: # 01:00 every day, using last commit on default branch - cron: "0 1 * * *"