From cfb0fd9993feb6f95197c26ca0fdcc5d459774fd Mon Sep 17 00:00:00 2001 From: mashehu Date: Wed, 22 Jul 2026 13:40:02 +0200 Subject: [PATCH 1/4] test nf-test latest-everything comment --- .github/workflows/nf-test.yml | 59 ++++++++++++++++++++++++++- .github/workflows/pr-comment.yml | 69 ++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/pr-comment.yml diff --git a/.github/workflows/nf-test.yml b/.github/workflows/nf-test.yml index efd72d6..86eda0c 100644 --- a/.github/workflows/nf-test.yml +++ b/.github/workflows/nf-test.yml @@ -40,7 +40,7 @@ jobs: rm -rf ./* || true rm -rf ./.??* || true ls -la ./ - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: fetch-depth: 0 @@ -85,7 +85,7 @@ jobs: TOTAL_SHARDS: ${{ needs.nf-test-changes.outputs.total_shards }} steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: fetch-depth: 0 @@ -116,6 +116,22 @@ jobs: fi fi + # continue-on-error keeps latest-everything from failing the job, so it never shows up in + # `needs.nf-test.result` downstream and CI stays green. Surface it via a PR comment instead; + # other NXF_VER failures already fail the job/CI directly, so no comment is needed for those. + - name: Prepare PR comment fragment + if: ${{ always() && steps.run_nf_test.outcome == 'failure' && matrix.NXF_VER == 'latest-everything' }} + run: | + mkdir -p pr-comment-fragment + echo "* ❌ \`${{ matrix.profile }}\` | \`${{ matrix.NXF_VER }}\` | Shard ${{ matrix.shard }}/${{ env.TOTAL_SHARDS }}" > pr-comment-fragment/fragment.md + + - name: Upload PR comment fragment + if: ${{ always() && steps.run_nf_test.outcome == 'failure' && matrix.NXF_VER == 'latest-everything' }} + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: pr-comment-fragment-${{ strategy.job-index }} + path: pr-comment-fragment/ + confirm-pass: needs: [nf-test] if: always() @@ -142,3 +158,42 @@ jobs: echo "DEBUG: toJSON(needs) = ${{ toJSON(needs) }}" echo "DEBUG: toJSON(needs.*.result) = ${{ toJSON(needs.*.result) }}" echo "::endgroup::" + + - name: Download PR comment fragments + if: ${{ always() }} + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + continue-on-error: true + with: + pattern: pr-comment-fragment-* + path: pr-comment-fragments + merge-multiple: true + + # Build a comment for the shared pr-comment.yml poster to publish on the PR. + # Based on the fragments above (not needs.*.result) so non-blocking failures are still reported. + - name: Prepare PR comment + if: ${{ always() }} + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + mkdir -p pr-comment + echo "$PR_NUMBER" > pr-comment/pr_number.txt + echo "nf-test" > pr-comment/header.txt + if [ -d pr-comment-fragments ] && [ -n "$(ls -A pr-comment-fragments)" ]; then + { + echo "## ❌ nf-test failed" + echo "" + echo "> [!NOTE]:" + echo "> Test with latest-everything failed but will not cause workflow failure. Please check if the error is expected with newer (edge-)releases of Nextflow or if it needs fixing." + cat pr-comment-fragments/*.md + echo "" + echo "See the [full run](${RUN_URL}) for details." + } > pr-comment/comment.md + fi + + - name: Upload PR comment artifact + if: ${{ always() }} + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: pr-comment + path: pr-comment/ diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml new file mode 100644 index 0000000..f7448d5 --- /dev/null +++ b/.github/workflows/pr-comment.yml @@ -0,0 +1,69 @@ +name: Post PR comment +# Shared, privileged comment poster. +# +# This is the single workflow that runs with a write token. It is triggered +# after any of the listed "producer" workflows complete on a pull request. +# Each producer runs untrusted PR code (if any) with a read-only token and +# uploads a `pr-comment` artifact describing the comment to post; this workflow +# only ever reads that plain-text artifact, so no PR code is executed here. +# +# Artifact contract (uploaded by producers under the name `pr-comment`): +# pr_number.txt - the pull request number +# header.txt - sticky-comment identifier (keeps comment types separate) +# comment.md - the Markdown body (omit the file to post nothing) + +on: + workflow_run: + workflows: + - "nf-core linting" + - "nf-core template version comment" + - "nf-core branch protection" + - "Run nf-test" + +permissions: + actions: read + contents: read + pull-requests: write + +jobs: + post-comment: + runs-on: ubuntu-latest + # Only act on runs that were triggered by a pull request. + if: github.event.workflow_run.event == 'pull_request' + steps: + - name: Download PR comment artifact + uses: dawidd6/action-download-artifact@b6e2e70617bc3265edd6dab6c906732b2f1ae151 # v21 + with: + run_id: ${{ github.event.workflow_run.id }} + name: pr-comment + if_no_artifact_found: ignore + + - name: Read comment metadata + id: meta + run: | + # No comment body means there is nothing to post. + [ -f pr-comment/comment.md ] || exit 0 + + pr_number=$(cat pr-comment/pr_number.txt) + header=$(cat pr-comment/header.txt) + + # Guard against anything unexpected ending up in the PR number. + case "$pr_number" in + ''|*[!0-9]*) + echo "Invalid PR number: '$pr_number'" + exit 1 + ;; + esac + + echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT" + echo "header=$header" >> "$GITHUB_OUTPUT" + echo "post=true" >> "$GITHUB_OUTPUT" + + - name: Post PR comment + if: steps.meta.outputs.post == 'true' + uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + number: ${{ steps.meta.outputs.pr_number }} + header: ${{ steps.meta.outputs.header }} + path: pr-comment/comment.md From 434f909524a802d23acc54baed3c59fda0fa65fe Mon Sep 17 00:00:00 2001 From: mashehu Date: Wed, 22 Jul 2026 13:46:38 +0200 Subject: [PATCH 2/4] test failing test --- main.nf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.nf b/main.nf index 548e85d..68101dd 100644 --- a/main.nf +++ b/main.nf @@ -66,6 +66,11 @@ workflow NFCORE_TESTPIPELINE { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +// fail if nextflow version is 26.07.0 +if (nextflow.version == '26.07.0') { + exit 1 +} + workflow { main: From 3888979935f6782c15d5b52a0ac9dcab34714be1 Mon Sep 17 00:00:00 2001 From: mashehu Date: Wed, 22 Jul 2026 16:16:30 +0200 Subject: [PATCH 3/4] fix action --- .github/workflows/pr-comment.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index f7448d5..4fe24f8 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -36,6 +36,10 @@ jobs: with: run_id: ${{ github.event.workflow_run.id }} name: pr-comment + # Extract into a pr-comment/ subdirectory; with a single named + # artifact this action otherwise unpacks the files into the workspace + # root, and the steps below look for them under pr-comment/. + path: pr-comment if_no_artifact_found: ignore - name: Read comment metadata From 023a6ceaa68dacba4546f67d082e807d65d8b700 Mon Sep 17 00:00:00 2001 From: mashehu Date: Thu, 23 Jul 2026 10:25:35 +0200 Subject: [PATCH 4/4] fix wording --- .github/workflows/nf-test.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nf-test.yml b/.github/workflows/nf-test.yml index 86eda0c..ec2989d 100644 --- a/.github/workflows/nf-test.yml +++ b/.github/workflows/nf-test.yml @@ -26,7 +26,7 @@ env: jobs: nf-test-changes: - name: nf-test-changes + name: nf-test-changes! runs-on: # use self-hosted runners - runs-on=${{ github.run_id }}-nf-test-changes - runner=4cpu-linux-x64 @@ -181,10 +181,12 @@ jobs: echo "nf-test" > pr-comment/header.txt if [ -d pr-comment-fragments ] && [ -n "$(ls -A pr-comment-fragments)" ]; then { - echo "## ❌ nf-test failed" + echo "## ❌ nf-test failed with latest Nextflow version" + echo "" + echo "> [!NOTE]" + echo "> Tests with Nextflow's latest version failed but it will not cause a CI workflow failure." + echo "> Please check if the failure is expected with newer (edge-)releases of Nextflow or if it needs fixing." echo "" - echo "> [!NOTE]:" - echo "> Test with latest-everything failed but will not cause workflow failure. Please check if the error is expected with newer (edge-)releases of Nextflow or if it needs fixing." cat pr-comment-fragments/*.md echo "" echo "See the [full run](${RUN_URL}) for details."