Skip to content

Commit 90f83a9

Browse files
authored
Merge pull request #42 from nf-core/olgabot/add-nf-test-config-v2
Add nf-test configuration and gitignore
2 parents e4c57d3 + a3e8064 commit 90f83a9

20 files changed

Lines changed: 561 additions & 127 deletions

File tree

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ Learn more about contributing: [CONTRIBUTING.md](https://github.com/nf-core/prot
1818
- [ ] If you've added a new tool - have you followed the pipeline conventions in the [contribution docs](https://github.com/nf-core/proteinannotator/tree/master/.github/CONTRIBUTING.md)
1919
- [ ] If necessary, also make a PR on the nf-core/proteinannotator _branch_ on the [nf-core/test-datasets](https://github.com/nf-core/test-datasets) repository.
2020
- [ ] Make sure your code lints (`nf-core pipelines lint`).
21-
- [ ] Ensure the test suite passes (`nextflow run . -profile test,docker --outdir <OUTDIR>`).
22-
- [ ] Check for unexpected warnings in debug mode (`nextflow run . -profile debug,test,docker --outdir <OUTDIR>`).
21+
- [ ] Ensure the test suite passes (e.g. `nf-test test */local --profile=~test,docker` for all new local tests).
22+
- [ ] Check for unexpected warnings in debug mode (`nf-test test */local --profile=~test,docker,debug`).
2323
- [ ] Usage Documentation in `docs/usage.md` is updated.
2424
- [ ] Output Documentation in `docs/output.md` is updated.
2525
- [ ] `CHANGELOG.md` is updated.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: "Get number of shards"
2+
description: "Get the number of nf-test shards for the current CI job"
3+
inputs:
4+
max_shards:
5+
description: "Maximum number of shards allowed"
6+
required: true
7+
paths:
8+
description: "Component paths to test"
9+
required: false
10+
outputs:
11+
shard:
12+
description: "Array of shard numbers"
13+
value: ${{ steps.shards.outputs.shard }}
14+
total_shards:
15+
description: "Total number of shards"
16+
value: ${{ steps.shards.outputs.total_shards }}
17+
runs:
18+
using: "composite"
19+
steps:
20+
- name: Install nf-test
21+
uses: nf-core/setup-nf-test@v1
22+
with:
23+
version: ${{ env.NFT_VER }}
24+
- name: Get number of shards
25+
id: shards
26+
shell: bash
27+
run: |
28+
# Run nf-test with dynamic parameter
29+
nftest_output=$(nf-test test \
30+
--dry-run \
31+
--profile +docker \
32+
--filter function,workflow,pipeline \
33+
--ci \
34+
--changed-since HEAD^) || {
35+
echo "nf-test command failed with exit code $?"
36+
echo "Full output: $nftest_output"
37+
exit 1
38+
}
39+
echo "nf-test dry-run output: $nftest_output"
40+
41+
# Default values for shard and total_shards
42+
shard="[]"
43+
total_shards=0
44+
45+
# Check if there are related tests
46+
if echo "$nftest_output" | grep -q 'No tests to execute'; then
47+
echo "No related tests found."
48+
else
49+
# Extract the number of related tests
50+
number_of_shards=$(echo "$nftest_output" | sed -n 's|.*Executed \([0-9]*\) tests.*|\1|p')
51+
if [[ -n "$number_of_shards" && "$number_of_shards" -gt 0 ]]; then
52+
shards_to_run=$(( $number_of_shards < ${{ inputs.max_shards }} ? $number_of_shards : ${{ inputs.max_shards }} ))
53+
shard=$(seq 1 "$shards_to_run" | jq -R . | jq -c -s .)
54+
total_shards="$shards_to_run"
55+
else
56+
echo "Unexpected output format. Falling back to default values."
57+
fi
58+
fi
59+
60+
# Write to GitHub Actions outputs
61+
echo "shard=$shard" >> $GITHUB_OUTPUT
62+
echo "total_shards=$total_shards" >> $GITHUB_OUTPUT
63+
64+
# Debugging output
65+
echo "Final shard array: $shard"
66+
echo "Total number of shards: $total_shards"

.github/actions/nf-test/action.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: "nf-test Action"
2+
description: "Runs nf-test with common setup steps"
3+
inputs:
4+
profile:
5+
description: "Profile to use"
6+
required: true
7+
shard:
8+
description: "Shard number for this CI job"
9+
required: true
10+
total_shards:
11+
description: "Total number of test shards(NOT the total number of matrix jobs)"
12+
required: true
13+
paths:
14+
description: "Test paths"
15+
required: true
16+
17+
runs:
18+
using: "composite"
19+
steps:
20+
- name: Setup Nextflow
21+
uses: nf-core/setup-nextflow@v2
22+
with:
23+
version: "${{ env.NXF_VERSION }}"
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5
27+
with:
28+
python-version: "3.11"
29+
30+
- name: Install nf-test
31+
uses: nf-core/setup-nf-test@v1
32+
with:
33+
version: "${{ env.NFT_VER }}"
34+
35+
- name: Setup apptainer
36+
if: contains(inputs.profile, 'singularity')
37+
uses: eWaterCycle/setup-apptainer@main
38+
39+
- name: Set up Singularity
40+
if: contains(inputs.profile, 'singularity')
41+
shell: bash
42+
run: |
43+
mkdir -p $NXF_SINGULARITY_CACHEDIR
44+
mkdir -p $NXF_SINGULARITY_LIBRARYDIR
45+
46+
- name: Conda setup
47+
if: ${{inputs.profile == 'conda'}}
48+
uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3
49+
with:
50+
auto-update-conda: true
51+
conda-solver: libmamba
52+
conda-remove-defaults: true
53+
54+
- name: Install pdiff
55+
shell: bash
56+
run: |
57+
python -m pip install pdiff
58+
59+
- name: Clean up Disk space
60+
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
61+
62+
# TODO Skip failing conda tests and document their failures
63+
# https://github.com/nf-core/modules/issues/7017
64+
- name: Run nf-test
65+
shell: bash
66+
env:
67+
NFT_DIFF: ${{ env.NFT_DIFF }}
68+
NFT_DIFF_ARGS: ${{ env.NFT_DIFF_ARGS }}
69+
NFT_WORKDIR: ${{ env.NFT_WORKDIR }}
70+
run: |
71+
nf-test test \
72+
--profile=+${{ inputs.profile }} \
73+
--tap=test.tap \
74+
--verbose \
75+
--ci \
76+
--changed-since HEAD^ \
77+
--shard ${{ inputs.shard }}/${{ inputs.total_shards }} \
78+
--filter function,workflow,pipeline
79+
80+
# Save the absolute path of the test.tap file to the output
81+
echo "tap_file_path=$(realpath test.tap)" >> $GITHUB_OUTPUT
82+
83+
- name: Generate test summary
84+
if: always()
85+
shell: bash
86+
run: |
87+
# Add header if it doesn't exist (using a token file to track this)
88+
if [ ! -f ".summary_header" ]; then
89+
echo "# 🚀 nf-test results" >> $GITHUB_STEP_SUMMARY
90+
echo "" >> $GITHUB_STEP_SUMMARY
91+
echo "| Status | Test Name | Profile | Shard |" >> $GITHUB_STEP_SUMMARY
92+
echo "|:------:|-----------|---------|-------|" >> $GITHUB_STEP_SUMMARY
93+
touch .summary_header
94+
fi
95+
96+
if [ -f test.tap ]; then
97+
while IFS= read -r line; do
98+
if [[ $line =~ ^ok ]]; then
99+
test_name="${line#ok }"
100+
# Remove the test number from the beginning
101+
test_name="${test_name#* }"
102+
echo "| ✅ | ${test_name} | ${{ inputs.profile }} | ${{ inputs.shard }}/${{ inputs.total_shards }} |" >> $GITHUB_STEP_SUMMARY
103+
elif [[ $line =~ ^not\ ok ]]; then
104+
test_name="${line#not ok }"
105+
# Remove the test number from the beginning
106+
test_name="${test_name#* }"
107+
echo "| ❌ | ${test_name} | ${{ inputs.profile }} | ${{ inputs.shard }}/${{ inputs.total_shards }} |" >> $GITHUB_STEP_SUMMARY
108+
fi
109+
done < test.tap
110+
else
111+
echo "| ⚠️ | No test results found | ${{ inputs.profile }} | ${{ inputs.shard }}/${{ inputs.total_shards }} |" >> $GITHUB_STEP_SUMMARY
112+
fi
113+
114+
- name: Clean up
115+
if: always()
116+
shell: bash
117+
run: |
118+
sudo rm -rf /home/ubuntu/tests/

.github/workflows/awsfulltest.yml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,57 @@ name: nf-core AWS full size tests
44
# It runs the -profile 'test_full' on AWS batch
55

66
on:
7+
pull_request:
8+
branches:
9+
- main
10+
- master
711
workflow_dispatch:
812
pull_request_review:
913
types: [submitted]
10-
release:
11-
types: [published]
1214

1315
jobs:
1416
run-platform:
1517
name: Run AWS full tests
16-
# run only if the PR is approved by at least 2 reviewers and against the master/main branch or manually triggered
17-
if: github.repository == 'nf-core/proteinannotator' && github.event.review.state == 'approved' && (github.event.pull_request.base.ref == 'master' || github.event.pull_request.base.ref == 'main') || github.event_name == 'workflow_dispatch'
18+
# run only if the PR is approved by at least 2 reviewers and against the master branch or manually triggered
19+
if: github.repository == 'nf-core/rnavar' && github.event.review.state == 'approved' && github.event.pull_request.base.ref == 'master' || github.event_name == 'workflow_dispatch'
1820
runs-on: ubuntu-latest
1921
steps:
20-
- name: Set revision variable
21-
id: revision
22+
- name: Get PR reviews
23+
uses: octokit/request-action@v2.x
24+
if: github.event_name != 'workflow_dispatch'
25+
id: check_approvals
26+
continue-on-error: true
27+
with:
28+
route: GET /repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews?per_page=100
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Check for approvals
33+
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
34+
run: |
35+
echo "No review approvals found. At least 2 approvals are required to run this action automatically."
36+
exit 1
37+
38+
- name: Check for enough approvals (>=2)
39+
id: test_variables
40+
if: github.event_name != 'workflow_dispatch'
2241
run: |
23-
echo "revision=${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'release') && github.sha || 'dev' }}" >> "$GITHUB_OUTPUT"
42+
JSON_RESPONSE='${{ steps.check_approvals.outputs.data }}'
43+
CURRENT_APPROVALS_COUNT=$(echo $JSON_RESPONSE | jq -c '[.[] | select(.state | contains("APPROVED")) ] | length')
44+
test $CURRENT_APPROVALS_COUNT -ge 2 || exit 1 # At least 2 approvals are required
2445
2546
- name: Launch workflow via Seqera Platform
2647
uses: seqeralabs/action-tower-launch@v2
27-
# TODO nf-core: You can customise AWS full pipeline tests as required
28-
# Add full size test data (but still relatively small datasets for few samples)
29-
# on the `test_full.config` test runs with only one set of parameters
3048
with:
3149
workspace_id: ${{ secrets.TOWER_WORKSPACE_ID }}
3250
access_token: ${{ secrets.TOWER_ACCESS_TOKEN }}
3351
compute_env: ${{ secrets.TOWER_COMPUTE_ENV }}
34-
revision: ${{ steps.revision.outputs.revision }}
35-
workdir: s3://${{ secrets.AWS_S3_BUCKET }}/work/proteinannotator/work-${{ steps.revision.outputs.revision }}
52+
revision: ${{ github.sha }}
53+
workdir: s3://${{ secrets.AWS_S3_BUCKET }}/work/rnavar/work-${{ github.sha }}
3654
parameters: |
3755
{
3856
"hook_url": "${{ secrets.MEGATESTS_ALERTS_SLACK_HOOK_URL }}",
39-
"outdir": "s3://${{ secrets.AWS_S3_BUCKET }}/proteinannotator/results-${{ steps.revision.outputs.revision }}"
57+
"outdir": "s3://${{ secrets.AWS_S3_BUCKET }}/rnavar/results-${{ github.sha }}"
4058
}
4159
profiles: test_full
4260

.github/workflows/ci.yml

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)