-
Notifications
You must be signed in to change notification settings - Fork 740
191 lines (169 loc) · 6.71 KB
/
nf-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Run nf-test
on:
push:
branches:
# https://docs.renovatebot.com/key-concepts/automerge/#branch-vs-pr-automerging
- "renovate/**" # branches Renovate creates
pull_request:
branches: [master]
merge_group:
types: [checks_requested]
branches: [master]
workflow_dispatch:
inputs:
runners:
description: "Runners to test on"
type: choice
options:
- "ubuntu-latest"
- "self-hosted"
default: "self-hosted"
# Cancel if a newer run is started
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# renovate: datasource=github-releases depName=askimed/nf-test versioning=semver
NFT_VER: "0.9.2"
NXF_ANSI_LOG: false
NXF_SINGULARITY_CACHEDIR: ${{ github.workspace }}/.singularity
NXF_SINGULARITY_LIBRARYDIR: ${{ github.workspace }}/.singularity
# renovate: datasource=github-releases depName=nextflow/nextflow versioning=semver
NXF_VER: "24.10.2"
jobs:
nf-test-changes:
name: nf-test-changes
runs-on: ubuntu-latest
outputs:
# Expose detected tags as 'modules' and 'workflows' output variables
paths: ${{ steps.list.outputs.components }}
modules: ${{ steps.components.outputs.modules }}
subworkflows: ${{ steps.components.outputs.subworkflows}}
shard: ${{ steps.set-shards.outputs.shard }}
total_shards: ${{ steps.set-shards.outputs.total_shards }}
steps:
- name: Clean Workspace # Purge the workspace in case it's running on a self-hosted runner
run: |
ls -la ./
rm -rf ./* || true
rm -rf ./.??* || true
ls -la ./
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: List nf-test files
id: list
uses: adamrtalbot/detect-nf-test-changes@de3c3c8e113031b4f15a3c1104b5f135e8346997 # v0.0.6
with:
head: ${{ github.sha }}
base: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
n_parents: 0
exclude_tags: "gpu"
- name: Separate modules and subworkflows
id: components
run: |
echo modules=$(echo '${{ steps.list.outputs.components }}' | jq -c '. | map(select(contains("modules"))) | map(gsub("modules/nf-core/"; ""))') >> $GITHUB_OUTPUT
echo subworkflows=$(echo '${{ steps.list.outputs.components }}' | jq '. | map(select(contains("subworkflows"))) | map(gsub("subworkflows/nf-core/"; ""))') >> $GITHUB_OUTPUT
- name: get number of shards
id: set-shards
if: ${{ steps.list.outputs.components != '[]' }}
uses: ./.github/actions/get-shards
env:
NFT_VER: ${{ env.NFT_VER }}
with:
max_shards: 15
paths: "${{ join(fromJson(steps.list.outputs.components ), ' ') }}"
- name: debug
run: |
echo ${{ steps.list.outputs.components }}
echo ${{ steps.components.outputs.modules }}
echo ${{ steps.components.outputs.subworkflows }}
echo ${{ steps.set-shards.outputs.shard }}
echo ${{ steps.set-shards.outputs.total_shards }}
nf-test:
runs-on: ${{ github.event.inputs.runners || 'self-hosted' }}
name: "Test | ${{ matrix.profile }} | ${{ matrix.shard }}"
needs: [nf-test-changes]
if: ${{ needs.nf-test-changes.outputs.total_shards != '0' }}
strategy:
fail-fast: false
matrix:
shard: ${{ fromJson(needs.nf-test-changes.outputs.shard) }}
profile: [conda, docker_self_hosted, singularity]
env:
NXF_ANSI_LOG: false
TOTAL_SHARDS: ${{ needs.nf-test-changes.outputs.total_shards }}
outputs:
filtered_paths: ${{ steps.filter.outputs.filtered_paths }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Filter paths
id: filter
run: |
PATHS='${{ needs.nf-test-changes.outputs.paths }}'
FILTERED=$(jq -n -c \
--arg profile "${{ matrix.profile }}" \
--argjson input_paths "$PATHS" \
'
def get_skip_list: inputs | .[$profile] // [];
# Get skip list and filter
get_skip_list as $skip_patterns |
# Debug output
($skip_patterns | "Skip patterns: " + (map(" - " + .) | join(","))) |
debug |
# Do the actual filtering
$input_paths | map(
. as $path |
select($skip_patterns | all(. as $pattern | ($path | startswith($pattern)) | not))
) as $result |
# Debug what was skipped
(if ($input_paths - $result) | length > 0 then
"Skipped: " + (($input_paths - $result) | map(" - " + .) | join(","))
else
"No paths skipped"
end) |
debug |
$result
' .github/skip_nf_test.json)
echo "filtered_paths=${FILTERED}" >> $GITHUB_OUTPUT
- name: Run nf-test Action
if: ${{steps.filter.outputs.filtered_paths != '[]'}}
uses: ./.github/actions/nf-test-action
env:
SENTIEON_ENCRYPTION_KEY: ${{ secrets.SENTIEON_ENCRYPTION_KEY }}
SENTIEON_LICENSE_MESSAGE: ${{ secrets.SENTIEON_LICENSE_MESSAGE }}
SENTIEON_LICSRVR_IP: ${{ secrets.SENTIEON_LICSRVR_IP }}
SENTIEON_AUTH_MECH: "GitHub Actions - token"
with:
profile: ${{ matrix.profile }}
shard: ${{ matrix.shard }}
total_shards: ${{ env.TOTAL_SHARDS }}
paths: "${{ join(fromJson(steps.filter.outputs.filtered_paths), ' ') }}"
confirm-pass:
runs-on: ubuntu-latest
needs: [nf-test]
if: always()
steps:
- name: One or more tests failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
- name: One or more tests cancelled
if: ${{ contains(needs.*.result, 'cancelled') }}
run: exit 1
- name: All tests ok
if: ${{ contains(needs.*.result, 'success') }}
run: exit 0
- name: If no tests run, but filtered_paths was not empty and no tests succeeded, fail
if: ${{ needs.nf-test.outputs.filtered_paths != '[]' && !contains(needs.*.result, 'success') }}
run: exit 1
- name: debug-print
if: always()
run: |
echo "::group::DEBUG: `needs` Contents"
echo "DEBUG: toJSON(needs) = ${{ toJSON(needs) }}"
echo "DEBUG: toJSON(needs.*.result) = ${{ toJSON(needs.*.result) }}"
echo "DEBUG: toJSON(needs.nf-test.outputs.filtered_paths) = ${{ needs.nf-test.outputs.filtered_paths }}"
echo "::endgroup::"