Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace tags strategy with implicit 'tags in test' strategy #253

Merged
merged 22 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 102 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,101 @@ jobs:
name: Check for changes
runs-on: ubuntu-latest
outputs:
# Expose matched filters as job 'tags' output variable
tags: ${{ steps.filter.outputs.changes }}
changes: ${{ steps.changed_files.outputs.any_modified }}
tags: ${{ steps.list.outputs.tags }}
steps:
- name: Install Nextflow
uses: nf-core/setup-nextflow@v1

- name: Cache nf-test installation
id: cache-software
uses: actions/cache@v3
with:
path: |
/usr/local/bin/nf-test
/home/runner/.nf-test/nf-test.jar
key: ${{ runner.os }}-${{ env.NFT_VER }}-nftest

- name: Install nf-test
if: steps.cache-software.outputs.cache-hit != 'true'
run: |
wget -qO- https://code.askimed.com/install/nf-test | bash
sudo mv nf-test /usr/local/bin/

- uses: actions/checkout@v3
- name: Combine all tags.yml files
id: get_username
run: find . -name "tags.yml" -not -path "./.github/*" -exec cat {} + > .github/tags.yml
- name: debug
run: cat .github/tags.yml
- uses: dorny/paths-filter@v2
id: filter
with:
filters: ".github/tags.yml"
fetch-depth: 0

