From 4d68b2cc77fdb4e381f38d30e87b567a7bdbf45f Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Fri, 13 Sep 2024 10:23:31 +0200 Subject: [PATCH] maint: update circleci config --- .circleci/config.yml | 211 ++++++++++++++++++++++--------------------- pyproject.toml | 5 +- 2 files changed, 110 insertions(+), 106 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 135a2d05..9ae540a9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,44 +1,69 @@ -version: 2 +version: 2.1 +orbs: + docker: circleci/docker@2.4.0 + codecov: codecov/codecov@4.1.0 + python: circleci/python@2.1.1 + jobs: - tests: - docker: - - image: cimg/python:3.11 - auth: - username: $DOCKER_USER - password: $DOCKER_PAT - working_directory: /tmp/tests - environment: - - OSF_MIRROR_PATH: /tmp/data/templateflow - steps: - - checkout: - path: /tmp/src/templateflow + build: + executor: + name: python/default + tag: '3.12' + steps: + - checkout + - python/install-packages: + pip-dependency-file: '' + args: 'build wheel twine' + pkg-manager: pip + cache-version: build-v1 - run: - name: Generate requirements.txt command: | - python /tmp/src/templateflow/.maint/update_requirements.py + python -m build + python -m twine check dist/* + name: Test packaging + - persist_to_workspace: + root: ~/project + paths: + - . + + deploy_pypi: + executor: + name: python/default + tag: '3.12' + + steps: + - attach_workspace: + at: ~/project + + - python/install-packages: + args: twine + pkg-manager: pip - - restore_cache: - keys: - - deps-v11-{{ checksum "/tmp/src/templateflow/dev-requirements.txt"}}-{{ epoch }} - - deps-v11-{{ checksum "/tmp/src/templateflow/dev-requirements.txt"}}- - - deps-v11- - run: - name: Prepare environment - command: | - python -m venv /tmp/venv - source /tmp/venv/bin/activate - python -m pip install -U pip - python -m pip install -r /tmp/src/templateflow/dev-requirements.txt - python -m pip install -U "datalad ~= 0.19.0" - python -m pip install -U build hatch twine pkginfo codecov + command: python -m twine upload dist/* + name: Upload to Pypi + + tests: + executor: + name: python/default + tag: '3.12' + working_directory: /tmp/test + + environment: + - OSF_MIRROR_PATH: /tmp/data/templateflow + steps: + - restore_cache: + keys: + - annex-v1-{{ epoch }} + - annex-v1- - run: name: Install git and git-annex command: | if [[ ! -e "/tmp/cache/git-annex-standalone.tar.gz" ]]; then wget -O- http://neuro.debian.net/lists/focal.us-ca.full | sudo tee /etc/apt/sources.list.d/neurodebian.sources.list - sudo apt-key add /tmp/src/templateflow/.neurodebian/neurodebian.gpg + sudo apt-key add .neurodebian/neurodebian.gpg sudo apt-key adv --recv-keys --keyserver hkps://keys.openpgp.org 0xA5D32F012649A5A9 || true sudo apt update && sudo apt-get install -y --no-install-recommends git-annex-standalone mkdir -p /tmp/cache @@ -50,80 +75,76 @@ jobs: git config --global user.email "email@domain.com" - save_cache: - key: deps-v11-{{ checksum "/tmp/src/templateflow/dev-requirements.txt"}}-{{ epoch }} + key: annex-v1-{{ epoch }} paths: - "/tmp/cache" - - "/tmp/venv" + + - attach_workspace: + at: ~/project - run: - name: Test packaging command: | - source /tmp/venv/bin/activate - cd /tmp/src/templateflow - python -m build - python -m twine check dist/* + python ~/project/.maint/update_requirements.py + name: Generate requirements.txt + + - python/install-packages: + pip-dependency-file: ~/project/dev-requirements.txt + pkg-manager: pip + cache-version: v1 - run: name: Run tests (w/ DataLad) command: | - source /tmp/venv/bin/activate export TEMPLATEFLOW_USE_DATALAD=on - pytest --junit-xml=/tmp/tests/datalad.xml --cov templateflow --cov-report xml:/tmp/cov_api_dl.xml \ - --doctest-modules /tmp/src/templateflow/templateflow + python -m pytest \ + --junit-xml=/tmp/tests/datalad.xml --cov templateflow --cov-report xml:/tmp/cov_api_dl.xml \ + --doctest-modules ~/project - - run: - name: Submit api test coverage - command: | - source /tmp/venv/bin/activate - codecov --file /tmp/cov_api_dl.xml --root /tmp/src/templateflow \ - --flags api,datalad -e CIRCLE_JOB + - codecov/upload: + file: /tmp/cov_api_dl.xml + flags: api,datalad + cli_args: "-e CIRCLE_JOB" - run: name: Run tests (pulling from S3) command: | - source /tmp/venv/bin/activate export TEMPLATEFLOW_USE_DATALAD=off export TEMPLATEFLOW_HOME=$HOME/templateflow-s3 - pytest --junit-xml=/tmp/tests/s3.xml --cov templateflow --cov-report xml:/tmp/cov_api_s3.xml \ - --doctest-modules /tmp/src/templateflow/templateflow/api.py + python -m pytest \ + --junit-xml=/tmp/tests/s3.xml --cov templateflow --cov-report xml:/tmp/cov_api_s3.xml \ + --doctest-modules ~/project/api.py - - run: - name: Submit api test coverage - command: | - source /tmp/venv/bin/activate - codecov --file /tmp/cov_api_s3.xml --root /tmp/src/templateflow \ - --flags api,s3 -e CIRCLE_JOB + - codecov/upload: + file: /tmp/cov_api_s3.xml + flags: api,s3 + cli_args: "-e CIRCLE_JOB" - run: name: Run tests (w/ DataLad, bypassed via S3) command: | - source /tmp/venv/bin/activate export TEMPLATEFLOW_USE_DATALAD=off export TEMPLATEFLOW_HOME=$HOME/templateflow-clean datalad install -r -s https://github.com/templateflow/templateflow $TEMPLATEFLOW_HOME - pytest --junit-xml=/tmp/tests/dl+s3.xml --cov templateflow --cov-report xml:/tmp/cov_api_dl_s3.xml \ - --doctest-modules /tmp/src/templateflow/templateflow/api.py + python -m pytest \ + --junit-xml=/tmp/tests/dl+s3.xml --cov templateflow --cov-report xml:/tmp/cov_api_dl_s3.xml \ + --doctest-modules ~/project/api.py - - run: - name: Submit api test coverage - command: | - source /tmp/venv/bin/activate - codecov --file /tmp/cov_api_dl_s3.xml --root /tmp/src/templateflow \ - --flags api,dls3 -e CIRCLE_JOB + - codecov/upload: + file: /tmp/cov_api_dl_s3.xml + flags: api,dls3 + cli_args: "-e CIRCLE_JOB" - run: name: Run tests (config, parameterized TEMPLATEFLOW_USE_DATALAD) command: | - source /tmp/venv/bin/activate - pytest --junit-xml=/tmp/tests/conftests.xml --cov templateflow --cov-report xml:/tmp/cov_config.xml \ - /tmp/src/templateflow/templateflow/conf/tests/test_conf.py + python -m pytest \ + --junit-xml=/tmp/tests/conftests.xml --cov templateflow --cov-report xml:/tmp/cov_config.xml \ + ~/project/conf/tests/test_conf.py - - run: - name: Submit config test coverage - command: | - source /tmp/venv/bin/activate - codecov --file /tmp/cov_config.xml --root /tmp/src/templateflow \ - --flags config -e CIRCLE_JOB + - codecov/upload: + file: /tmp/cov_config.xml + flags: config + cli_args: "-e CIRCLE_JOB" - store_test_results: path: /tmp/tests @@ -179,54 +200,38 @@ jobs: - store_artifacts: path: ~/html - deploy_pypi: - docker: - - image: cimg/python:3.9 - working_directory: /tmp/src/templateflow - steps: - - attach_workspace: - at: /tmp - - - checkout: - path: /tmp/src/templateflow - - - run: - name: Generate requirements.txt - command: | - python /tmp/src/templateflow/.maint/update_requirements.py - - - restore_cache: - keys: - - deps-v11-{{ checksum "/tmp/src/templateflow/dev-requirements.txt"}}-{{ epoch }} - - deps-v11-{{ checksum "/tmp/src/templateflow/dev-requirements.txt"}}- - - deps-v11- - - - run: - name: Deploy to PyPi - command: | - source /tmp/venv/bin/activate - python -m pip install build -U twine pkginfo - python -m build - python -m twine check dist/* - python -m twine upload dist/* - workflows: version: 2 build_test_deploy: jobs: + - build: + context: + - nipreps-common + filters: + branches: + ignore: + - /docs?\/.*/ + tags: + only: /.*/ + - tests: context: - nipreps-common + requires: + - build filters: branches: ignore: - /docs?\/.*/ tags: only: /.*/ + - deploy_pypi: context: - nipreps-common requires: + - build + - tests - build_docs filters: branches: diff --git a/pyproject.toml b/pyproject.toml index 507d5146..3b73f2c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,11 +39,10 @@ Documentation = "https://www.templateflow.org/python-client/" test = [ "pytest", "pytest-xdist", - "pytest-cov == 2.5.1", - "coverage", + "pytest-cov", ] datalad = [ - "datalad ~= 0.19.0" + "datalad ~= 1.0.0" ] doc = [ "nbsphinx",