-
Notifications
You must be signed in to change notification settings - Fork 5
240 lines (207 loc) · 7.57 KB
/
Copy pathci.yml
File metadata and controls
240 lines (207 loc) · 7.57 KB
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
name: CI
on:
push:
branches:
- main
- dev
paths-ignore:
- "**/meta.yml"
pull_request:
branches:
- main
paths-ignore:
- "**/meta.yml"
workflow_dispatch:
# 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 }}
NXF_ANSI_LOG: false
# renovate: datasource=github-releases depName=nextflow/nextflow versioning=semver
NXF_VER: "25.04.8"
# renovate: datasource=github-releases depName=askimed/nf-test versioning=semver
NFT_VER: "0.9.3"
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install Prettier
run: npm install -g prettier
- name: Run Prettier check
run: prettier --check .
editorconfig:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install editorconfig-checker
run: pip install editorconfig-checker
- name: Run editorconfig-checker
run: ec
detect-changed-modules:
name: Detect changed modules
runs-on: ubuntu-latest
outputs:
modules: ${{ steps.components.outputs.modules }}
test_files: ${{ steps.list.outputs.test_files }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changed test files
id: list
run: |
# Get base commit for comparison
if [ "${{ github.event_name }}" == "pull_request" ]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
else
BASE_SHA="HEAD~1"
fi
echo "Comparing against: $BASE_SHA"
# Get changed files
CHANGED_FILES=$(git diff --name-only $BASE_SHA...HEAD || git diff --name-only HEAD~1 HEAD)
echo "Changed files:"
echo "$CHANGED_FILES"
# Extract test files for changed modules
TEST_FILES=()
while IFS= read -r file; do
# Walk up from the changed file to the nearest module (the closest
# ancestor dir with tests/main.nf.test). This handles both flat
# modules (modules/org/tool/) and subtool modules
# (modules/org/tool/subtool/), e.g. bigbio/qpx/diann.
if [[ "$file" == modules/* ]]; then
dir=$(dirname "$file")
while [[ "$dir" == modules/* && "$dir" != "modules" ]]; do
test_file="${dir}/tests/main.nf.test"
if [ -f "$test_file" ]; then
if [[ ! " ${TEST_FILES[@]} " =~ " ${test_file} " ]]; then
TEST_FILES+=("$test_file")
fi
break
fi
dir=$(dirname "$dir")
done
fi
done <<< "$CHANGED_FILES"
# Convert to JSON array
if [ ${#TEST_FILES[@]} -eq 0 ]; then
echo 'test_files=[]' >> $GITHUB_OUTPUT
echo "No changed modules with tests found."
else
TEST_FILES_JSON=$(printf '%s\n' "${TEST_FILES[@]}" | jq -R . | jq -s .)
{
echo "test_files<<EOF"
echo "$TEST_FILES_JSON"
echo "EOF"
} >> $GITHUB_OUTPUT
echo "Changed test files:"
printf '%s\n' "${TEST_FILES[@]}"
fi
- name: Extract module names
id: components
run: |
TEST_FILES='${{ steps.list.outputs.test_files }}'
if [ "$TEST_FILES" == "[]" ]; then
echo 'modules=[]' >> $GITHUB_OUTPUT
else
# Extract module paths from test file paths
# modules/bigbio/thermorawfileparser/tests/main.nf.test -> bigbio/thermorawfileparser
MODULES=$(echo "$TEST_FILES" | jq -c 'map(gsub("modules/"; "") | gsub("/tests/main.nf.test"; ""))')
{
echo "modules<<EOF"
echo "$MODULES"
echo "EOF"
} >> $GITHUB_OUTPUT
fi
test-modules:
name: "${{ matrix.profile }} | ${{ matrix.module }}"
needs: [detect-changed-modules]
if: needs.detect-changed-modules.outputs.modules != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
module: ${{ fromJson(needs.detect-changed-modules.outputs.modules) }}
profile: [docker]
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install Nextflow
uses: nf-core/setup-nextflow@v1
with:
version: ${{ env.NXF_VER }}
- name: Install nf-test
run: |
wget -qO- https://code.askimed.com/install/nf-test | bash -s ${{ env.NFT_VER }}
sudo mv nf-test /usr/local/bin/
- name: Download onsite test data directory
if: matrix.module == 'bigbio/onsite'
run: |
DIR="tests/data/onsite/Phospho_redissolve_final_01_clean_perc.idparquet"
mkdir -p "$DIR"
BASE_URL="https://ftp.pride.ebi.ac.uk/pub/databases/pride/resources/proteomes/quantms-ci-github/onsite/Phospho_redissolve_final_01_clean_perc.idparquet"
for f in psms.parquet proteins.parquet protein_groups.parquet search_params.parquet; do
echo "Downloading $f ..."
curl -sL -o "$DIR/$f" "$BASE_URL/$f"
done
ls -lh "$DIR"
- name: Run nf-test for ${{ matrix.module }}
env:
PROFILE: ${{ matrix.profile }}
ONSITE_IDPARQUET_PATH: ${{ github.workspace }}/tests/data/onsite/Phospho_redissolve_final_01_clean_perc.idparquet
run: |
MODULE_PATH="${{ matrix.module }}"
TEST_FILE="modules/${MODULE_PATH}/tests/main.nf.test"
echo "Testing module: ${MODULE_PATH}"
echo "Test file: ${TEST_FILE}"
echo "Profile: ${{ matrix.profile }}"
if [ ! -f "${TEST_FILE}" ]; then
echo "Error: Test file ${TEST_FILE} not found"
exit 1
fi
# Run nf-test with profile (without TAP output to avoid path issues)
nf-test test \
--profile ${{ matrix.profile }} \
${TEST_FILE}
- name: Sanitize module name for artifact
if: always()
id: sanitize
run: |
# Replace / with - to make valid artifact name
SANITIZED=$(echo "${{ matrix.module }}" | tr '/' '-')
echo "name=test-results-${{ matrix.profile }}-${SANITIZED}" >> $GITHUB_OUTPUT
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ steps.sanitize.outputs.name }}
path: test_results/${{ matrix.module }}/
retention-days: 7
confirm-pass-tests:
name: Check test results
runs-on: ubuntu-latest
needs: [test-modules]
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, 'failure') && !contains(needs.*.result, 'cancelled') }}
run: exit 0