define_nxf_versions:
name: Choose nextflow versions to test against depending on target branch
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.nxf_versions.outputs.matrix }}
steps:
- id: nxf_versions
- uses: tj-actions/changed-files@v42
id: changed_files
with:
dir_names: "true"
output_renamed_files_as_deleted_and_added: "true"
# Define list of additional rules for testing paths
# Mostly, we define additional 'pipeline' or 'all' tests here
files_yaml: |
".":
- .github/workflows/**
- nf-test.config
- nextflow.config
tests:
- assets/*
- bin/*
- conf/*
- main.nf
- nextflow_schema.json
Comment on lines +62 to +72
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@maxulysse shall we put this in a separate file?

Copy link
Member

Choose a reason for hiding this comment

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

I'm sorry I don't understand what you meant by that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are supplementary existing tags. We can move this to a separate YAML, e.g. .github/test_paths.yml like we have tags now.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Further discussion - general consensus was it's all in one place if we leave it here. We can move it out later if we need to.


files_ignore: |
.git*
.gitpod.yml
.prettierignore
.prettierrc.yml
**.md
**.png
modules.json
pyproject.toml
tower.yml

- name: debug
run: |
if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.base_ref }}" == "dev" && "${{ matrix.NXF_VER }}" != "latest-everything" ]]; then
echo matrix='["latest-everything"]' | tee -a $GITHUB_OUTPUT
else
echo matrix='["latest-everything", "23.04.0"]' | tee -a $GITHUB_OUTPUT
fi
echo ${{ steps.changed_files.outputs.any_modified }}
echo ${{ steps.changed_files.outputs.all_changed_files }}
echo ${{ steps.changed_files.outputs.changed_keys }}

- name: nf-test list tags
id: list
if: ${{ steps.changed_files.outputs.any_modified }}
run: echo tags=$(nf-test list --silent --tags --format json ${{ steps.changed_files.outputs.all_changed_files }} ${{ steps.changed_files.outputs.changed_keys }}) >> $GITHUB_OUTPUT

- name: debug2
run: |
echo ${{ steps.list.outputs.tags }}

# define_nxf_versions:
# name: Choose nextflow versions to test against depending on target branch
# runs-on: ubuntu-latest
# outputs:
# matrix: ${{ steps.nxf_versions.outputs.matrix }}
# steps:
# - id: nxf_versions
# run: |
# if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.base_ref }}" == "dev" && "${{ matrix.NXF_VER }}" != "latest-everything" ]]; then
# echo matrix='["latest-everything"]' | tee -a $GITHUB_OUTPUT
# else
# echo matrix='["latest-everything", "23.04.0"]' | tee -a $GITHUB_OUTPUT
# fi

test:
name: ${{ matrix.tags }} ${{ matrix.profile }} NF ${{ matrix.NXF_VER }}
needs: [changes, define_nxf_versions]
if: needs.changes.outputs.tags != '[]'
name: ${{ matrix.tags }} ${{ matrix.profile }} NF-${{ matrix.NXF_VER }}
needs: [changes]
if: needs.changes.outputs.changes
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
NXF_VER: ${{ fromJson(needs.define_nxf_versions.outputs.matrix) }}
NXF_VER:
- "latest-everything"
- "23.04"
tags: ["${{ fromJson(needs.changes.outputs.tags) }}"]
profile:
- "docker"
Expand Down Expand Up @@ -122,3 +180,21 @@ jobs:
if: always() # always run even if the previous step fails
with:
report_paths: test.xml

confirm-pass:
runs-on: ubuntu-latest
needs: [test]
if: always()
steps:
- name: All tests ok
if: ${{ success() || !contains(needs.*.result, 'failure') }}
run: exit 0
- name: One or more tests failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1

- name: debug-print
if: always()
run: |
echo "toJSON(needs) = ${{ toJSON(needs) }}"
echo "toJSON(needs.*.result) = ${{ toJSON(needs.*.result) }}"
5 changes: 2 additions & 3 deletions modules/local/multiqc_mappings_config/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ nextflow_process {
name "Test process: MULTIQC_MAPPINGS_CONFIG"
script "../main.nf"
process "MULTIQC_MAPPINGS_CONFIG"
tag "modules"
tag "modules_local"
tag "multiqc_mappings_config"

tag "MULTIQC_MAPPINGS_CONFIG"
Copy link
Member

Choose a reason for hiding this comment

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

Not for this PR- but if tag is becoming redundant with the process maybe we should talk to the nf-test folks about allowing nf-test to list processes/ workflows rather than tags?

Copy link
Member

Choose a reason for hiding this comment

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

I think it's similar to what @adamrtalbot meant when creating this issue: askimed/nf-test#178

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, I've suggested it as a feature. This was the behaviour in pytest-workflow as well.

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha, sorry for the slow uptake


test("Should run without failures") {

Expand Down
2 changes: 0 additions & 2 deletions modules/local/multiqc_mappings_config/tests/tags.yml

This file was deleted.

5 changes: 2 additions & 3 deletions modules/local/sra_fastq_ftp/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ nextflow_process {
name "Test process: SRA_FASTQ_FTP"
script "../main.nf"
process "SRA_FASTQ_FTP"
tag "modules"
tag "modules_local"
tag "sra_fastq_ftp"

tag "SRA_FASTQ_FTP"

test("Should run without failures") {

Expand Down
2 changes: 0 additions & 2 deletions modules/local/sra_fastq_ftp/tests/tags.yml

This file was deleted.

5 changes: 2 additions & 3 deletions modules/local/sra_ids_to_runinfo/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ nextflow_process {
name "Test process: SRA_IDS_TO_RUNINFO"
script "../main.nf"
process "SRA_IDS_TO_RUNINFO"
tag "modules"
tag "modules_local"
tag "sra_ids_to_runinfo"

tag "SRA_IDS_TO_RUNINFO"

test("Should run without failures") {

Expand Down
2 changes: 0 additions & 2 deletions modules/local/sra_ids_to_runinfo/tests/tags.yml

This file was deleted.

5 changes: 2 additions & 3 deletions modules/local/sra_runinfo_to_ftp/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ nextflow_process {
name "Test process: SRA_RUNINFO_TO_FTP"
script "../main.nf"
process "SRA_RUNINFO_TO_FTP"
tag "modules"
tag "modules_local"
tag "sra_runinfo_to_ftp"

tag "SRA_RUNINFO_TO_FTP"

test("Should run without failures") {

Expand Down
2 changes: 0 additions & 2 deletions modules/local/sra_runinfo_to_ftp/tests/tags.yml

This file was deleted.

5 changes: 2 additions & 3 deletions modules/local/sra_to_samplesheet/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ nextflow_process {
name "Test process: SRA_TO_SAMPLESHEET"
script "../main.nf"
process "SRA_TO_SAMPLESHEET"
tag "modules"
tag "modules_local"
tag "sra_to_samplesheet"

tag "SRA_TO_SAMPLESHEET"

test("Should run without failures") {

Expand Down
2 changes: 0 additions & 2 deletions modules/local/sra_to_samplesheet/tests/tags.yml

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions modules/nf-core/custom/sratoolsncbisettings/tests/tags.yml

This file was deleted.

8 changes: 3 additions & 5 deletions modules/nf-core/sratools/fasterqdump/tests/main.nf.test

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions modules/nf-core/sratools/fasterqdump/tests/tags.yml

This file was deleted.

5 changes: 1 addition & 4 deletions modules/nf-core/sratools/prefetch/tests/main.nf.test

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions modules/nf-core/sratools/prefetch/tests/tags.yml

This file was deleted.

5 changes: 1 addition & 4 deletions modules/nf-core/untar/tests/main.nf.test

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions modules/nf-core/untar/tests/tags.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ nextflow_function {

name "Test Functions"
script "subworkflows/local/utils_nfcore_fetchngs_pipeline/main.nf"
tag 'subworkflows'
tag 'utils_nfcore_fetchngs_pipeline'
tag 'subworkflows/utils_nfcore_fetchngs_pipeline'
tag "UTILS_NFCORE_FETCHNGS_PIPELINE"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@maxulysse is this the right tag? Too late on a Friday to confirm. Please check on Monday 😆

Copy link
Member

Choose a reason for hiding this comment

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

yes


test("Function isSraId") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ nextflow_workflow {
name "Test Workflow PIPELINE_COMPLETION"
script "subworkflows/local/utils_nfcore_fetchngs_pipeline/main.nf"
workflow "PIPELINE_COMPLETION"
tag 'subworkflows'
tag 'utils_nfcore_fetchngs_pipeline'
tag 'subworkflows/utils_nfcore_fetchngs_pipeline'
tag "PIPELINE_COMPLETION"

test("Should run") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ nextflow_workflow {
name "Test Workflow PIPELINE_INITIALISATION"
script "subworkflows/local/utils_nfcore_fetchngs_pipeline/main.nf"
workflow "PIPELINE_INITIALISATION"
tag 'subworkflows'
tag 'utils_nfcore_fetchngs_pipeline'
tag 'subworkflows/utils_nfcore_fetchngs_pipeline'
tag 'PIPELINE_INITIALISATION'

test("Should run") {

Expand Down

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions subworkflows/nf-core/utils_nextflow_pipeline/tests/tags.yml

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading