Skip to content

CI: Build, test and deploy packages #1134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ jobs:
EXTRA_PIP_FLAGS: ${{ matrix.pip-flags }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
Expand All @@ -63,7 +63,7 @@ jobs:
run: tools/ci/submit_coverage.sh
if: ${{ always() }}
- name: Upload pytest test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }}
path: for_testing/test-results.xml
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ jobs:
EXTRA_PIP_FLAGS: ${{ matrix.pip-flags }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
Expand All @@ -84,7 +84,7 @@ jobs:
run: tools/ci/submit_coverage.sh
if: ${{ always() }}
- name: Upload pytest test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }}
path: for_testing/test-results.xml
Expand Down
98 changes: 73 additions & 25 deletions .github/workflows/stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:
branches:
- master
- maint/*
tags:
- "*"
pull_request:
branches:
- master
Expand All @@ -23,6 +25,59 @@ defaults:
shell: bash

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: 3
- run: pip install --upgrade build twine
- name: Build sdist and wheel
run: python -m build
- run: twine check dist/*
- name: Build git archive
run: git archive -v -o dist/nibabel-archive.tgz HEAD
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist/

test-package:
runs-on: ubuntu-latest
needs: [build]
strategy:
matrix:
package: ['wheel', 'sdist', 'archive']
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: dist/
- uses: actions/setup-python@v4
with:
python-version: 3
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Update pip
run: pip install --upgrade pip
- name: Install wheel
run: pip install dist/nibabel-*.whl
if: matrix.package == 'wheel'
- name: Install sdist
run: pip install dist/nibabel-*.tar.gz
if: matrix.package == 'sdist'
- name: Install archive
run: pip install dist/nibabel-archive.tgz
if: matrix.package == 'archive'
- run: python -c 'import nibabel; print(nibabel.__version__)'
- name: Install test extras
run: pip install nibabel[test]
- name: Run tests
run: pytest --doctest-modules --doctest-plus -v --pyargs nibabel

stable:
# Check each OS, all supported Python, minimum versions and latest releases
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -68,28 +123,6 @@ jobs:
check: skiptests
pip-flags: ''
depends: ''
# Check all installation methods
- os: ubuntu-latest
python-version: "3.10"
install: wheel
check: test
pip-flags: ''
depends: REQUIREMENTS
optional-depends: DEFAULT_OPT_DEPENDS
- os: ubuntu-latest
python-version: "3.10"
install: sdist
check: test
pip-flags: ''
depends: REQUIREMENTS
optional-depends: DEFAULT_OPT_DEPENDS
- os: ubuntu-latest
python-version: "3.10"
install: archive
check: test
pip-flags: ''
depends: REQUIREMENTS
optional-depends: DEFAULT_OPT_DEPENDS
exclude:
- os: ubuntu-latest
architecture: x86
Expand All @@ -103,12 +136,12 @@ jobs:
EXTRA_PIP_FLAGS: ${{ matrix.pip-flags }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
Expand All @@ -131,8 +164,23 @@ jobs:
run: tools/ci/submit_coverage.sh
if: ${{ always() }}
- name: Upload pytest test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }}
path: for_testing/test-results.xml
if: ${{ always() && matrix.check == 'test' }}

publish:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel just a little squeamish about directly pushing to PyPI on tagging, but it's really your call as release manager.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason that I want to do this is because with 4.0.0, there were tests that passed, then I tagged, and forgot to test on the tagged version before publishing. DeprecationWarnings mutated into ExpiredDeprecationErrors and we had a release that failed its own tests.

That said, it looks like I can create an environment that requires manual review before providing access to the PYPI token. Would that feel more comfortable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honesty - your call - you're doing the releases.

runs-on: ubuntu-latest
environment: "Package deployment"
needs: [stable, test-package]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}