Skip to content

Conversation

@adamrtalbot
Copy link
Contributor

@adamrtalbot adamrtalbot commented May 21, 2024

This PR adds nf-test to the pipeline template, based on the work in nf-core/fetchngs and nf-core/rnaseq. Adds a simple default test and replaces the nextflow run command with nf-test test for more advanced testing. The default test just checks for a successful exit status, which should keep it lightweight and similar to existing tests.

see nf-core/website#2536 for related documentation to PR.

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!
  • Documentation in docs is updated

@adamrtalbot adamrtalbot marked this pull request as draft May 21, 2024 19:11
Copy link
Contributor

@mashehu mashehu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the tooling (especially linting) in place before we can merge this into the template. Would also be nice if it would not break the CI for pipelines with nf-test, because this feels like a quite bullish push.

Co-authored-by: Matthias Hörtenhuber <[email protected]>
params {
// Base directory for nf-core/modules test data
modules_testdata_base_path = 's3://ngi-igenomes/testdata/nf-core/modules/'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pipelines_testdata_base_path = 's3://ngi-igenomes/testdata/nf-core/PIPELNE/'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be done on line 11

Copy link
Member

@maxulysse maxulysse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GOOD FOR ME as long as you deal with the pipelines_testdata_base_path params

@adamrtalbot
Copy link
Contributor Author

Would also be nice if it would not break the CI for pipelines with nf-test

This shouldn't break any pipelines with existing nf-tests, in fact it should complement them pretty well. There may be merge conflicts but all of the existing nf-tested pipelines should be mostly compatible. I've checked fetchngs, rnaseq, sarek, methylseq and phageannotator which are as far as I'm aware the main nf-tested pipelines.


name "Test pipeline with default settings"
script "../main.nf"
tag {{ name }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mashehu what is wrong with this jinja templating? From my understanding this should be a tag of the pipeline name but it is being interpreted as a closure.

@adamrtalbot
Copy link
Contributor Author

We need the tooling (especially linting)

@mashehu what should we lint for here? We need to check that outdir = "$outputDir", but outside of that everything is reasonably flexible. Perhaps we could make sure profile "test" is default but I'm not sure that's always going to be true (i.e. weird pipelines). Tags are no longer required, naming can't be that strict. Should we just check for existence of files?

@mashehu
Copy link
Contributor

mashehu commented May 22, 2024

Would also be nice if it would not break the CI for pipelines with nf-test

This shouldn't break any pipelines with existing nf-tests, in fact it should complement them pretty well. There may be merge conflicts but all of the existing nf-tested pipelines should be mostly compatible. I've checked fetchngs, rnaseq, sarek, methylseq and phageannotator which are as far as I'm aware the main nf-tested pipelines.

Sorry, I meant CI for pipelines without nf-test. Or do you think we can push easily every pipeline to switch to nf-test?

@mashehu
Copy link
Contributor

mashehu commented May 22, 2024

We need the tooling (especially linting)

@mashehu what should we lint for here? We need to check that outdir = "$outputDir", but outside of that everything is reasonably flexible. Perhaps we could make sure profile "test" is default but I'm not sure that's always going to be true (i.e. weird pipelines). Tags are no longer required, naming can't be that strict. Should we just check for existence of files?

Yes, at least file existence and a minimum set of assertions. See linting for components.


name "Test pipeline with default settings"
script "../main.nf"
// tag {{ name }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this failing? I tested it, and it seems to work, it's replaced by the pipeline name

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update: I think it has to go between quotes tag "{{ name }}"


then {
assertAll(
{ assert workflow.success }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add "TODO nf-core" comments and link to documentation on how to assert different files, are more tests with other profiles, etc.

@mirpedrol mirpedrol mentioned this pull request May 22, 2024
12 tasks
@adamrtalbot
Copy link
Contributor Author

Or do you think we can push easily every pipeline to switch to nf-test?

I personally would prefer to push people to nf-test rather than nextflow run, because we can actually test the outputs. Replacing nextflow run with nf-test shouldn't be too hard, especially if we only test for pipeline success by default.

@adamrtalbot
Copy link
Contributor Author

adamrtalbot commented May 22, 2024

Yes, at least file existence and a minimum set of assertions. See linting for components.

@mashehu added quick linting check, will flesh it out later: 15ccd18

@adamrtalbot adamrtalbot marked this pull request as ready for review June 21, 2024 15:55
@codecov
Copy link

codecov bot commented Jun 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.11%. Comparing base (edc9b41) to head (a483dca).

Current head a483dca differs from pull request most recent head 2738965

Please upload reports for the commit 2738965 to get more accurate results.

Additional details and impacted files

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

@adamrtalbot
Copy link
Contributor Author

fatal: unable to access 'https://gitlab.com/nf-core/modules-test.git/': Failed to connect to gitlab.com port 443 after 129691 ms: Connection timed out

Annoying.

@adamrtalbot adamrtalbot changed the base branch from dev to pipeline-nf-test July 15, 2024 13:25
Copy link
Member

@mirpedrol mirpedrol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! sorry for the late review :)

@adamrtalbot adamrtalbot merged commit 55d07ae into nf-core:pipeline-nf-test Aug 2, 2024
@adamrtalbot adamrtalbot deleted the add_pipeline_nf-tests_to_template branch August 2, 2024 08:56
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.

5 participants