|
| 1 | +_machine_kwds: &machine_kwds |
| 2 | + image: circleci/classic:201710-02 |
| 3 | + |
| 4 | +_store_artifacts_kwds: &store_artifacts_kwds |
| 5 | + path: /home/circleci/work/tests |
| 6 | + |
| 7 | +_test_environment: &test_environment |
| 8 | + WORKDIR: /home/circleci/work |
| 9 | + DOCKER_IMAGE: "nipype/nipype" |
| 10 | + |
| 11 | +_set_pr_number: &set_pr_number |
| 12 | + name: Set PR number |
| 13 | + command: | |
| 14 | + echo 'export CIRCLE_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}"' >> $BASH_ENV |
| 15 | + source $BASH_ENV |
| 16 | + echo $CIRCLE_PR_NUMBER |
| 17 | +
|
| 18 | +_generate_dockerfiles: &generate_dockerfiles |
| 19 | + name: Generate Dockerfiles |
| 20 | + command: | |
| 21 | + make gen-dockerfiles |
| 22 | +
|
| 23 | +_modify_nipype_version: &modify_nipype_version |
| 24 | + name: Modify Nipype version if necessary |
| 25 | + command: | |
| 26 | + if [ "$CIRCLE_TAG" != "" ]; then |
| 27 | + sed -i -E "s/(__version__ = )'[A-Za-z0-9.-]+'/\1'$CIRCLE_TAG'/" nipype/info.py |
| 28 | + fi |
| 29 | +
|
| 30 | +_get_base_image: &get_base_image |
| 31 | + name: Get base image (pull or build) |
| 32 | + no_output_timeout: 60m |
| 33 | + command: | |
| 34 | + source /tmp/docker/get_base_image.sh |
| 35 | + if [ "$GET_BASE" == "PULL" ]; then |
| 36 | + echo "Pulling base image ..." |
| 37 | + docker pull nipype/nipype:base |
| 38 | + elif [ "$GET_BASE" == "BUILD" ]; then |
| 39 | + e=1 && for i in {1..5}; do |
| 40 | + docker build -t nipype/nipype:base - < docker/Dockerfile.base && e=0 && break || sleep 15 |
| 41 | + done && [ "$e" -eq "0" ] |
| 42 | + else |
| 43 | + echo "Error: method to get base image not understood" |
| 44 | + exit 1 |
| 45 | + fi |
| 46 | +
|
| 47 | +_build_main_image_py36: &build_main_image_py36 |
| 48 | + name: Build main image (py36) |
| 49 | + no_output_timeout: 60m |
| 50 | + command: | |
| 51 | + e=1 && for i in {1..5}; do |
| 52 | + docker build \ |
| 53 | + --rm=false \ |
| 54 | + --tag nipype/nipype:latest \ |
| 55 | + --tag nipype/nipype:py36 \ |
| 56 | + --build-arg BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \ |
| 57 | + --build-arg VCS_REF="$(git rev-parse --short HEAD)" \ |
| 58 | + --build-arg VERSION="${CIRCLE_TAG}" /home/circleci/nipype \ |
| 59 | + && e=0 && break || sleep 15 |
| 60 | + done && [ "$e" -eq "0" ] |
| 61 | +
|
| 62 | +_build_main_image_py27: &build_main_image_py27 |
| 63 | + name: Build main image (py27) |
| 64 | + no_output_timeout: 60m |
| 65 | + command: | |
| 66 | + e=1 && for i in {1..5}; do |
| 67 | + docker build \ |
| 68 | + --rm=false \ |
| 69 | + --tag nipype/nipype:py27 \ |
| 70 | + --build-arg PYTHON_VERSION_MAJOR=2 \ |
| 71 | + --build-arg PYTHON_VERSION_MINOR=7 \ |
| 72 | + --build-arg BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \ |
| 73 | + --build-arg VCS_REF="$(git rev-parse --short HEAD)" \ |
| 74 | + --build-arg VERSION="${CIRCLE_TAG}-py27" /home/circleci/nipype \ |
| 75 | + && e=0 && break || sleep 15 |
| 76 | + done && [ "$e" -eq "0" ] |
| 77 | +
|
| 78 | +_download_test_data: &_download_test_data |
| 79 | + name: Download test data |
| 80 | + no_output_timeout: 20m |
| 81 | + working_directory: /home/circleci/examples |
| 82 | + environment: |
| 83 | + OSF_NIPYPE_URL: "https://files.osf.io/v1/resources/nefdp/providers/osfstorage" |
| 84 | + command: | |
| 85 | + export DATA_NIPYPE_TUTORIAL_URL="${OSF_NIPYPE_URL}/57f4739cb83f6901ed94bf21" |
| 86 | + curl -sSL --retry 5 --connect-timeout 15 "$DATA_NIPYPE_TUTORIAL_URL" | tar xj |
| 87 | +
|
| 88 | + export DATA_NIPYPE_FSL_COURSE="${OSF_NIPYPE_URL}/57f472cf9ad5a101f977ecfe" |
| 89 | + curl -sSL --retry 5 --connect-timeout 15 "$DATA_NIPYPE_FSL_COURSE" | tar xz |
| 90 | +
|
| 91 | + export DATA_NIPYPE_FSL_FEEDS="${OSF_NIPYPE_URL}/57f473066c613b01f113e7af" |
| 92 | + curl -sSL --retry 5 --connect-timeout 15 "$DATA_NIPYPE_FSL_FEEDS" | tar xz |
| 93 | +
|
| 94 | +_prepare_working_directory: &prepare_working_directory |
| 95 | + name: Prepare working directory |
| 96 | + environment: *test_environment |
| 97 | + command: | |
| 98 | + mkdir -p "$WORKDIR" |
| 99 | + chmod -R 777 "$WORKDIR" |
| 100 | +
|
| 101 | +_get_codecov: &_get_codecov |
| 102 | + name: Get codecov |
| 103 | + command: | |
| 104 | + pip install --no-cache-dir codecov |
| 105 | +
|
| 106 | +_run_codecov_coverage: &_run_codecov_coverage |
| 107 | + name: Run codecov (coverage) |
| 108 | + environment: *test_environment |
| 109 | + command: | |
| 110 | + codecov --file $WORKDIR/tests/coverage*.xml --root "$HOME/nipype" --flags unittests -e CIRCLE_JOB |
| 111 | +
|
| 112 | +_run_codecov_smoke: &_run_codecov_smoke |
| 113 | + name: Run codecov (smoke tests) |
| 114 | + environment: *test_environment |
| 115 | + command: | |
| 116 | + codecov --file $WORKDIR/tests/smoketest*.xml --root "$HOME/nipype" --flags smoketests -e CIRCLE_JOB |
| 117 | +
|
| 118 | +
|
| 119 | +version: 2 |
| 120 | +jobs: |
| 121 | + |
| 122 | + compare_base_dockerfiles: |
| 123 | + docker: |
| 124 | + - image: docker:17.10.0-ce-git |
| 125 | + steps: |
| 126 | + - checkout: |
| 127 | + path: /home/circleci/nipype |
| 128 | + - setup_remote_docker |
| 129 | + - run: |
| 130 | + name: Generate and prune base Dockerfile in preparation for cache check |
| 131 | + working_directory: /home/circleci/nipype/docker |
| 132 | + command: | |
| 133 | + mkdir -p /tmp/docker |
| 134 | + ash ./generate_dockerfiles.sh -b |
| 135 | +
|
| 136 | + # Use the sha256 sum of the pruned Dockerfile as the cache key. |
| 137 | + ash prune_dockerfile.sh Dockerfile.base > /tmp/docker/Dockerfile.base-pruned |
| 138 | + - restore_cache: |
| 139 | + key: dockerfile-cache-v1-master-{{ checksum "/tmp/docker/Dockerfile.base-pruned" }} |
| 140 | + - run: |
| 141 | + name: Determine how to get base image |
| 142 | + command: | |
| 143 | + if [ -f /tmp/docker/cache/Dockerfile.base-pruned ]; then |
| 144 | + echo "Cache found. Will pull base image." |
| 145 | + echo 'export GET_BASE=PULL' > /tmp/docker/get_base_image.sh |
| 146 | + else |
| 147 | + echo "Cache not found. Will build base image." |
| 148 | + echo 'export GET_BASE=BUILD' > /tmp/docker/get_base_image.sh |
| 149 | + fi |
| 150 | + - persist_to_workspace: |
| 151 | + root: /tmp |
| 152 | + paths: |
| 153 | + - docker/Dockerfile.base-pruned |
| 154 | + - docker/get_base_image.sh |
| 155 | + |
| 156 | + test_pytest: |
| 157 | + machine: *machine_kwds |
| 158 | + working_directory: /home/circleci/nipype |
| 159 | + steps: |
| 160 | + - checkout: |
| 161 | + path: /home/circleci/nipype |
| 162 | + - attach_workspace: |
| 163 | + at: /tmp |
| 164 | + - run: *set_pr_number |
| 165 | + - run: *generate_dockerfiles |
| 166 | + - run: *modify_nipype_version |
| 167 | + - run: *get_base_image |
| 168 | + - run: *build_main_image_py36 |
| 169 | + - run: *build_main_image_py27 |
| 170 | + - run: *_get_codecov |
| 171 | + - run: *_download_test_data |
| 172 | + - run: *prepare_working_directory |
| 173 | + - run: |
| 174 | + name: Run pytests (py36) |
| 175 | + no_output_timeout: 30m |
| 176 | + environment: *test_environment |
| 177 | + command: bash -ux /home/circleci/nipype/.circleci/test_py3_pytest.sh |
| 178 | + - run: |
| 179 | + name: Run pytests (py27) |
| 180 | + no_output_timeout: 30m |
| 181 | + environment: *test_environment |
| 182 | + command: bash -ux /home/circleci/nipype/.circleci/test_py2_pytest.sh |
| 183 | + - run: *_run_codecov_coverage |
| 184 | + - store_artifacts: *store_artifacts_kwds |
| 185 | + - store_test_results: *store_artifacts_kwds |
| 186 | + - run: |
| 187 | + name: Build docs (py36) |
| 188 | + no_output_timeout: 30m |
| 189 | + environment: *test_environment |
| 190 | + command: bash -ux /home/circleci/nipype/.circleci/test_py3_docs.sh |
| 191 | + - store_artifacts: |
| 192 | + path: /home/circleci/work/docs |
| 193 | + - run: |
| 194 | + name: Save Docker images to workspace if on master |
| 195 | + no_output_timeout: 60m |
| 196 | + command: | |
| 197 | + if [ "$CIRCLE_BRANCH" = "master" -a -z "$CIRCLE_PULL_REQUEST" ]; then |
| 198 | + docker save nipype/nipype:base \ |
| 199 | + nipype/nipype:latest \ |
| 200 | + nipype/nipype:py27 \ |
| 201 | + nipype/nipype:py36 | gzip -1 > /tmp/docker/nipype-base-latest-py36-py27.tar.gz \ |
| 202 | + && du -h /tmp/docker/nipype-base-latest-py36-py27.tar.gz |
| 203 | + fi |
| 204 | + - persist_to_workspace: |
| 205 | + root: /tmp |
| 206 | + paths: |
| 207 | + - docker |
| 208 | + |
| 209 | + test_py3_fmri_fsl_spm: |
| 210 | + machine: *machine_kwds |
| 211 | + working_directory: /home/circleci/nipype |
| 212 | + steps: |
| 213 | + - checkout: |
| 214 | + path: /home/circleci/nipype |
| 215 | + - attach_workspace: |
| 216 | + at: /tmp |
| 217 | + - run: *set_pr_number |
| 218 | + - run: *generate_dockerfiles |
| 219 | + - run: *modify_nipype_version |
| 220 | + - run: *get_base_image |
| 221 | + - run: *build_main_image_py36 |
| 222 | + - run: *_get_codecov |
| 223 | + - run: *_download_test_data |
| 224 | + - run: *prepare_working_directory |
| 225 | + - run: |
| 226 | + name: Run FSL reuse pipeline (py36) |
| 227 | + no_output_timeout: 40m |
| 228 | + environment: *test_environment |
| 229 | + command: bash -ux /home/circleci/nipype/.circleci/test_py3_fmri_fsl_reuse_linear_l1.sh |
| 230 | + - run: |
| 231 | + name: Run SPM test workflow - 3D inputs (py36) |
| 232 | + no_output_timeout: 40m |
| 233 | + environment: *test_environment |
| 234 | + command: bash -ux /home/circleci/nipype/.circleci/test_py3_fmri_spm_linear_3d.sh |
| 235 | + - run: |
| 236 | + name: Run SPM test workflow - 4D inputs (py36) |
| 237 | + no_output_timeout: 40m |
| 238 | + environment: *test_environment |
| 239 | + command: bash -ux /home/circleci/nipype/.circleci/test_py3_fmri_spm_linear_4d.sh |
| 240 | + - run: *_run_codecov_smoke |
| 241 | + - store_artifacts: *store_artifacts_kwds |
| 242 | + |
| 243 | + test_py3_fmri_spm_dartel_multiproc: |
| 244 | + machine: *machine_kwds |
| 245 | + working_directory: /home/circleci/nipype |
| 246 | + steps: |
| 247 | + - checkout: |
| 248 | + path: /home/circleci/nipype |
| 249 | + - attach_workspace: |
| 250 | + at: /tmp |
| 251 | + - run: *set_pr_number |
| 252 | + - run: *generate_dockerfiles |
| 253 | + - run: *modify_nipype_version |
| 254 | + - run: *get_base_image |
| 255 | + - run: *build_main_image_py36 |
| 256 | + - run: *_get_codecov |
| 257 | + - run: *_download_test_data |
| 258 | + - run: *prepare_working_directory |
| 259 | + - run: |
| 260 | + name: Run SPM DARTEL Level 1 pipeline (py36) |
| 261 | + no_output_timeout: 1h |
| 262 | + environment: *test_environment |
| 263 | + command: bash -ux /home/circleci/nipype/.circleci/test_py3_fmri_spm_dartel_multiproc_l1.sh |
| 264 | + - run: |
| 265 | + name: Run SPM DARTEL Level 2 pipeline (py36) |
| 266 | + no_output_timeout: 30m |
| 267 | + environment: *test_environment |
| 268 | + command: bash -ux /home/circleci/nipype/.circleci/test_py3_fmri_spm_dartel_multiproc_l2.sh |
| 269 | + - run: *_run_codecov_smoke |
| 270 | + - store_artifacts: *store_artifacts_kwds |
| 271 | + |
| 272 | + test_fmri_spm_nested_fsl_feeds: |
| 273 | + machine: *machine_kwds |
| 274 | + working_directory: /home/circleci/nipype |
| 275 | + steps: |
| 276 | + - checkout: |
| 277 | + path: /home/circleci/nipype |
| 278 | + - attach_workspace: |
| 279 | + at: /tmp |
| 280 | + - run: *set_pr_number |
| 281 | + - run: *generate_dockerfiles |
| 282 | + - run: *modify_nipype_version |
| 283 | + - run: *get_base_image |
| 284 | + - run: *build_main_image_py36 |
| 285 | + - run: *build_main_image_py27 |
| 286 | + - run: *_get_codecov |
| 287 | + - run: *_download_test_data |
| 288 | + - run: *prepare_working_directory |
| 289 | + - run: |
| 290 | + name: Run SPM Nested Level 1 pipeline (py36) |
| 291 | + no_output_timeout: 1h |
| 292 | + environment: *test_environment |
| 293 | + command: bash -ux /home/circleci/nipype/.circleci/test_py3_fmri_spm_nested_multiproc_l1.sh |
| 294 | + - run: |
| 295 | + name: Run SPM Nested Level 2 pipeline (py27) |
| 296 | + no_output_timeout: 30m |
| 297 | + environment: *test_environment |
| 298 | + command: bash -ux /home/circleci/nipype/.circleci/test_py2_fmri_spm_nested_multiproc_l2.sh |
| 299 | + - run: |
| 300 | + name: Run FSL FEEDS pipeline (py36) |
| 301 | + no_output_timeout: 40m |
| 302 | + environment: *test_environment |
| 303 | + command: bash -ux /home/circleci/nipype/.circleci/test_py3_fmri_fsl_feeds_linear_l1.sh |
| 304 | + - run: *_run_codecov_smoke |
| 305 | + - store_artifacts: *store_artifacts_kwds |
| 306 | + |
| 307 | + deploy: |
| 308 | + docker: |
| 309 | + - image: docker:17.10.0-ce-git |
| 310 | + steps: |
| 311 | + - setup_remote_docker |
| 312 | + - attach_workspace: |
| 313 | + at: /tmp |
| 314 | + - run: |
| 315 | + name: Load saved Docker images. |
| 316 | + no_output_timeout: 60m |
| 317 | + command: | |
| 318 | + docker load < /tmp/docker/nipype-base-latest-py36-py27.tar.gz |
| 319 | + - run: |
| 320 | + name: Push to DockerHub |
| 321 | + no_output_timeout: 120m |
| 322 | + command: | |
| 323 | + echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin |
| 324 | + docker push nipype/nipype:base |
| 325 | + docker push nipype/nipype:latest |
| 326 | + docker push nipype/nipype:py36 |
| 327 | + docker push nipype/nipype:py27 |
| 328 | + - run: |
| 329 | + name: Move pruned Dockerfile to /tmp/docker/cache directory |
| 330 | + command: | |
| 331 | + mkdir -p /tmp/docker/cache/ |
| 332 | + mv /tmp/docker/Dockerfile.base-pruned /tmp/docker/cache/Dockerfile.base-pruned |
| 333 | + - save_cache: |
| 334 | + paths: |
| 335 | + - /tmp/docker/cache/Dockerfile.base-pruned |
| 336 | + key: dockerfile-cache-v1-{{ .Branch }}-{{ checksum "/tmp/docker/cache/Dockerfile.base-pruned" }} |
| 337 | + |
| 338 | + |
| 339 | +workflows: |
| 340 | + version: 2 |
| 341 | + build_test_deploy: |
| 342 | + jobs: |
| 343 | + - compare_base_dockerfiles |
| 344 | + - test_pytest: |
| 345 | + requires: |
| 346 | + - compare_base_dockerfiles |
| 347 | + - test_py3_fmri_fsl_spm: |
| 348 | + requires: |
| 349 | + - compare_base_dockerfiles |
| 350 | + - test_py3_fmri_spm_dartel_multiproc: |
| 351 | + requires: |
| 352 | + - compare_base_dockerfiles |
| 353 | + - test_fmri_spm_nested_fsl_feeds: |
| 354 | + requires: |
| 355 | + - compare_base_dockerfiles |
| 356 | + - deploy: |
| 357 | + filters: |
| 358 | + branches: |
| 359 | + only: master |
| 360 | + requires: |
| 361 | + - test_pytest |
| 362 | + - test_fmri_spm_nested_fsl_feeds |
| 363 | + - test_py3_fmri_fsl_spm |
| 364 | + - test_py3_fmri_spm_dartel_multiproc |
0 commit comments