From d34b63f13c0b224584808e996a4f5f8b36a266eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Wed, 25 Sep 2024 21:11:19 -0400 Subject: [PATCH] ENH: Transition CI to GHA Transition continuous integration testing from CircleCI to GitHub Actions. Change the status badge accordingly in the `README` file. Use tox to automate and standardize testing. Make the `pyproject.toml` concurrency be a list. Avoids: ``` ValueError: Option [tool.coverage.run]concurrency is not a list: 'multiprocessing' ``` raised for example in https://github.com/nipreps/eddymotion/actions/runs/11043769196/job/30678593703?pr=229#step:7:57 Change mention to CircleCI in test file comment to GHA. --- .circleci/config.yml | 109 ------------------------------------- .github/workflows/test.yml | 71 ++++++++++++++++++++++++ README.rst | 4 +- pyproject.toml | 2 +- test/test_main.py | 2 +- tox.ini | 85 +++++++++++++++++++++++++++++ 6 files changed, 160 insertions(+), 113 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/test.yml create mode 100644 tox.ini diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index a55666f4..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,109 +0,0 @@ -version: 2.1 -orbs: - docker: circleci/docker@1.6.0 - -jobs: - tests: - docker: # executor type - - image: nipreps/miniconda:py39_2403.0 - auth: - username: $DOCKER_USER - password: $DOCKER_PAT - - resource_class: xlarge - - environment: - TEST_DATA_HOME: "/tmp/tests-data" - - working_directory: /tmp/tests - steps: - - checkout: - path: /tmp/src/eddymotion - - - restore_cache: - keys: - - micromamba-v1-{{ .Branch }}-{{ .Revision }} - - micromamba-v1--{{ .Revision }} - - micromamba-v1-{{ .Branch }}- - - micromamba-v1-main- - - micromamba-v1- - - - run: - name: Install ANTs - command: | - eval "$(micromamba shell hook --shell bash)" - micromamba activate - micromamba shell init --shell bash --root-prefix=/tmp/micromamba - micromamba install -y -c conda-forge "ants=2.5" - - - save_cache: - key: micromamba-v1-{{ .Branch }}-{{ .Revision }} - paths: - - /tmp/micromamba - - - run: - name: Configure git (pacify datalad) - command: | - git config --global user.name "First Last" - git config --global user.email "email@domain.com" - - - restore_cache: - keys: - - data-v1-{{ .Branch }}-{{ .Revision }} - - data-v1--{{ .Revision }} - - data-v1-{{ .Branch }}- - - data-v1-main- - - data-v1- - - run: - name: Pull down test data - command: | - if [[ ! -d "${TEST_DATA_HOME}" ]]; then - datalad install -rg --source=https://gin.g-node.org/nipreps-data/tests-eddymotion.git ${TEST_DATA_HOME} - else - cd ${TEST_DATA_HOME} - datalad update --merge -r . - datalad get -r -J4 * - fi - - - save_cache: - key: data-v1-{{ .Branch }}-{{ .Revision }} - paths: - - /tmp/tests-data - - - run: - name: Initiate versioning - command: | - micromamba run -n base python -m pip install -U build hatch hatchling pip twine docutils - micromamba run -n base python -m pip install /tmp/src/eddymotion[all] - - - run: - name: Run tests - command: | - micromamba run -n base pytest -n auto --doctest-modules /tmp/src/eddymotion/src /tmp/src/eddymotion/test - -workflows: - version: 2 - build_test_deploy: - jobs: - - tests: - context: - - nipreps-common - filters: - branches: - ignore: - - /docs?\/.*/ - tags: - only: /.*/ - - nightly: - triggers: - - schedule: - cron: "0 10 * * *" - filters: - branches: - only: - - main - jobs: - - tests: - context: - - nipreps-common diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..dc8966d6 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,71 @@ +name: Tests + +on: + push: + branches: + - main + - maint/* + pull_request: + branches: + - main + - maint/* + # Allow job to be triggered manually from GitHub interface + workflow_dispatch: + +defaults: + run: + shell: bash + +# Force tox and pytest to use color +env: + FORCE_COLOR: true + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + stable: + # Check each OS, all supported Python, minimum versions and latest releases + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ['ubuntu-latest'] + python-version: ['3.10', '3.11', '3.12'] + dependencies: ['full', 'pre'] + include: + - os: ubuntu-latest + python-version: '3.10' + dependencies: 'min' + + env: + DEPENDS: ${{ matrix.dependencies }} + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + allow-prereleases: true + - name: Display Python version + run: python -c "import sys; print(sys.version)" + - name: Install tox + run: | + python -m pip install --upgrade pip + python -m pip install tox tox-gh-actions + - name: Show tox config + run: tox c + - name: Run tox + run: tox -v --exit-and-dump-after 1200 + - uses: codecov/codecov-action@v4 + if: ${{ always() }} + with: + files: cov.xml + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/README.rst b/README.rst index fcc590c4..e22ebc66 100644 --- a/README.rst +++ b/README.rst @@ -14,8 +14,8 @@ :target: https://pypi.python.org/pypi/eddymotion/ :alt: Latest Version -.. image:: https://circleci.com/gh/nipreps/eddymotion/tree/main.svg?style=shield - :target: https://circleci.com/gh/nipreps/eddymotion/tree/main +.. image:: https://github.com/nipreps/eddymotion/actions/workflows/test.yml/badge.svg + :target: https://github.com/nipreps/eddymotion/actions/workflows/test.yml :alt: Testing .. image:: https://github.com/nipreps/eddymotion/actions/workflows/pages/pages-build-deployment/badge.svg diff --git a/pyproject.toml b/pyproject.toml index d4181d90..b8c95e5b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -171,7 +171,7 @@ filterwarnings = ["ignore::DeprecationWarning"] [tool.coverage.run] branch = true -concurrency = 'multiprocessing' +concurrency = ['multiprocessing'] omit = [ '*/tests/*', '*/__init__.py', diff --git a/test/test_main.py b/test/test_main.py index daffe19a..8531a3ff 100644 --- a/test/test_main.py +++ b/test/test_main.py @@ -66,4 +66,4 @@ def test_main(tmp_path, datadir): ) # assert Path(output_dir).joinpath("dwi.h5").exists() # Empty - # Also, call python -m eddymotion or eddymotion from CircleCI ?? + # Also, call python -m eddymotion or eddymotion from GHA ?? diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..142559f9 --- /dev/null +++ b/tox.ini @@ -0,0 +1,85 @@ +[tox] +requires = + tox>=4 +envlist = + py3{10,11,12}-{full,pre} + py310-min +skip_missing_interpreters = true + +# Configuration that allows us to split tests across GitHub runners effectively +[gh-actions] +python = + 3.10: py310 + 3.11: py311 + 3.12: py312 + +[gh-actions:env] +DEPENDS = + min: min + full: full + pre: pre + +[testenv] +description = Pytest with coverage +labels = test +pip_pre = + pre: true +pass_env = + # getpass.getuser() sources for Windows: + LOGNAME + USER + LNAME + USERNAME + # Pass user color preferences through + PY_COLORS + FORCE_COLOR + NO_COLOR + CLICOLOR + CLICOLOR_FORCE +extras = test +deps = + min: nipype ==1.8.5 + min: pybids ==0.15.6 +commands = + pytest --doctest-modules --cov eddymotion --cov-report xml \ + --junitxml=test-results.xml -v src/eddymotion {posargs} + +[testenv:docs] +description = Build documentation site +labels = docs +allowlist_externals = make +extras = doc +commands = + make -C doc html + +[testenv:spellcheck] +description = Check spelling +labels = check +deps = + codespell[toml] +skip_install = true +commands = + codespell . {posargs} + +[testenv:build{,-strict}] +labels = + check + pre-release +deps = + build + twine +skip_install = true +set_env = + build-strict: PYTHONWARNINGS=error +commands = + python -m build + python -m twine check dist/* + +[testenv:publish] +depends = build +labels = release +deps = + twine +skip_install = true +commands = + python -m twine upload dist/*