diff --git a/.github/actions/nf-test-shard/action.yml b/.github/actions/nf-test-shard/action.yml index 79e27cd9..52837a5a 100644 --- a/.github/actions/nf-test-shard/action.yml +++ b/.github/actions/nf-test-shard/action.yml @@ -1,5 +1,12 @@ name: "Get number of shards" description: "Get the number of nf-test shards for the current CI job" +inputs: + tags: + description: "Tags to pass as argument for nf-test --tag parameter" + required: true + max_shards: + description: "Maximum number of shards allowed" + required: true outputs: shard: description: "Array of shard numbers" @@ -22,7 +29,7 @@ runs: shell: bash run: | # Run nf-test to get the number of related tests - nftest_output=$(nf-test test --dry-run --changed-since HEAD^ --filter pipeline) + nftest_output=$(nf-test test --dry-run --changed-since HEAD^ --filter pipeline --tag ${{ inputs.tags }}) echo "nf-test dry-run output: $nftest_output" # Default values for shard and total_shards @@ -30,14 +37,15 @@ runs: total_shards=0 # Check if there are related tests - if echo "$nftest_output" | grep -q 'Found 0 related test(s)'; then + if echo "$nftest_output" | grep -q 'Nothing to do'; then echo "No related tests found." else # Extract the number of related tests - number_of_shards=$(echo "$nftest_output" | grep -o 'Found [0-9]* related test' | tail -1 | awk '{print $2}') + 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 - shard=$(seq 1 "$number_of_shards" | jq -R . | jq -c -s .) - total_shards="$number_of_shards" + 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 diff --git a/.github/actions/nf-test/action.yml b/.github/actions/nf-test/action.yml index a911cf60..84131a13 100644 --- a/.github/actions/nf-test/action.yml +++ b/.github/actions/nf-test/action.yml @@ -14,7 +14,7 @@ inputs: description: "Filter test cases by specified types (e.g., module, pipeline, workflow or function)" required: true tags: - description: "Test tags to be run" + description: "Tags to pass as argument for nf-test --tag parameter" required: true runs: @@ -75,7 +75,7 @@ runs: --filter ${{ inputs.filters }} \ --tap=test.tap \ --verbose \ - ${{ inputs.tags }} + --tag ${{ inputs.tags }} # TODO If no test.tap, then make one to spoof? - uses: pcolby/tap-summary@0959cbe1d4422e62afc65778cdaea6716c41d936 # v1 diff --git a/.github/workflows/nf-test-gpu.yml b/.github/workflows/nf-test-gpu.yml index 8d5d11cd..00c435bd 100644 --- a/.github/workflows/nf-test-gpu.yml +++ b/.github/workflows/nf-test-gpu.yml @@ -46,6 +46,9 @@ jobs: uses: ./.github/actions/nf-test-shard env: NFT_VER: ${{ env.NFT_VER }} + with: + tags: "cpu" + max_shards: 2 - name: Set outputs id: set-outputs @@ -81,7 +84,7 @@ jobs: shard: ${{ matrix.shard }} total_shards: ${{ needs.get-shards.outputs.total_shards }} filters: ${{ matrix.filters }} - tags: "--tag gpu" + tags: "gpu" confirm-pass: runs-on: ubuntu-latest diff --git a/.github/workflows/nf-test.yml b/.github/workflows/nf-test.yml index e1c866c5..309f3a3a 100644 --- a/.github/workflows/nf-test.yml +++ b/.github/workflows/nf-test.yml @@ -49,6 +49,9 @@ jobs: uses: ./.github/actions/nf-test-shard env: NFT_VER: ${{ env.NFT_VER }} + with: + tags: "cpu" + max_shards: 5 - name: Set outputs id: set-outputs @@ -84,6 +87,7 @@ jobs: shard: ${{ matrix.shard }} total_shards: ${{ needs.get-shards.outputs.total_shards }} filters: ${{ matrix.filters }} + tags: "cpu" confirm-pass: runs-on: ubuntu-latest