-
Notifications
You must be signed in to change notification settings - Fork 0
STRY0019104 - Test against GSP version of Nextflow in GitHub CI for all pipelines #26
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
Changes from all commits
474a575
bfe60d2
37da693
6dcbb1b
8b5851d
71fcfff
7e9a623
05901ef
eb11c48
8db68ee
2537e6b
15d0864
9871e0a
4e01c34
b264bf2
dad1046
500bd92
8c39c16
75fec4e
d3021ca
e1fe690
a0a303a
38d5b41
928bd6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| name: "Get number of shards" | ||
| description: "Get the number of nf-test shards for the current CI job" | ||
| inputs: | ||
| max_shards: | ||
| description: "Maximum number of shards allowed" | ||
| required: true | ||
| paths: | ||
| description: "Component paths to test" | ||
| required: false | ||
| tags: | ||
| description: "Tags to pass as argument for nf-test --tag parameter" | ||
| required: false | ||
| outputs: | ||
| shard: | ||
| description: "Array of shard numbers" | ||
| value: ${{ steps.shards.outputs.shard }} | ||
| total_shards: | ||
| description: "Total number of shards" | ||
| value: ${{ steps.shards.outputs.total_shards }} | ||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Install nf-test | ||
| uses: nf-core/setup-nf-test@v1 | ||
| with: | ||
| version: ${{ env.NFT_VER }} | ||
| - name: Get number of shards | ||
| id: shards | ||
| shell: bash | ||
| run: | | ||
| # Run nf-test with dynamic parameter | ||
| nftest_output=$(nf-test test \ | ||
| --profile +docker \ | ||
| $(if [ -n "${{ inputs.tags }}" ]; then echo "--tag ${{ inputs.tags }}"; fi) \ | ||
| --dry-run \ | ||
| --ci \ | ||
| --changed-since HEAD^) || { | ||
| echo "nf-test command failed with exit code $?" | ||
| echo "Full output: $nftest_output" | ||
| exit 1 | ||
| } | ||
| echo "nf-test dry-run output: $nftest_output" | ||
| # Default values for shard and total_shards | ||
| shard="[]" | ||
| total_shards=0 | ||
| # Check if there are related tests | ||
| if echo "$nftest_output" | grep -q 'No tests to execute'; then | ||
| echo "No related tests found." | ||
| else | ||
| # Extract the number of related tests | ||
| number_of_shards=$(echo "$nftest_output" | sed -n 's|.*Executed \([0-9]*\) tests.*|\1|p') | ||
| if [[ -n "$number_of_shards" && "$number_of_shards" -gt 0 ]]; then | ||
| shards_to_run=$(( $number_of_shards < ${{ inputs.max_shards }} ? $number_of_shards : ${{ inputs.max_shards }} )) | ||
| shard=$(seq 1 "$shards_to_run" | jq -R . | jq -c -s .) | ||
| total_shards="$shards_to_run" | ||
| else | ||
| echo "Unexpected output format. Falling back to default values." | ||
| fi | ||
| fi | ||
| # Write to GitHub Actions outputs | ||
| echo "shard=$shard" >> $GITHUB_OUTPUT | ||
| echo "total_shards=$total_shards" >> $GITHUB_OUTPUT | ||
| # Debugging output | ||
| echo "Final shard array: $shard" | ||
| echo "Total number of shards: $total_shards" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| name: "nf-test Action" | ||
| description: "Runs nf-test with common setup steps" | ||
| inputs: | ||
| profile: | ||
| description: "Profile to use" | ||
| required: true | ||
| shard: | ||
| description: "Shard number for this CI job" | ||
| required: true | ||
| total_shards: | ||
| description: "Total number of test shards(NOT the total number of matrix jobs)" | ||
| required: true | ||
| paths: | ||
| description: "Test paths" | ||
| required: true | ||
| tags: | ||
| description: "Tags to pass as argument for nf-test --tag parameter" | ||
| required: false | ||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Setup Nextflow | ||
| uses: nf-core/setup-nextflow@v2 | ||
| with: | ||
| version: "${{ env.NXF_VERSION }}" | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 | ||
| with: | ||
| python-version: "3.13" | ||
|
|
||
| - name: Install nf-test | ||
| uses: nf-core/setup-nf-test@v1 | ||
| with: | ||
| version: "${{ env.NFT_VER }}" | ||
| install-pdiff: true | ||
|
|
||
| - name: Setup apptainer | ||
| if: contains(inputs.profile, 'singularity') | ||
| uses: eWaterCycle/setup-apptainer@main | ||
|
|
||
| - name: Set up Singularity | ||
| if: contains(inputs.profile, 'singularity') | ||
| shell: bash | ||
| run: | | ||
| mkdir -p $NXF_SINGULARITY_CACHEDIR | ||
| mkdir -p $NXF_SINGULARITY_LIBRARYDIR | ||
|
|
||
| - name: Conda setup | ||
| if: contains(inputs.profile, 'conda') | ||
| uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3 | ||
| with: | ||
| auto-update-conda: true | ||
| conda-solver: libmamba | ||
| conda-remove-defaults: true | ||
|
|
||
| - name: Run nf-test | ||
| shell: bash | ||
| env: | ||
| NFT_WORKDIR: ${{ env.NFT_WORKDIR }} | ||
| run: | | ||
| nf-test test \ | ||
| --profile=+${{ inputs.profile }} \ | ||
| $(if [ -n "${{ inputs.tags }}" ]; then echo "--tag ${{ inputs.tags }}"; fi) \ | ||
| --ci \ | ||
| --changed-since HEAD^ \ | ||
| --verbose \ | ||
| --tap=test.tap \ | ||
| --shard ${{ inputs.shard }}/${{ inputs.total_shards }} | ||
|
|
||
| # Save the absolute path of the test.tap file to the output | ||
| echo "tap_file_path=$(realpath test.tap)" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Generate test summary | ||
| if: always() | ||
| shell: bash | ||
| run: | | ||
| # Add header if it doesn't exist (using a token file to track this) | ||
| if [ ! -f ".summary_header" ]; then | ||
| echo "# 🚀 nf-test results" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Status | Test Name | Profile | Shard |" >> $GITHUB_STEP_SUMMARY | ||
| echo "|:------:|-----------|---------|-------|" >> $GITHUB_STEP_SUMMARY | ||
| touch .summary_header | ||
| fi | ||
|
|
||
| if [ -f test.tap ]; then | ||
| while IFS= read -r line; do | ||
| if [[ $line =~ ^ok ]]; then | ||
| test_name="${line#ok }" | ||
| # Remove the test number from the beginning | ||
| test_name="${test_name#* }" | ||
| echo "| ✅ | ${test_name} | ${{ inputs.profile }} | ${{ inputs.shard }}/${{ inputs.total_shards }} |" >> $GITHUB_STEP_SUMMARY | ||
| elif [[ $line =~ ^not\ ok ]]; then | ||
| test_name="${line#not ok }" | ||
| # Remove the test number from the beginning | ||
| test_name="${test_name#* }" | ||
| echo "| ❌ | ${test_name} | ${{ inputs.profile }} | ${{ inputs.shard }}/${{ inputs.total_shards }} |" >> $GITHUB_STEP_SUMMARY | ||
| fi | ||
| done < test.tap | ||
| else | ||
| echo "| ⚠️ | No test results found | ${{ inputs.profile }} | ${{ inputs.shard }}/${{ inputs.total_shards }} |" >> $GITHUB_STEP_SUMMARY | ||
| fi | ||
|
|
||
| - name: Clean up | ||
| if: always() | ||
| shell: bash | ||
| run: | | ||
| sudo rm -rf /home/ubuntu/tests/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,17 @@ | ||
| name: nf-core branch protection | ||
| # This workflow is triggered on PRs to main branch on the repository | ||
| # It fails when someone tries to make a PR against the phac-nml `main` branch instead of `dev` | ||
| # This workflow is triggered on PRs to `main`/`master` branch on the repository | ||
| # It fails when someone tries to make a PR against the phac-nml `main`/`master` branch instead of `dev` | ||
|
Comment on lines
+2
to
+3
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we were moving away from
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's correct. The default checks from the nf-core templates should be for both |
||
| on: | ||
| pull_request_target: | ||
| branches: [main] | ||
| branches: | ||
| - main | ||
| - master | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| # PRs to the phac-nml repo main branch are only ok if coming from the phac-nml repo `dev` or any `patch` branches | ||
| # PRs to the phac-nml repo main/master branch are only ok if coming from the phac-nml repo `dev` or any `patch` branches | ||
| - name: Check PRs | ||
| if: github.repository == 'phac-nml/speciesabundance' | ||
| run: | | ||
|
|
@@ -22,7 +24,7 @@ jobs: | |
| uses: mshick/add-pr-comment@b8f338c590a895d50bcbfa6c5859251edc8952fc # v2 | ||
| with: | ||
| message: | | ||
| ## This PR is against the `main` branch :x: | ||
| ## This PR is against the `${{github.event.pull_request.base.ref}}` branch :x: | ||
|
|
||
| * Do not close this PR | ||
| * Click _Edit_ and change the `base` to `dev` | ||
|
|
@@ -32,9 +34,9 @@ jobs: | |
|
|
||
| Hi @${{ github.event.pull_request.user.login }}, | ||
|
|
||
| It looks like this pull-request is has been made against the [${{github.event.pull_request.head.repo.full_name }}](https://github.com/${{github.event.pull_request.head.repo.full_name }}) `main` branch. | ||
| The `main` branch on phac-nml repositories should always contain code from the latest release. | ||
| Because of this, PRs to `main` are only allowed if they come from the [${{github.event.pull_request.head.repo.full_name }}](https://github.com/${{github.event.pull_request.head.repo.full_name }}) `dev` branch. | ||
| It looks like this pull-request is has been made against the [${{github.event.pull_request.head.repo.full_name }}](https://github.com/${{github.event.pull_request.head.repo.full_name }}) ${{github.event.pull_request.base.ref}} branch. | ||
| The ${{github.event.pull_request.base.ref}} branch on phac-nml repositories should always contain code from the latest release. | ||
| Because of this, PRs to ${{github.event.pull_request.base.ref}} are only allowed if they come from the [${{github.event.pull_request.head.repo.full_name }}](https://github.com/${{github.event.pull_request.head.repo.full_name }}) `dev` branch. | ||
|
|
||
| You do not need to close this PR, you can change the target branch to `dev` by clicking the _"Edit"_ button at the top of this page. | ||
| Note that even after this, the test will continue to show as failing until you push a new commit. | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is cool didn't know about this, so it is only going to run tests impacted by changes?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Since
HEAD^is referencing the parent commit of theHEADcommit I wanted to know more about how this worked on GitHub (since a PR can have multiple commits, so why doesHEAD^capture all changes in the PR)?Based on what I've read, it looks like the GitHub actions checkout (https://github.com/marketplace/actions/checkout) will checkout code with a particular commit that is the squashed commit of all changes in your PR. Hence,
HEAD^will point to the commit prior to the PR, and so differences fromHEAD^(that is the--changed-since HEAD^parameter) will properly capture all code changes in this PR. Runningnf-test test ... --changed-since HEAD^locally on a branch won't work (since it only looks at differences one commit up).This is based on inspecting output of the GitHub actions and a copilot summary (I couldn't find good documentation on this outside of copilot):