From 932a772b77fc576bfc5f1f3c2b8efed214aea4fc Mon Sep 17 00:00:00 2001 From: "Adam H. Freedman" Date: Wed, 17 Jun 2026 09:20:59 -0400 Subject: [PATCH] Add GitHub Actions test workflow --- .github/workflows/tests.yml | 113 ++++++++++++++++++++++++++++++++++++ tests/README.md | 4 ++ 2 files changed, 117 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..afeed2b --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,113 @@ +name: Tests + +on: + pull_request: + workflow_dispatch: + +concurrency: + group: tests-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +defaults: + run: + shell: bash -el {0} + +jobs: + default-pytest: + name: Default pytest suite + runs-on: ubuntu-latest + timeout-minutes: 30 + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up conda test environment + uses: conda-incubator/setup-miniconda@v3 + with: + miniforge-version: latest + activate-environment: scrnaseq-cluster-downsample-tests + environment-file: environment.yml + auto-activate-base: false + use-mamba: true + + - name: Show tool versions + run: | + python --version + pytest --version + snakemake --version + + - name: Run default tests + run: pytest tests -q + + snakemake-rule: + name: Snakemake rule execution + runs-on: ubuntu-latest + timeout-minutes: 90 + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up conda test environment + uses: conda-incubator/setup-miniconda@v3 + with: + miniforge-version: latest + activate-environment: scrnaseq-cluster-downsample-tests + environment-file: environment.yml + auto-activate-base: false + use-mamba: true + + - name: Cache Snakemake conda environments + uses: actions/cache@v4 + with: + path: .snakemake/conda + key: ${{ runner.os }}-snakemake-conda-${{ hashFiles('workflow/envs/downsample_clusters.yml', 'workflow/envs/downsample_clusters.linux-64.pin.txt') }} + restore-keys: | + ${{ runner.os }}-snakemake-conda- + + - name: Show tool versions + run: | + python --version + pytest --version + snakemake --version + conda --version + + - name: Run Snakemake rule test + run: pytest tests --run-rule -q + + full-workflow: + name: Full Snakemake workflow + runs-on: ubuntu-latest + timeout-minutes: 120 + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up conda test environment + uses: conda-incubator/setup-miniconda@v3 + with: + miniforge-version: latest + activate-environment: scrnaseq-cluster-downsample-tests + environment-file: environment.yml + auto-activate-base: false + use-mamba: true + + - name: Cache Snakemake conda environments + uses: actions/cache@v4 + with: + path: .snakemake/conda + key: ${{ runner.os }}-snakemake-conda-${{ hashFiles('workflow/envs/downsample_clusters.yml', 'workflow/envs/downsample_clusters.linux-64.pin.txt') }} + restore-keys: | + ${{ runner.os }}-snakemake-conda- + + - name: Show tool versions + run: | + python --version + pytest --version + snakemake --version + conda --version + + - name: Run full testdata workflow + run: pytest tests --run-workflow -q diff --git a/tests/README.md b/tests/README.md index 7fd66b5..e89090a 100644 --- a/tests/README.md +++ b/tests/README.md @@ -20,6 +20,10 @@ To execute the full testdata workflow and write outputs under `testdata/results/ pytest tests --run-workflow -q ``` +GitHub Actions runs the default suite, the optional rule test, and the full +workflow test on pull requests. The same workflow can also be started manually +from the Actions tab with `workflow_dispatch`. + The full-workflow test removes `testdata/results/` before running so that both expected test fixture outputs are regenerated from scratch. It validates each output table and compares it to the reference snapshot under `tests/reference_outputs/testdata/results/`. By default Snakemake creates rule conda environments under `.snakemake/conda` in the repository root. To use an explicit Snakemake conda prefix: