|
| 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 | + tags: |
| 17 | + description: "Tags to pass as argument for nf-test --tag parameter" |
| 18 | + required: false |
| 19 | +runs: |
| 20 | + using: "composite" |
| 21 | + steps: |
| 22 | + - name: Setup Nextflow |
| 23 | + uses: nf-core/setup-nextflow@v2 |
| 24 | + with: |
| 25 | + version: "${{ env.NXF_VERSION }}" |
| 26 | + |
| 27 | + - name: Set up Python |
| 28 | + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 |
| 29 | + with: |
| 30 | + python-version: "3.13" |
| 31 | + |
| 32 | + - name: Install nf-test |
| 33 | + uses: nf-core/setup-nf-test@v1 |
| 34 | + with: |
| 35 | + version: "${{ env.NFT_VER }}" |
| 36 | + install-pdiff: true |
| 37 | + |
| 38 | + - name: Setup apptainer |
| 39 | + if: contains(inputs.profile, 'singularity') |
| 40 | + uses: eWaterCycle/setup-apptainer@main |
| 41 | + |
| 42 | + - name: Set up Singularity |
| 43 | + if: contains(inputs.profile, 'singularity') |
| 44 | + shell: bash |
| 45 | + run: | |
| 46 | + mkdir -p $NXF_SINGULARITY_CACHEDIR |
| 47 | + mkdir -p $NXF_SINGULARITY_LIBRARYDIR |
| 48 | +
|
| 49 | + - name: Conda setup |
| 50 | + if: contains(inputs.profile, 'conda') |
| 51 | + uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3 |
| 52 | + with: |
| 53 | + auto-update-conda: true |
| 54 | + conda-solver: libmamba |
| 55 | + conda-remove-defaults: true |
| 56 | + |
| 57 | + # TODO Skip failing conda tests and document their failures |
| 58 | + # https://github.com/nf-core/modules/issues/7017 |
| 59 | + - name: Run nf-test |
| 60 | + shell: bash |
| 61 | + env: |
| 62 | + NFT_DIFF: ${{ env.NFT_DIFF }} |
| 63 | + NFT_DIFF_ARGS: ${{ env.NFT_DIFF_ARGS }} |
| 64 | + NFT_WORKDIR: ${{ env.NFT_WORKDIR }} |
| 65 | + run: | |
| 66 | + nf-test test \ |
| 67 | + --profile=+${{ inputs.profile }} \ |
| 68 | + $(if [ -n "${{ inputs.tags }}" ]; then echo "--tag ${{ inputs.tags }}"; fi) \ |
| 69 | + --ci \ |
| 70 | + --changed-since HEAD^ \ |
| 71 | + --verbose \ |
| 72 | + --tap=test.tap \ |
| 73 | + --shard ${{ inputs.shard }}/${{ inputs.total_shards }} |
| 74 | +
|
| 75 | + # Save the absolute path of the test.tap file to the output |
| 76 | + echo "tap_file_path=$(realpath test.tap)" >> $GITHUB_OUTPUT |
| 77 | +
|
| 78 | + - name: Generate test summary |
| 79 | + if: always() |
| 80 | + shell: bash |
| 81 | + run: | |
| 82 | + # Add header if it doesn't exist (using a token file to track this) |
| 83 | + if [ ! -f ".summary_header" ]; then |
| 84 | + echo "# 🚀 nf-test results" >> $GITHUB_STEP_SUMMARY |
| 85 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 86 | + echo "| Status | Test Name | Profile | Shard |" >> $GITHUB_STEP_SUMMARY |
| 87 | + echo "|:------:|-----------|---------|-------|" >> $GITHUB_STEP_SUMMARY |
| 88 | + touch .summary_header |
| 89 | + fi |
| 90 | +
|
| 91 | + if [ -f test.tap ]; then |
| 92 | + while IFS= read -r line; do |
| 93 | + if [[ $line =~ ^ok ]]; then |
| 94 | + test_name="${line#ok }" |
| 95 | + # Remove the test number from the beginning |
| 96 | + test_name="${test_name#* }" |
| 97 | + echo "| ✅ | ${test_name} | ${{ inputs.profile }} | ${{ inputs.shard }}/${{ inputs.total_shards }} |" >> $GITHUB_STEP_SUMMARY |
| 98 | + elif [[ $line =~ ^not\ ok ]]; then |
| 99 | + test_name="${line#not 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 | + fi |
| 104 | + done < test.tap |
| 105 | + else |
| 106 | + echo "| ⚠️ | No test results found | ${{ inputs.profile }} | ${{ inputs.shard }}/${{ inputs.total_shards }} |" >> $GITHUB_STEP_SUMMARY |
| 107 | + fi |
| 108 | +
|
| 109 | + - name: Clean up |
| 110 | + if: always() |
| 111 | + shell: bash |
| 112 | + run: | |
| 113 | + sudo rm -rf /home/ubuntu/tests/ |
0 commit comments