Skip to content

CI: run the Python tests in 16 groups instead of one job per test file - #4634

Open
ewels wants to merge 4 commits into
devfrom
claude/stoic-volta-31tgce-ci-groups
Open

ewels wants to merge 4 commits into
devfrom
claude/stoic-volta-31tgce-ci-groups

Conversation

@ewels

@ewels ewels commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

The "Python tests" workflow starts one job per test file: 94 jobs on PRs, and 188 on pushes to dev. Each job spends about 30 s on setup plus about a minute waiting for a runner, and many test files take less time than that to run.

This PR runs the tests in 16 groups instead, using pytest-split, plus one download group for the tests that need Apptainer.

Timings

dev (PR run) this PR
Jobs 94 17
Wall time 9.3 min 7.0 min
Runner time 143 min 80 min

Both columns are single runs. dev is this PR run; other recent dev PR runs took 9.4–11 min. The new wall time is limited by the slowest group, which is about 6 min of tests.

How it works

  • pytest-split deals the tests out round-robin, so a slow file's tests end up spread over many groups.
  • Nothing to maintain. New test files are picked up automatically. The number of groups is set in one place, PYTEST_SPLITS, and a small Get test groups job turns it into the job matrix.
  • setup-uv now installs Python, so the separate setup-python step is gone.

Bug fix found along the way

Two tests failed on the first run with Branch 'subworkflows' not found in 'https://gitlab.com/nf-core/modules-test.git'. This is an existing bug in SyncedRepo.checkout().

  • What breaks: git checkout subworkflows refuses to run if the branch currently checked out has a subworkflows/ folder ("could be both a local file and a tracking branch").
  • Why it appeared now: with one job per file, those tests never shared a cached clone. Mixing tests from different files in one job exposed it.
  • Fix: pass --, so git always reads the argument as a branch or commit. It can affect users too, so it has its own changelog entry.
Why no durations file?

pytest-split can balance groups using a committed file of per-test durations. That file goes stale as tests change. I simulated both approaches with the per-test timings from the latest dev run:

Other details
  • The snapshot report artifact is uploaded whenever a failed run produced snapshot_report.html. Previously that depended on the job's test file name.
  • Codecov's MATRIX_TEST is now the group name.
  • Every run prints a two-line "No test durations found" notice from pytest-split. That's expected.
  • Speed up module/subworkflow install and update by not checking out old commits #4633 also edits SyncedRepo.checkout(), so whichever PR merges second will need a small rebase.

Before merging: job names change from Run <file> with … to Run tests (group N) with …. Any required status checks that name the old jobs need updating.

Split out of #4629.

PR checklist

  • This comment contains a description of changes (with reason)
  • CHANGELOG.md is updated
  • If you've fixed a bug or added code that should be tested, add tests! (the fix is covered by the existing subworkflow tests that failed)
  • Documentation in docs is updated (n/a)

🤖 Generated with Claude Code

https://claude.ai/code/session_01MhDtLdb3HSoES4BFJRnUzw

Use pytest-split to deal the tests round-robin into 16 groups, plus one group
for the download tests, which need Apptainer. Without a durations file every
test counts the same, which spreads each file's slow tests over all groups.
New test files are picked up automatically.

Also let setup-uv install Python instead of a separate setup-python step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MhDtLdb3HSoES4BFJRnUzw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MhDtLdb3HSoES4BFJRnUzw
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.88%. Comparing base (cd7c955) to head (f5883f7).

Files with missing lines Patch % Lines
nf_core/synced_repo.py 50.00% 1 Missing ⚠️

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MhDtLdb3HSoES4BFJRnUzw
`git checkout subworkflows` fails with "could be both a local file and a
tracking branch" when the checked-out branch has a subworkflows/ directory
and there is no local 'subworkflows' branch yet. Pass "--" so git always
treats the argument as a revision.

This showed up in CI once tests from different files shared a worker, and
so the same cached clone of the modules-test repository.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MhDtLdb3HSoES4BFJRnUzw
@codspeed

codspeed Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 39.4%

3 warnings

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ 9 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚠️ 9 benchmarks with a significant change ran in a different software environment

Their base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the changes might come from this difference rather than from the code. Open an affected benchmark to see what changed.

See affected benchmarks

⚡ 9 improved benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_modules_install_startup 2.3 s 1.6 s +46.95%
⚡ test_pipelines_create_startup 998.2 ms 693 ms +44.05%
⚡ test_pipelines_schema_lint_startup 382.7 ms 269.1 ms +42.22%
⚡ test_cli_command_group_help_startup[subworkflows] 174.5 ms 124.5 ms +40.19%
⚡ test_cli_help_startup 170.3 ms 123.3 ms +38.18%
⚡ test_import_main_startup 134.6 ms 98.4 ms +36.9%
⚡ test_cli_command_group_help_startup[modules] 171 ms 125 ms +36.73%
⚡ test_cli_command_group_help_startup[pipelines] 168.7 ms 124.3 ms +35.68%
⚡ test_cli_command_group_help_startup[test-datasets] 166.4 ms 124 ms +34.21%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing claude/stoic-volta-31tgce-ci-groups (f5883f7) with dev (41500d7)1

Open in CodSpeed

Footnotes

  1. No successful run was found on dev (cd7c955) during the generation of this report, so 41500d7 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@ewels
ewels marked this pull request as ready for review November 23, 2026 09:31

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants