-
Notifications
You must be signed in to change notification settings - Fork 31
483 lines (437 loc) · 13.7 KB
/
workflows.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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
---
name: "CI build and test jobs"
on:
pull_request:
branches-ignore:
- /doc\/.*/
push:
branches:
- dev
- maint/*
tags:
- '*'
schedule:
# 7am EST / 8am EDT, daily
- cron: '0 12 * * *'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
INSTALL_TYPE: pip
defaults:
run:
shell: bash -l {0}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.9
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Add version to environment
run: |
python -c 'import fitlins; print(f"VERSION={fitlins.__version__}")' >> $GITHUB_ENV
- name: Check version matches tag
if: startsWith(github.ref, 'refs/tags/')
run: test "$VERSION" = "${{ github.ref_name }}"
- name: Build image and export
timeout-minutes: 30
uses: docker/build-push-action@v5
with:
context: .
build-args: |
BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
VCS_REF="$(git rev-parse --short HEAD)"
VERSION=${{ env.VERSION }}
push: false
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
load: true
- name: Verify executable can be run
run: |
docker images
docker run --rm $IMAGE_NAME:latest --help
- name: Check version
run: |
DOCKERVERSION=$(docker run --rm $IMAGE_NAME:latest --version \
| tail -n 1 | sed -e 's/.*fit/fit/' -e 's/[\r\n]//g')
echo "$VERSION"
echo "$DOCKERVERSION"
test "$DOCKERVERSION" = "fitlins v$VERSION"
- name: Export docker image to a tar file
run: |
docker save ${{ github.repository }} > /tmp/docker.tar
ls -l /tmp/
- name: Upload docker.tar as artifact
uses: actions/upload-artifact@v3
with:
name: docker
path: /tmp/docker.tar
cache_test_data:
runs-on: ubuntu-latest
steps:
- name: "Make cachedir"
run: |
mkdir -p /tmp/.cache/data && \
chmod 777 /tmp/.cache/data
- name: Set git ID
run: |
git config --global user.name 'Fitlins GH-Action User' && \
git config --global user.email 'shashankbansal56@gmail.com'
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install dependencies
shell: bash -l {0}
run: |
sudo apt-get update -y
sudo apt-get install -y git-annex
python -m pip install --upgrade pip
pip install datalad==0.14.7
- name: Datalad WTF
run: |
datalad wtf
- name: Install cached data
uses: actions/cache@v3
id: cache
with:
path: /tmp/.cache/data
key: ds003-v5-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
ds003-v5-${{ github.ref_name }}-
ds003-v5-
- name: "Install fMRIPrep derivatives of ds000003 and reference data"
# if: steps.cache.outputs.cache-hit != 'true'
run: |
cd /tmp/.cache/data
datalad install -r -s https://gin.g-node.org/markiewicz/fitlins-tests
datalad update --merge -d fitlins-tests
cd fitlins-tests
datalad get inputs/ds000003-fmriprep/sub-0{1,2,3}/func/*_space-MNI152NLin2009cAsym_desc-*.nii.gz \
inputs/ds000003-fmriprep/sub-0{1,2,3}/func/*_desc-confounds_*.tsv \
inputs/ds000003-fmriprep/dataset_description.json \
inputs/ds000003-fmriprep/sub-*/*/*.json \
outputs
datalad status
- name: "Check installed derivatives data"
run: |
cd /tmp/.cache/data/fitlins-tests/
git log --oneline --graph
du -sh .
run_pytest:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-latest']
python-version: ["3.7", "3.8", "3.9", "3.10"]
pip-flags: ['']
check: ['test']
env:
CHECK_TYPE: ${{ matrix.check }}
EXTRA_PIP_FLAGS: ${{ matrix.pip-flags }}
OS_TYPE: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
auto-update-conda: true
activate-environment: fitlins-ci
environment-file: tools/ci/conda_environment.yml
python-version: ${{ matrix.python-version }}
show-channel-urls: true
auto-activate-base: false
- name: Test conda installation
run: |
conda info
conda list
conda env list
conda config --show-sources
conda config --show
- name: Install dependencies
run: |
conda install -y --channel leej3 "afni-minimal"
conda list | grep afni
- name: Display Python version
run: |
which python
which pip
python -c "import sys; print(sys.version)"
- name: Install fitlins
run: tools/ci/install.sh
- name: Run tests
run: tools/ci/check.sh
- uses: codecov/codecov-action@v3
with:
verbose: true
if: ${{ always() }}
pre-release:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest']
python-version: ['3.10']
# Check pre-release pybids and pre-release everything
pip-flags: ['', 'PRE_PIP_FLAGS']
check: ['test']
env:
CHECK_TYPE: ${{ matrix.check }}
EXTRA_PIP_FLAGS: ${{ matrix.pip-flags }}
OS_TYPE: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: fitlins-ci
environment-file: tools/ci/conda_environment.yml
python-version: ${{ matrix.python-version }}
- name: Test conda installation
run: |
conda info
conda list
conda env list
conda config --show-sources
conda config --show
- name: Install dependencies
run: |
conda install -y --channel leej3 "afni-minimal"
conda list | grep afni
- name: Display Python version
run: |
which python
which pip
python -c "import sys; print(sys.version)"
- name: Install fitlins
run: tools/ci/install.sh
- name: Install pybids from GitHub
run: pip install git+https://github.com/bids-standard/pybids.git
- name: Run tests
run: tools/ci/check.sh
- uses: codecov/codecov-action@v3
with:
verbose: true
if: ${{ always() }}
test_ds003_nistats_smooth:
needs: [cache_test_data]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.9]
test_name: ["nistats_smooth"]
pip-flags: ['']
check: ['workflow']
env:
CHECK_TYPE: ${{ matrix.check }}
EXTRA_PIP_FLAGS: ${{ matrix.pip-flags }}
OS_TYPE: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install fitlins
run: tools/ci/install.sh
- name: Restore cached test data
uses: actions/cache@v3
id: cache
with:
path: /tmp/.cache/data
key: ds003-v5-${{ github.ref_name }}-${{ github.sha }}
- name: Run fitlins tests
timeout-minutes: 240
run: |
mkdir -p $WORK_DIR $OUTPUT_DIR
chmod 777 $WORK_DIR $OUTPUT_DIR
tools/ci/check.sh
env:
DATA: /tmp/.cache/data/fitlins-tests
TEST_NAME: ${{ matrix.test_name }}
OUTPUT_DIR: /tmp/ds003/derivatives
WORK_DIR: /tmp/ds003/work
- name: Combine coverage and submit
uses: codecov/codecov-action@v3
with:
verbose: true
test_ds003_afni:
needs: [cache_test_data]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.9]
test_name: ["afni_smooth", "afni_blurto"]
pip-flags: ['']
check: ['workflow']
env:
CHECK_TYPE: ${{ matrix.check }}
EXTRA_PIP_FLAGS: ${{ matrix.pip-flags }}
OS_TYPE: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
auto-update-conda: true
activate-environment: fitlins-ci
environment-file: tools/ci/conda_environment.yml
python-version: ${{ matrix.python-version }}
show-channel-urls: true
auto-activate-base: false
- name: Test conda installation
run: |
conda info
conda list
conda env list
- name: Install dependencies
run: |
conda install -y --channel leej3 "afni-minimal"
conda list | grep afni
- name: Install fitlins
run: tools/ci/install.sh
- name: Restore cached test data
uses: actions/cache@v3
id: cache
with:
path: /tmp/.cache/data
key: ds003-v5-${{ github.ref_name }}-${{ github.sha }}
- name: Run fitlins tests
timeout-minutes: 240
run: |
mkdir -p $WORK_DIR $OUTPUT_DIR
chmod 777 $WORK_DIR $OUTPUT_DIR
tools/ci/check.sh
env:
DATA: /tmp/.cache/data/fitlins-tests
TEST_NAME: ${{ matrix.test_name }}
OUTPUT_DIR: /tmp/ds003/derivatives
WORK_DIR: /tmp/ds003/work
- name: Combine coverage and submit
uses: codecov/codecov-action@v3
with:
verbose: true
test_ds003_nistats_blurto:
needs: [build, cache_test_data]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test_name: ["nistats_blurto"]
steps:
- uses: actions/checkout@v4
- name: Set up docker buildx
uses: docker/setup-buildx-action@v3
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: docker
path: /tmp
- name: Load docker image
run: |
docker info
set +o pipefail
ls -l /tmp/docker.tar
docker load < /tmp/docker.tar
docker images
- name: Restore cached test data
uses: actions/cache@v3
id: cache
with:
path: /tmp/.cache/data
key: ds003-v5-${{ github.ref_name }}-${{ github.sha }}
- name: Run fitlins tests
timeout-minutes: 240
run: |
mkdir -p $WORK_DIR $OUTPUT_DIR
chmod 777 $WORK_DIR $OUTPUT_DIR
docker run --rm \
-v $DATA:$DATA \
-v $WORK_DIR:$WORK_DIR \
-v $OUTPUT_DIR:$OUTPUT_DIR \
-v $PWD:/work \
-e CHECK_TYPE -e TEST_NAME \
-e DATA -e WORK_DIR -e OUTPUT_DIR \
-u $UID \
--entrypoint=/neurodocker/startup.sh \
$IMAGE tools/ci/check.sh
env:
IMAGE: ${{ github.repository }}:latest
CHECK_TYPE: workflow
DATA: /tmp/.cache/data/fitlins-tests
TEST_NAME: ${{ matrix.test_name }}
OUTPUT_DIR: /tmp/ds003/derivatives
WORK_DIR: /tmp/ds003/work
- name: Combine coverage and submit
uses: codecov/codecov-action@v3
with:
verbose: true
deploy_docker:
needs: [test_ds003_afni, test_ds003_nistats_smooth, test_ds003_nistats_blurto]
if: github.ref == 'refs/heads/dev' || startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Set up docker buildx
uses: docker/setup-buildx-action@v3
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: docker
path: /tmp
- name: Load docker image
run: |
docker info
set +o pipefail
ls -l /tmp/docker.tar
docker load < /tmp/docker.tar
docker images
- name: Set version/dev tags
run: |
# GHCR
docker tag $IMAGE_NAME $REGISTRY/$IMAGE_NAME:${{ github.ref_name }}
# DockerHub
docker tag $IMAGE_NAME $IMAGE_NAME:${{ github.ref_name }}
- name: Check images
run: docker images
- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to GHCR
timeout-minutes: 60
run: docker push $REGISTRY/$IMAGE_NAME:${{ github.ref_name }}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Deploy to DockerHub
timeout-minutes: 60
run: docker push $IMAGE_NAME:${{ github.ref_name }}
- name: Deploy ":latest" to DockerHub
timeout-minutes: 10
if: startsWith(github.ref, 'refs/tags/')
run: docker push $IMAGE_NAME:latest