@@ -84,98 +84,85 @@ aliases:
84
84
jobs :
85
85
build :
86
86
<< : *machine_defaults
87
+ environment :
88
+ DOCKER_BUILDKIT : 1
87
89
steps :
88
90
- checkout :
89
91
path : *src
90
92
- restore_cache :
91
93
keys :
92
- - build-v0 -{{ .Branch }}-{{ .Revision }}
93
- - build-v0 --{{ .Revision }}
94
- - build-v0 -{{ .Branch }}-
95
- - build-v0 -master-
96
- - build-v0 -
94
+ - build-v1 -{{ .Branch }}-{{ .Revision }}
95
+ - build-v1 --{{ .Revision }}
96
+ - build-v1 -{{ .Branch }}-
97
+ - build-v1 -master-
98
+ - build-v1 -
97
99
paths :
98
100
- /tmp/docker
99
101
- /tmp/images
100
102
- docker/install-docker-credential-helper
101
103
- run : *docker_auth
102
104
- run : *setup_docker_registry
103
105
- run :
104
- name : Save docker registry
105
- command : |
106
- if [[ ! -f /tmp/images/registry.tar.gz ]]; then
107
- mkdir -p /tmp/images
108
- docker save registry:2 | gzip > /tmp/images/registry.tar.gz
109
- fi
110
- - run :
111
- name : Pull Ubuntu/jammy image
112
- command : |
113
- set +e
114
- docker pull localhost:5000/ubuntu
115
- success=$?
116
- set -e
117
- if [[ "$success" = "0" ]]; then
118
- echo "Pulling from local registry"
119
- docker tag localhost:5000/ubuntu ubuntu:jammy-20221130
120
- else
121
- echo "Pulling from Docker Hub"
122
- docker pull ubuntu:jammy-20221130
123
- docker tag ubuntu:jammy-20221130 localhost:5000/ubuntu
124
- docker push localhost:5000/ubuntu
125
- fi
126
- - run :
127
- name : Pull sMRIPrep Docker image
128
- command : |
129
- set +e
130
- docker pull localhost:5000/smriprep
131
- success=$?
132
- set -e
133
- if [[ "$success" = "0" ]]; then
134
- echo "Pulled from local registry"
135
- docker tag localhost:5000/smriprep nipreps/smriprep:latest
136
- docker tag localhost:5000/smriprep nipreps/smriprep
137
- else
138
- echo "Pulling from Docker Hub"
139
- docker pull nipreps/smriprep:latest
140
- fi
106
+ name : Create named builder
107
+ command : docker buildx create --use --name=builder --driver=docker-container
141
108
- run :
142
109
name : Build Docker image
143
110
no_output_timeout : 60m
144
111
command : |
145
112
export PY3=$( pyenv versions | awk '/^\* 3/ { print $2 }' )
146
113
pyenv local $PY3
114
+ pip install hatch
147
115
# Get version, update files.
148
- THISVERSION=$( python3 get_version.py )
116
+ THISVERSION=$( hatch version )
149
117
if [[ ${THISVERSION:0:1} == "0" ]] ; then
150
118
echo "WARNING: latest git tag could not be found"
151
119
echo "Please, make sure you fetch all tags from upstream with"
152
120
echo "the command ``git fetch --tags --verbose`` and push"
153
121
echo "them to your fork with ``git push origin --tags``"
154
122
fi
155
123
# Build docker image
156
- e=1 && for i in {1..5}; do
157
- docker build --rm \
158
- --cache-from= nipreps/smriprep \
124
+ docker buildx build --load --builder builder \
125
+ --cache-from localhost:5000/smriprep \
126
+ --cache-from nipreps/smriprep:latest \
159
127
-t nipreps/smriprep:latest \
160
128
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
161
129
--build-arg VCS_REF=`git rev-parse --short HEAD` \
162
- --build-arg VERSION="${CIRCLE_TAG:-$THISVERSION}" . \
163
- && e=0 && break || sleep 15
164
- done && [ "$e" -eq "0" ]
130
+ --build-arg VERSION="${CIRCLE_TAG:-$THISVERSION}" .
165
131
- run :
166
132
name : Check Docker image
167
133
command : |
168
134
export PY3=$( pyenv versions | awk '/^\* 3/ { print $2 }' )
169
135
pyenv local $PY3
170
136
# Get version, update files.
171
- THISVERSION=$( python3 get_version.py )
137
+ THISVERSION=$( hatch version )
172
138
BUILT_VERSION=$( docker run --rm nipreps/smriprep:latest --version )
173
139
BUILT_VERSION=${BUILT_VERSION%$'\r'}
174
140
BUILT_VERSION=${BUILT_VERSION#*"smriprep v"}
175
141
echo "VERSION: \"$THISVERSION\""
176
142
echo "BUILT: \"$BUILT_VERSION\""
177
143
set -e
178
144
test "$BUILT_VERSION" = "$THISVERSION"
145
+ - run :
146
+ name : Docker push to local registry
147
+ no_output_timeout : 40m
148
+ command : |
149
+ docker tag nipreps/smriprep:latest localhost:5000/smriprep
150
+ docker push localhost:5000/smriprep
151
+ - run :
152
+ name : Docker registry garbage collection
153
+ command : |
154
+ docker exec -it registry /bin/registry garbage-collect --delete-untagged \
155
+ /etc/docker/registry/config.yml
156
+
157
+ - persist_to_workspace :
158
+ root : /tmp
159
+ paths :
160
+ - src/smriprep
161
+ - save_cache :
162
+ key : build-v1-{{ .Branch }}-{{ .Revision }}
163
+ paths :
164
+ - /tmp/docker
165
+ - /tmp/images
179
166
180
167
- run :
181
168
name : Docker push to local registry
@@ -189,7 +176,7 @@ jobs:
189
176
docker exec -it registry /bin/registry garbage-collect --delete-untagged \
190
177
/etc/docker/registry/config.yml
191
178
- save_cache :
192
- key : build-v0 -{{ .Branch }}-{{ .Revision }}
179
+ key : build-v1 -{{ .Branch }}-{{ .Revision }}
193
180
paths :
194
181
- /tmp/docker
195
182
- /tmp/images
@@ -300,7 +287,7 @@ jobs:
300
287
at : /tmp
301
288
- restore_cache :
302
289
keys :
303
- - build-v0 -{{ .Branch }}-{{ .Revision }}
290
+ - build-v1 -{{ .Branch }}-{{ .Revision }}
304
291
paths :
305
292
- /tmp/docker
306
293
- /tmp/images
@@ -337,35 +324,31 @@ jobs:
337
324
338
325
test_deploy_pypi :
339
326
<< : *python_defaults
340
- working_directory : /tmp/src/smriprep
341
327
steps :
342
328
- checkout
329
+ - run :
330
+ name : Update build tools
331
+ command : pip install --upgrade build twine hatch
343
332
- run :
344
333
name : Build sMRIPrep
345
- command : |
346
- pip install --user twine # For use in checking distributions
347
- THISVERSION=$( python get_version.py )
348
- THISVERSION=${THISVERSION%.dirty*}
349
- THISVERSION=${CIRCLE_TAG:-$THISVERSION}
350
- virtualenv --python=python build
351
- source build/bin/activate
352
- pip install --upgrade "pip>=19.1" numpy
353
- echo "${CIRCLE_TAG:-$THISVERSION}" > smriprep/VERSION
354
- python setup.py sdist
355
- pip wheel --no-deps -w dist/ .
334
+ command : python -m build
335
+ - run :
336
+ name : Twine check smriprep
337
+ command : twine check dist/*
338
+ - run :
339
+ name : Pre-run hatch version
340
+ command : hatch version
356
341
- store_artifacts :
357
342
path : /tmp/src/smriprep/dist
358
343
- run :
359
344
name : Check sdist distribution
360
345
command : |
361
- THISVERSION=$( python get_version.py )
362
- THISVERSION=${THISVERSION%.dirty*}
346
+ THISVERSION=$( hatch version )
363
347
THISVERSION=${CIRCLE_TAG:-$THISVERSION}
364
- twine check dist/smriprep*.tar.gz
365
348
virtualenv --python=python sdist
366
349
source sdist/bin/activate
367
- pip install --upgrade " pip>=19.1" numpy
368
- pip install dist/smriprep*.tar.gz
350
+ python -m pip install --upgrade pip
351
+ python -m pip install dist/smriprep*.tar.gz
369
352
which smriprep | grep sdist\\/bin
370
353
INSTALLED_VERSION=$(smriprep --version)
371
354
INSTALLED_VERSION=${INSTALLED_VERSION%$'\r'}
@@ -376,13 +359,11 @@ jobs:
376
359
- run :
377
360
name : Check wheel distribution
378
361
command : |
379
- THISVERSION=$( python get_version.py )
380
- THISVERSION=${THISVERSION%.dirty*}
362
+ THISVERSION=$( hatch version )
381
363
THISVERSION=${CIRCLE_TAG:-$THISVERSION}
382
- twine check dist/smriprep*.whl
383
364
virtualenv --python=python wheel
384
365
source wheel/bin/activate
385
- pip install dist/smriprep*.whl
366
+ python -m pip install dist/smriprep*.whl
386
367
which smriprep | grep wheel\\/bin
387
368
INSTALLED_VERSION=$(smriprep --version)
388
369
INSTALLED_VERSION=${INSTALLED_VERSION%$'\r'}
@@ -392,28 +373,10 @@ jobs:
392
373
test "$INSTALLED_VERSION" = "$THISVERSION"
393
374
- run :
394
375
name : Build smriprep-docker
395
- command : |
396
- THISVERSION=$( python get_version.py )
397
- THISVERSION=${THISVERSION%.dirty*}
398
- cd wrapper
399
- virtualenv --python=python build
400
- source build/bin/activate
401
- pip install --upgrade "pip>=19.1"
402
- sed -i -E "s/(__version__ = )\"[A-Za-z0-9.-]+\"/\1\"${CIRCLE_TAG:-$THISVERSION}\"/" smriprep_docker.py
403
- python setup.py sdist
404
- twine check dist/smriprep*.tar.gz
405
- pip wheel --no-deps -w dist/ .
406
- twine check dist/smriprep*.whl
407
- pip install dist/smriprep*.whl
408
- set +e
409
- INSTALLED_VERSION=$(yes n | smriprep-docker --version)
410
- set -e
411
- INSTALLED_VERSION=${INSTALLED_VERSION%$'\r'}
412
- INSTALLED_VERSION=${INSTALLED_VERSION#*"smriprep wrapper "}
413
- INSTALLED_VERSION=$( echo ${INSTALLED_VERSION} | cut -f1 -d" ")
414
- echo "VERSION: \"$THISVERSION\""
415
- echo "INSTALLED: \"$INSTALLED_VERSION\""
416
- test "$INSTALLED_VERSION" = "$THISVERSION"
376
+ command : python -m build wrapper
377
+ - run :
378
+ name : Twine check wrapper
379
+ command : twine check wrapper/dist/*
417
380
- store_artifacts :
418
381
path : /tmp/src/smriprep/wrapper/dist
419
382
@@ -435,7 +398,7 @@ jobs:
435
398
fi
436
399
- restore_cache :
437
400
keys :
438
- - build-v0 -{{ .Branch }}-{{ .Revision }}
401
+ - build-v1 -{{ .Branch }}-{{ .Revision }}
439
402
paths :
440
403
- /tmp/docker
441
404
- /tmp/images
@@ -566,7 +529,7 @@ jobs:
566
529
fi
567
530
- restore_cache :
568
531
keys :
569
- - build-v0 -{{ .Branch }}-{{ .Revision }}
532
+ - build-v1 -{{ .Branch }}-{{ .Revision }}
570
533
paths :
571
534
- /tmp/docker
572
535
- /tmp/images
@@ -688,8 +651,8 @@ jobs:
688
651
name : Update pip
689
652
command : pip install --upgrade pip
690
653
- run :
691
- name : Install deps
692
- command : pip install -r docs/requirements.txt
654
+ name : Install deps and package
655
+ command : pip install -r docs/requirements.txt .
693
656
- run :
694
657
name : Build only this commit
695
658
no_output_timeout : 30m
@@ -734,35 +697,20 @@ jobs:
734
697
735
698
deploy_pypi :
736
699
<< : *python_defaults
737
- working_directory : /tmp/src/smriprep
738
700
steps :
739
701
- checkout
702
+ - run :
703
+ name : Update build tools
704
+ command : pip install --upgrade build twine
740
705
- run :
741
706
name : Build sMRIPrep
742
- command : |
743
- THISVERSION=$( python get_version.py )
744
- virtualenv --python=python build
745
- source build/bin/activate
746
- pip install --upgrade "pip>=19.1"
747
- echo "${CIRCLE_TAG:-$THISVERSION}" > smriprep/VERSION
748
- python setup.py sdist
749
- pip wheel --no-deps -w dist/ .
707
+ command : python -m build
750
708
- run :
751
709
name : Build smriprep-docker
752
- command : |
753
- THISVERSION=$( python get_version.py )
754
- cd wrapper
755
- virtualenv --python=python build
756
- source build/bin/activate
757
- pip install --upgrade "pip>=19.1"
758
- sed -i -E "s/(__version__ = )\"[A-Za-z0-9.-]+\"/\1\"${CIRCLE_TAG:-$THISVERSION}\"/" smriprep_docker.py
759
- python setup.py sdist
760
- pip wheel --no-deps -w dist/ .
710
+ command : python -m build wrapper/
761
711
- run :
762
712
name : Upload packages to PyPI
763
- command : |
764
- pip install --user twine
765
- twine upload dist/smriprep* wrapper/dist/smriprep*
713
+ command : python -m twine upload dist/smriprep* wrapper/dist/smriprep*
766
714
767
715
deploy_docker :
768
716
<< : *machine_defaults
@@ -777,9 +725,9 @@ jobs:
777
725
fi
778
726
- restore_cache :
779
727
keys :
780
- - build-v0 -{{ .Branch }}-{{ epoch }}
781
- - build-v0 -{{ .Branch }}-
782
- - build-v0 -master-
728
+ - build-v1 -{{ .Branch }}-{{ epoch }}
729
+ - build-v1 -{{ .Branch }}-
730
+ - build-v1 -master-
783
731
paths :
784
732
- /tmp/docker
785
733
- /tmp/images
0 commit comments