-
Notifications
You must be signed in to change notification settings - Fork 21
265 lines (233 loc) · 9.53 KB
/
ci.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
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
name: CI
on:
push:
branches:
- dev
- main
- ci
pull_request:
branches:
- dev
- main
release:
types: [published]
env:
SINGULARITY_VERSION: "3.8.3"
NXF_ANSI_LOG: false
CAPSULE_LOG: none
NXF_SINGULARITY_CACHEDIR: "${{ github.workspace }}/singularity"
jobs:
preload_docker:
name: Preload docker images
if: ${{ github.event_name == 'push'}}
runs-on: ubuntu-latest
steps:
- name: Check out pipeline code
uses: actions/checkout@v3
- name: Cache docker
id: cache-docker
uses: actions/cache@v3
with:
path: ${{ runner.temp }}/docker
key: ${{ runner.os }}-${{ github.sha }}
- name: Pull and save docker
if: matrix.profile == 'docker' && ${{ steps.cache-docker.outputs.cache-hit != 'true' }}
run: |
git grep 'ext.docker*' ${{ github.workspace }}/conf/modules.config | cut -f 2 -d '=' | xargs -L 2 echo | tr -d ' ' > ${{ runner.temp }}/images.txt
cat ${{ runner.temp }}/images.txt | xargs -I {} sh -c 'docker pull --platform linux/amd64 "$1"' - {}
mkdir -p ${{ runner.temp }}/docker/
cat ${{ runner.temp }}/images.txt | xargs -I {} sh -c 'docker save "$1" > ${{ runner.temp }}/docker/$(basename "$1").tar' - {}
preload_singularity:
name: Preload singularity images
if: ${{ github.event_name == 'push'}}
runs-on: ubuntu-latest
steps:
- name: Check out pipeline code
uses: actions/checkout@v3
- name: Cache singularity setup
id: cache-singularity-setup
uses: actions/cache@v3
with:
path: /opt/hostedtoolcache/singularity/${{ env.SINGULARITY_VERSION }}/x64
key: ${{ runner.os }}-singularity-${{ env.SINGULARITY_VERSION }}
- name: Set up Singularity
uses: eWaterCycle/setup-singularity@v7
if: ${{ steps.cache-singularity-setup.outputs.cache-hit != 'true' }}
with:
singularity-version: ${{ env.SINGULARITY_VERSION }}
- name: Add singularity to path
if: steps.cache-singularity-setup.outputs.cache-hit == 'true'
run: |
echo "/opt/hostedtoolcache/singularity/${{ env.SINGULARITY_VERSION }}/x64/bin" >> $GITHUB_PATH
- name: Cache singularity images
id: cache-singularity-pull
uses: actions/cache@v3
with:
path: ${{ env.NXF_SINGULARITY_CACHEDIR }}
key: ${{ runner.os }}-${{ github.sha }}--singularity
- name: Pull and save singularity
if: ${{ steps.cache-singularity-pull.outputs.cache-hit != 'true' }}
run: |
mkdir -p $NXF_SINGULARITY_CACHEDIR
git grep 'ext.singularity*' conf/modules.config | cut -f 2 -d '=' | xargs -L 2 echo | tr -d ' ' > ${{ runner.temp }}/singularity_images.txt
cat ${{ runner.temp }}/singularity_images.txt | sed 's/oras:\/\///;s/https:\/\///;s/\//-/g;s/$/.img/;s/:/-/' > ${{ runner.temp }}/singularity_image_paths.txt
paste -d '\n' ${{ runner.temp }}/singularity_image_paths.txt ${{ runner.temp }}/singularity_images.txt | xargs -L 2 sh -c 'singularity pull --disable-cache --dir $NXF_SINGULARITY_CACHEDIR $0 $1'
test:
needs: [preload_docker, preload_singularity]
name: Run standard workflow test
if: ${{ github.event_name == 'push'}}
runs-on: ubuntu-latest
env:
NXF_VER: ${{ matrix.nxf_ver }}
strategy:
fail-fast: false
matrix:
test_profile: ["test"]
profile: ["docker", "singularity"]
nxf_ver: ['22.10.0', ''] # minimum supported version, latest version
steps:
- name: Check out pipeline code
uses: actions/checkout@v3
- name: Install Nextflow
run: |
wget -qO- get.nextflow.io | bash
sudo mv nextflow /usr/local/bin/
- name: Restore docker cache
id: restore-docker
uses: actions/cache@v3
if: matrix.profile == 'docker'
with:
path: ${{ runner.temp }}/docker
key: ${{ runner.os }}-${{ github.sha }}
- name: Load docker images from cache
if: steps.restore-docker.outputs.cache-hit == 'true'
run: |
find $HOME -name '*.tar'
find ${{ runner.temp }}/docker/ -name '*.tar' -exec sh -c 'docker load < {}' \;
- name: Cache singularity setup
id: restore-singularity-setup
if: matrix.profile == 'singularity'
uses: actions/cache@v3
with:
path: /opt/hostedtoolcache/singularity/${{ env.SINGULARITY_VERSION }}/x64
key: ${{ runner.os }}-singularity-${{ env.SINGULARITY_VERSION }}
- name: Add singularity to path
if: steps.restore-singularity-setup.outputs.cache-hit == 'true'
run: |
echo "/opt/hostedtoolcache/singularity/${{ env.SINGULARITY_VERSION }}/x64/bin" >> $GITHUB_PATH
- name: Restore singularity cache
id: restore-singularity
uses: actions/cache@v3
if: matrix.profile == 'singularity'
with:
path: ${{ env.NXF_SINGULARITY_CACHEDIR }}
key: ${{ runner.os }}-${{ github.sha }}--singularity
- name: Run pipeline with test data
continue-on-error: false
run: |
nextflow run ${GITHUB_WORKSPACE} -profile ${{ matrix.test_profile}},${{ matrix.profile }}
unit_test:
needs: [preload_docker, preload_singularity]
name: ${{ matrix.profile }} ${{ matrix.tags }}
if: ${{ github.event_name == 'push'}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
profile: ["docker", "singularity"]
tags:
- "test input check subworkflow"
- "test input check subworkflow with PGS catalog API"
- "test input check subworkflow with PGS catalog API and whitespace"
- "test make compatible subworkflow with bfile"
- "test make compatible subworkflow with vcf"
- "test make compatible subworkflow with pfile"
- "test input check subworkflow with liftover 38to37"
- "test input check subworkflow with liftover 37to38"
- "test apply score subworkflow"
- "test perfect apply score"
# TODO - "test score correlation"
- "test combine scorefiles module"
- "test match module"
- "test match combine module"
- "plink2 testrelabelpvar"
- "plink2 testscore"
- "plink2 testsmallscore"
- "plink2 testmultiscore"
- "plink2 testsmallmultiscore"
- "plink2 testmultiscorefail"
- "plink2 vcf"
- "plink2 testrelabelbim"
- "pgscatalog test --pgs_id"
- "pgscatalog test --efo_trait --pgp_id and --pgs_id"
- "pgscatalog test bad accession"
- "pgscatalog test good and bad accessions GRCh38"
steps:
- name: Check out pipeline code
uses: actions/checkout@v3
- name: Restore docker cache
id: restore-docker
uses: actions/cache@v3
if: matrix.profile == 'docker'
with:
path: ${{ runner.temp }}/docker
key: ${{ runner.os }}-${{ github.sha }}
- name: Load docker images from cache
if: steps.restore-docker.outputs.cache-hit == 'true'
run: |
find $HOME -name '*.tar'
find ${{ runner.temp }}/docker/ -name '*.tar' -exec sh -c 'docker load < {}' \;
- name: Cache singularity setup
id: cache-singularity
if: matrix.profile == 'singularity'
uses: actions/cache@v3
with:
path: /opt/hostedtoolcache/singularity/${{ env.SINGULARITY_VERSION }}/x64
key: ${{ runner.os }}-singularity-${{ env.SINGULARITY_VERSION }}
- name: Set up Singularity
uses: eWaterCycle/setup-singularity@v7
if: steps.cache-singularity.outputs.cache-hit != 'true' && matrix.profile == 'singularity'
- name: Add singularity to path
if: steps.cache-singularity.outputs.cache-hit == 'true' && matrix.profile == 'singularity'
run: |
echo "/opt/hostedtoolcache/singularity/${{ env.SINGULARITY_VERSION }}/x64/bin" >> $GITHUB_PATH
- name: Restore singularity cache
id: restore-singularity
uses: actions/cache@v3
if: matrix.profile == 'singularity'
with:
path: ${{ env.NXF_SINGULARITY_CACHEDIR }}
key: ${{ runner.os }}-${{ github.sha }}--singularity
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
cache: 'pip'
- run: pip install -r ${{ github.workspace }}/tests/requirements.txt
- name: Install Nextflow
run: |
wget -qO- get.nextflow.io | bash
sudo mv nextflow /usr/local/bin/
- name: Run unit tests
run: TMPDIR=~ PROFILE=${{ matrix.profile }} pytest --kwdof --symlink --git-aware --wt 2 --tag "${{ matrix.tags }}" --ignore tests/bin
- name: Output log on failure
if: failure()
run: |
echo "======> log.out <======="
cat /home/runner/pytest_workflow_*/*/log.out
echo
echo
echo "======> log.err <======="
cat /home/runner/pytest_workflow_*/*/log.err
- name: Upload logs on failure
if: failure()
uses: actions/upload-artifact@v2
with:
name: logs-${{ matrix.profile }}
path: |
/home/runner/pytest_workflow_*/*/.nextflow.log
/home/runner/pytest_workflow_*/*/log.out
/home/runner/pytest_workflow_*/*/log.err
/home/runner/pytest_workflow_*/*/work
!/home/runner/pytest_workflow_*/*/work/conda
!/home/runner/pytest_workflow_*/*/work/singularity