@@ -18,85 +18,115 @@ permissions:
18
18
contents : read
19
19
20
20
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
+
21
53
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 :
22
76
if : " !startsWith(github.ref, 'refs/tags/') && !contains(github.event.head_commit.message, '[skip ci]')"
77
+ needs : [build, job_metadata]
23
78
runs-on : ubuntu-latest
24
79
strategy :
25
80
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 }}
28
86
29
87
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
34
92
- name : Set up Python ${{ matrix.python-version }}
35
93
uses : actions/setup-python@v4
36
94
with :
37
95
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
39
99
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
45
103
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 ."
58
112
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
84
117
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="")')
90
119
echo "INSTALLED: \"${INSTALLED_VERSION}\""
91
- test "${INSTALLED_VERSION}" = "${THISVERSION}"
120
+ test "${INSTALLED_VERSION}" = "${VERSION}"
121
+ env :
122
+ VERSION : ${{ needs.job_metadata.outputs.version }}
92
123
93
124
flake8 :
94
125
runs-on : ubuntu-latest
95
126
steps :
96
- - uses : actions/checkout@v3
127
+ - uses : actions/checkout@v4
97
128
- name : Set up Python 3
98
129
uses : actions/setup-python@v4
99
130
with :
100
131
python-version : 3
101
- - run : pip install flake8
102
- - run : flake8 sdcflows/
132
+ - run : pipx run flake8 sdcflows/
0 commit comments