Skip to content

Commit 16bdd14

Browse files
authored
Merge pull request #1134 from nipy/ci/build-test-deploy
CI: Build, test and deploy packages
2 parents fd5c84b + bc8e0c7 commit 16bdd14

File tree

3 files changed

+79
-31
lines changed

3 files changed

+79
-31
lines changed

.github/workflows/misc.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ jobs:
3535
EXTRA_PIP_FLAGS: ${{ matrix.pip-flags }}
3636

3737
steps:
38-
- uses: actions/checkout@v2
38+
- uses: actions/checkout@v3
3939
with:
4040
submodules: recursive
4141
fetch-depth: 0
4242
- name: Set up Python ${{ matrix.python-version }}
43-
uses: actions/setup-python@v2
43+
uses: actions/setup-python@v4
4444
with:
4545
python-version: ${{ matrix.python-version }}
4646
architecture: ${{ matrix.architecture }}
@@ -63,7 +63,7 @@ jobs:
6363
run: tools/ci/submit_coverage.sh
6464
if: ${{ always() }}
6565
- name: Upload pytest test results
66-
uses: actions/upload-artifact@v2
66+
uses: actions/upload-artifact@v3
6767
with:
6868
name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }}
6969
path: for_testing/test-results.xml

.github/workflows/pre-release.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ jobs:
5656
EXTRA_PIP_FLAGS: ${{ matrix.pip-flags }}
5757

5858
steps:
59-
- uses: actions/checkout@v2
59+
- uses: actions/checkout@v3
6060
with:
6161
submodules: recursive
6262
fetch-depth: 0
6363
- name: Set up Python ${{ matrix.python-version }}
64-
uses: actions/setup-python@v2
64+
uses: actions/setup-python@v4
6565
with:
6666
python-version: ${{ matrix.python-version }}
6767
architecture: ${{ matrix.architecture }}
@@ -84,7 +84,7 @@ jobs:
8484
run: tools/ci/submit_coverage.sh
8585
if: ${{ always() }}
8686
- name: Upload pytest test results
87-
uses: actions/upload-artifact@v2
87+
uses: actions/upload-artifact@v3
8888
with:
8989
name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }}
9090
path: for_testing/test-results.xml

.github/workflows/stable.yml

+73-25
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ on:
1111
branches:
1212
- master
1313
- maint/*
14+
tags:
15+
- "*"
1416
pull_request:
1517
branches:
1618
- master
@@ -23,6 +25,59 @@ defaults:
2325
shell: bash
2426

2527
jobs:
28+
build:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v3
32+
with:
33+
fetch-depth: 0
34+
- uses: actions/setup-python@v4
35+
with:
36+
python-version: 3
37+
- run: pip install --upgrade build twine
38+
- name: Build sdist and wheel
39+
run: python -m build
40+
- run: twine check dist/*
41+
- name: Build git archive
42+
run: git archive -v -o dist/nibabel-archive.tgz HEAD
43+
- uses: actions/upload-artifact@v3
44+
with:
45+
name: dist
46+
path: dist/
47+
48+
test-package:
49+
runs-on: ubuntu-latest
50+
needs: [build]
51+
strategy:
52+
matrix:
53+
package: ['wheel', 'sdist', 'archive']
54+
steps:
55+
- uses: actions/download-artifact@v3
56+
with:
57+
name: dist
58+
path: dist/
59+
- uses: actions/setup-python@v4
60+
with:
61+
python-version: 3
62+
- name: Display Python version
63+
run: python -c "import sys; print(sys.version)"
64+
- name: Update pip
65+
run: pip install --upgrade pip
66+
- name: Install wheel
67+
run: pip install dist/nibabel-*.whl
68+
if: matrix.package == 'wheel'
69+
- name: Install sdist
70+
run: pip install dist/nibabel-*.tar.gz
71+
if: matrix.package == 'sdist'
72+
- name: Install archive
73+
run: pip install dist/nibabel-archive.tgz
74+
if: matrix.package == 'archive'
75+
- run: python -c 'import nibabel; print(nibabel.__version__)'
76+
- name: Install test extras
77+
run: pip install nibabel[test]
78+
- name: Run tests
79+
run: pytest --doctest-modules --doctest-plus -v --pyargs nibabel
80+
2681
stable:
2782
# Check each OS, all supported Python, minimum versions and latest releases
2883
runs-on: ${{ matrix.os }}
@@ -68,28 +123,6 @@ jobs:
68123
check: skiptests
69124
pip-flags: ''
70125
depends: ''
71-
# Check all installation methods
72-
- os: ubuntu-latest
73-
python-version: "3.10"
74-
install: wheel
75-
check: test
76-
pip-flags: ''
77-
depends: REQUIREMENTS
78-
optional-depends: DEFAULT_OPT_DEPENDS
79-
- os: ubuntu-latest
80-
python-version: "3.10"
81-
install: sdist
82-
check: test
83-
pip-flags: ''
84-
depends: REQUIREMENTS
85-
optional-depends: DEFAULT_OPT_DEPENDS
86-
- os: ubuntu-latest
87-
python-version: "3.10"
88-
install: archive
89-
check: test
90-
pip-flags: ''
91-
depends: REQUIREMENTS
92-
optional-depends: DEFAULT_OPT_DEPENDS
93126
exclude:
94127
- os: ubuntu-latest
95128
architecture: x86
@@ -103,12 +136,12 @@ jobs:
103136
EXTRA_PIP_FLAGS: ${{ matrix.pip-flags }}
104137

105138
steps:
106-
- uses: actions/checkout@v2
139+
- uses: actions/checkout@v3
107140
with:
108141
submodules: recursive
109142
fetch-depth: 0
110143
- name: Set up Python ${{ matrix.python-version }}
111-
uses: actions/setup-python@v2
144+
uses: actions/setup-python@v4
112145
with:
113146
python-version: ${{ matrix.python-version }}
114147
architecture: ${{ matrix.architecture }}
@@ -131,8 +164,23 @@ jobs:
131164
run: tools/ci/submit_coverage.sh
132165
if: ${{ always() }}
133166
- name: Upload pytest test results
134-
uses: actions/upload-artifact@v2
167+
uses: actions/upload-artifact@v3
135168
with:
136169
name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }}
137170
path: for_testing/test-results.xml
138171
if: ${{ always() && matrix.check == 'test' }}
172+
173+
publish:
174+
runs-on: ubuntu-latest
175+
environment: "Package deployment"
176+
needs: [stable, test-package]
177+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
178+
steps:
179+
- uses: actions/download-artifact@v3
180+
with:
181+
name: dist
182+
path: dist/
183+
- uses: pypa/gh-action-pypi-publish@release/v1
184+
with:
185+
user: __token__
186+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)