Skip to content

Commit 4ffc349

Browse files
authored
Merge pull request #402 from effigies/mnt/modernize-build
MNT: Modernize Docker/GHA
2 parents dad5519 + cc4df84 commit 4ffc349

File tree

8 files changed

+248
-225
lines changed

8 files changed

+248
-225
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Set update schedule for GitHub Actions
2+
3+
version: 2
4+
updates:
5+
6+
- package-ecosystem: "github-actions"
7+
directory: "/"
8+
schedule:
9+
# Check for updates to GitHub Actions every week
10+
interval: "weekly"

.github/workflows/pythonpackage.yml

Lines changed: 88 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -18,85 +18,115 @@ permissions:
1818
contents: read
1919

2020
jobs:
21+
job_metadata:
22+
if: github.repository == 'nipreps/sdcflows'
23+
runs-on: ubuntu-latest
24+
outputs:
25+
commit_message: ${{ steps.get_commit_message.outputs.commit_message }}
26+
version: ${{ steps.show_version.outputs.version }}
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
- name: Print head git commit message
33+
id: get_commit_message
34+
run: |
35+
if [[ -z "$COMMIT_MSG" ]]; then
36+
COMMIT_MSG=$(git show -s --format=%s $REF)
37+
fi
38+
echo commit_message=$COMMIT_MSG | tee -a $GITHUB_OUTPUT
39+
env:
40+
COMMIT_MSG: ${{ github.event.head_commit.message }}
41+
REF: ${{ github.event.pull_request.head.sha }}
42+
- name: Detect version
43+
id: show_version
44+
run: |
45+
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
46+
VERSION=${GITHUB_REF##*/}
47+
else
48+
pip install setuptools_scm
49+
VERSION=$( python -m setuptools_scm )
50+
fi
51+
echo version=$VERSION | tee -a $GITHUB_OUTPUT
52+
2153
build:
54+
if: github.repository == 'nipreps/sdcflows'
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@v4
58+
with:
59+
fetch-depth: 0
60+
- name: Set up Python 3
61+
uses: actions/setup-python@v4
62+
with:
63+
python-version: 3
64+
- name: Display Python version
65+
run: python -c "import sys; print(sys.version)"
66+
- name: Build niworkflows
67+
run: pipx run build
68+
- name: Check distributions
69+
run: pipx run twine check dist/*
70+
- uses: actions/upload-artifact@v3
71+
with:
72+
name: dist
73+
path: dist/
74+
75+
test:
2276
if: "!startsWith(github.ref, 'refs/tags/') && !contains(github.event.head_commit.message, '[skip ci]')"
77+
needs: [build, job_metadata]
2378
runs-on: ubuntu-latest
2479
strategy:
2580
matrix:
26-
python-version: ["3.8", "3.9", "3.10"]
27-
pip: ["pip==21.2", "pip~=22.0"]
81+
python-version: ["3.8", "3.12"]
82+
install: [repo, sdist, wheel, editable]
83+
84+
env:
85+
INSTALL_TYPE: ${{ matrix.install }}
2886

2987
steps:
30-
- uses: actions/checkout@v3
31-
- name: Fetch all tags (for setuptools_scm to work)
32-
run: |
33-
/usr/bin/git -c protocol.version=2 fetch --tags --prune --unshallow origin
88+
- uses: actions/checkout@v4
89+
if: matrix.install == 'repo' || matrix.install == 'editable'
90+
with:
91+
fetch-depth: 0
3492
- name: Set up Python ${{ matrix.python-version }}
3593
uses: actions/setup-python@v4
3694
with:
3795
python-version: ${{ matrix.python-version }}
38-
- uses: actions/cache@v3
96+
- name: Fetch packages
97+
if: matrix.install == 'sdist' || matrix.install == 'wheel'
98+
uses: actions/download-artifact@v3
3999
with:
40-
path: $HOME/.cache/pip
41-
key: pip-cache-v1
42-
restore-keys: |
43-
pip-cache-
44-
- name: Build in confined environment and interpolate version
100+
name: dist
101+
path: dist/
102+
- name: Select archive
45103
run: |
46-
python -m venv /tmp/buildenv
47-
source /tmp/buildenv/bin/activate
48-
python -m pip install -U build "setuptools >= 45" wheel "setuptools_scm >= 6.2" \
49-
setuptools_scm_git_archive pip twine docutils
50-
51-
python -m build -s -w
52-
python -m twine check dist/sdcflows-*
53-
mv dist /tmp/package
54-
rm -rf sdcflows.egg-info/
55-
# Interpolate version
56-
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
57-
TAG=${GITHUB_REF##*/}
104+
if [ "$INSTALL_TYPE" = "sdist" ]; then
105+
ARCHIVE=$( ls dist/*.tar.gz )
106+
elif [ "$INSTALL_TYPE" = "wheel" ]; then
107+
ARCHIVE=$( ls dist/*.whl )
108+
elif [ "$INSTALL_TYPE" = "repo" ]; then
109+
ARCHIVE="."
110+
elif [ "$INSTALL_TYPE" = "editable" ]; then
111+
ARCHIVE="-e ."
58112
fi
59-
THISVERSION=$( python -m setuptools_scm )
60-
THISVERSION=${TAG:-$THISVERSION}
61-
echo "Expected VERSION: \"${THISVERSION}\""
62-
echo "THISVERSION=${THISVERSION}" >> $GITHUB_ENV
63-
- name: Install in confined environment [pip]
64-
run: |
65-
python -m venv /tmp/pip
66-
source /tmp/pip/bin/activate
67-
python -m pip install -U "setuptools >= 45" "setuptools_scm >= 6.2" "${{ matrix.pip }}"
68-
python -m pip install .
69-
INSTALLED_VERSION=$(python -c 'import sdcflows as sdc; print(sdc.__version__, end="")')
70-
echo "VERSION: \"${THISVERSION}\""
71-
echo "INSTALLED: \"${INSTALLED_VERSION}\""
72-
test "${INSTALLED_VERSION}" = "${THISVERSION}"
73-
- name: Install in confined environment [sdist]
74-
run: |
75-
python -m venv /tmp/install_sdist
76-
source /tmp/install_sdist/bin/activate
77-
python -m pip install -U "setuptools >= 45" "${{ matrix.pip }}"
78-
python -m pip install /tmp/package/sdcflows*.tar.gz
79-
INSTALLED_VERSION=$(python -c 'import sdcflows as sdc; print(sdc.__version__, end="")')
80-
echo "VERSION: \"${THISVERSION}\""
81-
echo "INSTALLED: \"${INSTALLED_VERSION}\""
82-
test "${INSTALLED_VERSION}" = "${THISVERSION}"
83-
- name: Install in confined environment [wheel]
113+
echo "ARCHIVE=$ARCHIVE" | tee -a $GITHUB_ENV
114+
- name: Install package
115+
run: python -m pip install $ARCHIVE
116+
- name: Check version
84117
run: |
85-
python -m venv /tmp/install_wheel
86-
source /tmp/install_wheel/bin/activate
87-
python -m pip install -U "setuptools >= 45" "${{ matrix.pip }}"
88-
python -m pip install /tmp/package/sdcflows*.whl
89-
INSTALLED_VERSION=$(python -c 'import sdcflows as sdc; print(sdc.__version__, end="")')
118+
INSTALLED_VERSION=$(python -c 'import sdcflows; print(sdcflows.__version__, end="")')
90119
echo "INSTALLED: \"${INSTALLED_VERSION}\""
91-
test "${INSTALLED_VERSION}" = "${THISVERSION}"
120+
test "${INSTALLED_VERSION}" = "${VERSION}"
121+
env:
122+
VERSION: ${{ needs.job_metadata.outputs.version }}
92123

93124
flake8:
94125
runs-on: ubuntu-latest
95126
steps:
96-
- uses: actions/checkout@v3
127+
- uses: actions/checkout@v4
97128
- name: Set up Python 3
98129
uses: actions/setup-python@v4
99130
with:
100131
python-version: 3
101-
- run: pip install flake8
102-
- run: flake8 sdcflows/
132+
- run: pipx run flake8 sdcflows/

.github/workflows/unittests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
strategy:
3636
max-parallel: 5
3737
matrix:
38-
python-version: ["3.8", "3.9", "3.10"]
38+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
3939
deps: ["requirements"]
4040
include:
4141
- python-version: "3.8"
@@ -108,8 +108,8 @@ jobs:
108108
python-${{ matrix.python-version }}-${{ env.CACHE_NUM }}
109109
- name: Install DataLad
110110
run: |
111-
conda install git-annex datalad pip
112-
pip install datalad-osf
111+
conda install git-annex=*=alldep* pip
112+
pip install datalad datalad-osf
113113
- name: Install fsl
114114
run: |
115115
conda install fsl-fugue fsl-topup

0 commit comments

Comments
 (0)