_machine_kwds: &machine_kwds image: ubuntu-2004:202107-02 _store_artifacts_kwds: &store_artifacts_kwds path: /home/circleci/work/tests _test_environment: &test_environment WORKDIR: /home/circleci/work DOCKER_IMAGE: "nipype/nipype" _set_pr_number: &set_pr_number name: Set PR number command: | echo 'export CIRCLE_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}"' >> $BASH_ENV source $BASH_ENV echo $CIRCLE_PR_NUMBER _generate_dockerfiles: &generate_dockerfiles name: Generate Dockerfiles command: | make gen-dockerfiles _modify_nipype_version: &modify_nipype_version name: Modify Nipype version if necessary command: | if [ "$CIRCLE_TAG" != "" ]; then sed -i -E "s/(__version__ = )'[A-Za-z0-9.-]+'/\1'$CIRCLE_TAG'/" nipype/info.py fi _get_base_image: &get_base_image name: Get base image (pull or build) no_output_timeout: 60m command: | source /tmp/docker/get_base_image.sh if [ "$GET_BASE" == "PULL" ]; then echo "Pulling base image ..." docker pull nipype/nipype:base elif [ "$GET_BASE" == "BUILD" ]; then tools/retry_cmd.sh -n 5 -s 15 \ docker build -t nipype/nipype:base - < docker/Dockerfile.base else echo "Error: method to get base image not understood" exit 1 fi _build_main_image_py38: &build_main_image_py38 name: Build main image (py38) no_output_timeout: 60m command: | tools/retry_cmd.sh -n 5 -s 15 \ docker build \ --rm=false \ --tag nipype/nipype:latest \ --tag nipype/nipype:py38 \ $(test -z "${CIRCLE_TAG}" || echo --tag nipype/nipype:"${CIRCLE_TAG}") \ --build-arg BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \ --build-arg VCS_REF="$(git rev-parse --short HEAD)" \ --build-arg VERSION="${CIRCLE_TAG}" /home/circleci/nipype _download_test_data: &_download_test_data name: Download test data no_output_timeout: 20m working_directory: /home/circleci/examples environment: OSF_NIPYPE_URL: "https://files.osf.io/v1/resources/nefdp/providers/osfstorage" command: | set -x export DATA_NIPYPE_TUTORIAL_URL="${OSF_NIPYPE_URL}/57f4739cb83f6901ed94bf21" if [[ ! -d nipype-tutorial ]]; then curl -sSL --retry 5 --connect-timeout 15 "$DATA_NIPYPE_TUTORIAL_URL" | tar xjv fi export DATA_NIPYPE_FSL_COURSE="${OSF_NIPYPE_URL}/57f472cf9ad5a101f977ecfe" if [[ ! -d nipype-fsl_course_data ]]; then curl -sSL --retry 5 --connect-timeout 15 "$DATA_NIPYPE_FSL_COURSE" | tar xzv fi export DATA_NIPYPE_FSL_FEEDS="${OSF_NIPYPE_URL}/57f473066c613b01f113e7af" if [[ ! -d feeds ]]; then curl -sSL --retry 5 --connect-timeout 15 "$DATA_NIPYPE_FSL_FEEDS" | tar xzv fi _prepare_working_directory: &prepare_working_directory name: Prepare working directory environment: *test_environment command: | mkdir -p "$WORKDIR" chmod -R 777 "$WORKDIR" _get_codecov: &_get_codecov name: Get codecov command: | pip install --no-cache-dir codecov _run_codecov_coverage: &_run_codecov_coverage name: Run codecov (coverage) environment: *test_environment command: | codecov --file $WORKDIR/tests/coverage*.xml --root "$HOME/nipype" --flags unittests -e CIRCLE_JOB _run_codecov_smoke: &_run_codecov_smoke name: Run codecov (smoke tests) environment: *test_environment command: | codecov --file $WORKDIR/tests/smoketest*.xml --root "$HOME/nipype" --flags smoketests -e CIRCLE_JOB version: 2 jobs: compare_base_dockerfiles: docker: - image: cimg/base:2022.04 steps: - checkout: path: /home/circleci/nipype - setup_remote_docker - run: name: Generate and prune base Dockerfile in preparation for cache check working_directory: /home/circleci/nipype/docker command: | mkdir -p /tmp/docker bash ./generate_dockerfiles.sh -b # Use the sha256 sum of the pruned Dockerfile as the cache key. bash prune_dockerfile.sh Dockerfile.base > /tmp/docker/Dockerfile.base-pruned - restore_cache: key: dockerfile-cache-v1-master-{{ checksum "/tmp/docker/Dockerfile.base-pruned" }} - run: name: Determine how to get base image command: | if [ -f /tmp/docker/cache/Dockerfile.base-pruned ]; then echo "Cache found. Will pull base image." echo 'export GET_BASE=PULL' > /tmp/docker/get_base_image.sh else echo "Cache not found. Will build base image." echo 'export GET_BASE=BUILD' > /tmp/docker/get_base_image.sh fi - persist_to_workspace: root: /tmp paths: - docker/Dockerfile.base-pruned - docker/get_base_image.sh get_test_data: machine: *machine_kwds working_directory: /home/circleci/nipype steps: - restore_cache: keys: - data-v0-{{ .Branch }}-{{ .Revision }} - data-v0--{{ .Revision }} - data-v0-{{ .Branch }}- - data-v0-master- - data-v0- - run: *_download_test_data - save_cache: key: data-v0-{{ .Branch }}-{{ .Revision }} paths: - /home/circleci/examples test_pytest: machine: *machine_kwds working_directory: /home/circleci/nipype steps: - checkout: path: /home/circleci/nipype - attach_workspace: at: /tmp - restore_cache: keys: - data-v0-{{ .Branch }}-{{ .Revision }} - run: *set_pr_number - run: *generate_dockerfiles - run: *modify_nipype_version - run: *get_base_image - run: *build_main_image_py38 - run: *_get_codecov - run: *prepare_working_directory - run: name: Run pytests no_output_timeout: 30m environment: *test_environment command: bash -ux /home/circleci/nipype/.circleci/test_pytest.sh - run: *_run_codecov_coverage - store_artifacts: *store_artifacts_kwds - store_test_results: *store_artifacts_kwds - run: name: Save Docker images to workspace if on master no_output_timeout: 60m command: | if [ "$CIRCLE_BRANCH" = "master" -a -z "$CIRCLE_PULL_REQUEST" ]; then docker save nipype/nipype:base \ nipype/nipype:latest \ nipype/nipype:py38 | gzip -1 > /tmp/docker/nipype-base-latest-py38.tar.gz \ && du -h /tmp/docker/nipype-base-latest-py38.tar.gz fi - persist_to_workspace: root: /tmp paths: - docker deploy_dockerhub: docker: - image: docker:17.10.0-ce-git steps: - setup_remote_docker - attach_workspace: at: /tmp - run: name: Load saved Docker images. no_output_timeout: 60m command: | docker load < /tmp/docker/nipype-base-latest-py38.tar.gz - run: name: Push to DockerHub no_output_timeout: 120m command: | echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin docker push nipype/nipype:base docker push nipype/nipype:latest docker push nipype/nipype:py38 test -z "${CIRCLE_TAG}" || docker push nipype/nipype:"${CIRCLE_TAG}" - run: name: Move pruned Dockerfile to /tmp/docker/cache directory command: | mkdir -p /tmp/docker/cache/ mv /tmp/docker/Dockerfile.base-pruned /tmp/docker/cache/Dockerfile.base-pruned - save_cache: paths: - /tmp/docker/cache/Dockerfile.base-pruned key: dockerfile-cache-v1-{{ .Branch }}-{{ checksum "/tmp/docker/cache/Dockerfile.base-pruned" }} update_feedstock: machine: *machine_kwds working_directory: /home/circleci/nipype steps: - checkout: path: /home/circleci/nipype - run: name: Install hub command: | curl -sSL https://github.com/github/hub/releases/download/v2.14.2/hub-linux-amd64-2.14.2.tgz | \ tar zxv -C /tmp sudo /tmp/hub-linux-amd64-2.14.2/install - run: name: Expand SSH Key command: | (echo "-----BEGIN OPENSSH PRIVATE KEY-----"; echo $GITHUB_ED25519 | fold -w 71; echo "-----END OPENSSH PRIVATE KEY-----") > ~/.ssh/id_ed25519 chmod go-rwx ~/.ssh/id_ed25519 ssh-keygen -y -f ~/.ssh/id_ed25519 > ~/.ssh/id_ed25519.pub - run: name: Set git/hub configuration command: | git config --global user.name "nipybot" git config --global user.email "nipybot@gmail.com" git config --global hub.protocol ssh - run: name: Update feedstock command: | ssh-add -D ssh-add ~/.ssh/id_ed25519 /home/circleci/nipype/tools/feedstock.sh workflows: version: 2 build_test_deploy: jobs: []