Skip to content

Commit f71a0eb

Browse files
committed
CI: Install package across Python versions and run pytest
1 parent 03d6328 commit f71a0eb

File tree

1 file changed

+59
-51
lines changed

1 file changed

+59
-51
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 59 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -14,77 +14,85 @@ jobs:
1414
build:
1515
if: "!contains(github.event.head_commit.message, '[skip ci]')"
1616
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
python-version: ["3.10"]
20+
steps:
21+
- uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 0
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v3
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
- name: Display Python version
29+
run: python -c "import sys; print(sys.version)"
30+
- name: Check python version and install build
31+
run: |
32+
python --version
33+
python -m pip install -U build twine
34+
- name: Build niworkflows
35+
run: python -m build
36+
- name: Check distributions
37+
run: twine check dist/*
38+
- uses: actions/upload-artifact@v3
39+
with:
40+
name: dist
41+
path: dist/
42+
43+
test:
44+
needs: [build]
45+
runs-on: ubuntu-latest
1746
strategy:
1847
matrix:
1948
python-version: [3.7, 3.8, 3.9]
49+
install: [sdist, wheel, repo, editable]
50+
env:
51+
INSTALL_TYPE: ${{ matrix.install }}
2052

2153
steps:
54+
- uses: actions/checkout@v3
55+
with:
56+
fetch-depth: 0
2257
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v2
58+
uses: actions/setup-python@v3
2459
with:
2560
python-version: ${{ matrix.python-version }}
26-
- uses: actions/checkout@v2
61+
- name: Fetch packages
62+
uses: actions/download-artifact@v3
2763
with:
28-
ssh-key: "${{ secrets.NIPREPS_DEPLOY }}"
29-
fetch-depth: 0
30-
- name: Build in confined, updated environment and interpolate version
64+
name: dist
65+
path: dist/
66+
- name: Select archive
67+
run: |
68+
if [ "$INSTALL_TYPE" = "sdist" ]; then
69+
ARCHIVE=$( ls dist/*.tar.gz )
70+
elif [ "$INSTALL_TYPE" = "wheel" ]; then
71+
ARCHIVE=$( ls dist/*.whl )
72+
elif [ "$INSTALL_TYPE" = "repo" ]; then
73+
ARCHIVE="."
74+
elif [ "$INSTALL_TYPE" = "editable" ]; then
75+
ARCHIVE="-e ."
76+
fi
77+
echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
78+
- name: Install package
79+
run: python -m pip install $ARCHIVE
80+
- name: Check version
3181
run: |
32-
python -m venv /tmp/buildenv
33-
source /tmp/buildenv/bin/activate
34-
python -m pip install -U setuptools pip wheel twine docutils
35-
python setup.py sdist bdist_wheel
36-
python -m twine check dist/niworkflows*
37-
3882
# Interpolate version
3983
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
4084
TAG=${GITHUB_REF##*/}
4185
fi
4286
THISVERSION=$( python get_version.py )
4387
THISVERSION=${TAG:-$THISVERSION}
44-
echo "Expected VERSION: \"${THISVERSION}\""
45-
echo "THISVERSION=${THISVERSION}" >> ${GITHUB_ENV}
46-
47-
- name: Install in confined environment [sdist]
48-
run: |
49-
python -m venv /tmp/install_sdist
50-
source /tmp/install_sdist/bin/activate
51-
python -m pip install --upgrade pip wheel
52-
python -m pip install dist/niworkflows*.tar.gz
5388
INSTALLED_VERSION=$(python -c 'import niworkflows; print(niworkflows.__version__, end="")')
5489
echo "VERSION: \"${THISVERSION}\""
5590
echo "INSTALLED: \"${INSTALLED_VERSION}\""
5691
test "${INSTALLED_VERSION}" = "${THISVERSION}"
57-
58-
- name: Install in confined environment [wheel]
59-
run: |
60-
python -m venv /tmp/install_wheel
61-
source /tmp/install_wheel/bin/activate
62-
python -m pip install --upgrade pip wheel
63-
python -m pip install dist/niworkflows*.whl
64-
INSTALLED_VERSION=$(python -c 'import niworkflows; print(niworkflows.__version__, end="")')
65-
echo "INSTALLED: \"${INSTALLED_VERSION}\""
66-
test "${INSTALLED_VERSION}" = "${THISVERSION}"
67-
68-
- name: Install in confined environment [pip install .]
69-
run: |
70-
python -m venv /tmp/setup_install
71-
source /tmp/setup_install/bin/activate
72-
python -m pip install --upgrade pip wheel
73-
python -m pip install .
74-
INSTALLED_VERSION=$(python -c 'import niworkflows; print(niworkflows.__version__, end="")')
75-
echo "INSTALLED: \"${INSTALLED_VERSION}\""
76-
test "${INSTALLED_VERSION}" = "${THISVERSION}"
77-
78-
- name: Install in confined environment [pip install -e .]
79-
run: |
80-
python -m venv /tmp/setup_develop
81-
source /tmp/setup_develop/bin/activate
82-
python -m pip install pip
83-
python -m pip install --upgrade pip wheel
84-
python -m pip install -e .
85-
INSTALLED_VERSION=$(python -c 'import niworkflows; print(niworkflows.__version__, end="")')
86-
echo "INSTALLED: \"${INSTALLED_VERSION}\""
87-
test "${INSTALLED_VERSION}" = "${THISVERSION}"
92+
- name: Install test dependencies
93+
run: python -m pip install "niworkflows[tests]"
94+
- name: Run tests
95+
run: pytest -sv --doctest-modules --cov niworkflows niworkflows
8896

8997
flake8:
9098
if: "!contains(github.event.head_commit.message, '[skip ci]')"

0 commit comments

Comments
 (0)