Skip to content

Commit 55110d3

Browse files
committed
chore(ci): Add build/test/deploy workflow
1 parent a32dfff commit 55110d3

File tree

1 file changed

+215
-0
lines changed

1 file changed

+215
-0
lines changed
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
name: Build-Test-Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
- maint/*
9+
tags:
10+
- '*'
11+
pull_request:
12+
branches:
13+
- main
14+
- master
15+
- maint/*
16+
schedule:
17+
# 8am EST / 9am EDT Mondays
18+
- cron: '0 13 * * 1'
19+
workflow_dispatch:
20+
21+
defaults:
22+
run:
23+
shell: bash
24+
25+
concurrency:
26+
group: ${{ github.workflow }}-${{ github.ref }}
27+
cancel-in-progress: true
28+
29+
permissions:
30+
contents: read
31+
32+
env:
33+
# Force tox and pytest to use color
34+
FORCE_COLOR: true
35+
TEMPLATEFLOW_HOME: /tmp/templateflow
36+
37+
jobs:
38+
build:
39+
name: Build & verify package
40+
runs-on: ubuntu-latest
41+
permissions:
42+
attestations: write
43+
id-token: write
44+
steps:
45+
- uses: actions/checkout@v4
46+
with:
47+
fetch-depth: 0
48+
persist-credentials: false
49+
- uses: hynek/build-and-inspect-python-package@v2
50+
with:
51+
upload-name-suffix: -main
52+
attest-build-provenance-github: ${{ github.event_name != 'pull_request' }}
53+
- uses: hynek/build-and-inspect-python-package@v2
54+
with:
55+
path: wrapper
56+
upload-name-suffix: -wrapper
57+
attest-build-provenance-github: ${{ github.event_name != 'pull_request' }}
58+
59+
test:
60+
runs-on: ${{ matrix.os }}
61+
strategy:
62+
matrix:
63+
os: ['ubuntu-latest']
64+
python-version: ['3.10', '3.11', '3.12', '3.13']
65+
dependencies: [latest] # , pre]
66+
architecture: ['x64']
67+
include:
68+
# Test minimum dependencies on oldest supported Python
69+
- os: ubuntu-latest
70+
python-version: "3.10"
71+
dependencies: min
72+
exclude:
73+
# Do not test pre-releases for versions out of SPEC0
74+
- os: ubuntu-latest
75+
python-version: "3.10"
76+
dependencies: pre
77+
78+
env:
79+
DEPENDS: ${{ matrix.dependencies }}
80+
81+
steps:
82+
- uses: actions/checkout@v4
83+
with:
84+
persist-credentials: false
85+
- name: Install the latest version of uv
86+
uses: astral-sh/setup-uv@v3
87+
- name: Set up Python ${{ matrix.python-version }}
88+
uses: actions/setup-python@v5
89+
with:
90+
python-version: ${{ matrix.python-version }}
91+
architecture: ${{ matrix.architecture }}
92+
- name: Display Python version
93+
run: python -c "import sys; print(sys.version)"
94+
95+
- name: Restore cached templateflow
96+
id: tf-cache-restore
97+
uses: actions/cache@v4
98+
with:
99+
path: /tmp/templateflow
100+
key: templateflow-v0
101+
# Use the following to fall back to and build on v0 when bumping to v1
102+
# If the cache need to be cleared, remove this when bumping key version
103+
# restore-keys: |
104+
# templateflow-v0
105+
- name: Initialize templateflow
106+
if: steps.tf-cache-restore.outputs.cache-hit != 'true'
107+
run: |
108+
uvx templateflow update --no-overwrite
109+
110+
- name: Install tox
111+
run: |
112+
uv tool install tox --with=tox-uv --with=tox-gh-actions
113+
- name: Show tox config
114+
run: tox c
115+
- name: Run tox
116+
run: tox -v --exit-and-dump-after 1200
117+
- uses: codecov/codecov-action@v4
118+
with:
119+
token: ${{ secrets.CODECOV_TOKEN }}
120+
if: ${{ always() }}
121+
122+
test-packages:
123+
runs-on: ${{ matrix.os }}
124+
needs: [build]
125+
strategy:
126+
matrix:
127+
os: ['ubuntu-latest']
128+
python-version: ['3.12']
129+
130+
env:
131+
DEPENDS: ${{ matrix.dependencies }}
132+
133+
steps:
134+
- name: Download packages built by build-and-inspect-python-package
135+
uses: actions/download-artifact@v4
136+
with:
137+
pattern: Packages-*
138+
path: dist
139+
- run: ls -lR
140+
141+
- name: Install the latest version of uv
142+
uses: astral-sh/setup-uv@v3
143+
- name: Set up Python ${{ matrix.python-version }}
144+
uses: actions/setup-python@v5
145+
with:
146+
python-version: ${{ matrix.python-version }}
147+
- name: Restore cached templateflow
148+
id: tf-cache-restore
149+
uses: actions/cache@v4
150+
with:
151+
path: /tmp/templateflow
152+
key: templateflow-v0
153+
# Use the following to fall back to and build on v0 when bumping to v1
154+
# If the cache need to be cleared, remove this when bumping key version
155+
# restore-keys: |
156+
# templateflow-v0
157+
- name: Check wrapper version
158+
run: |
159+
echo n | uvx --from=$( ls dist/*/smriprep_docker*.whl ) smriprep-docker --version
160+
161+
- name: Unpack sdist
162+
run: |
163+
tar --strip-components=1 -xzf dist/*/smriprep-*.tar.gz
164+
165+
- name: Install tox
166+
run: |
167+
uv tool install tox --with=tox-uv --with=tox-gh-actions
168+
- name: Show tox config
169+
run: tox c
170+
- name: Run tox
171+
run: tox -v --exit-and-dump-after 1200
172+
- uses: codecov/codecov-action@v4
173+
with:
174+
token: ${{ secrets.CODECOV_TOKEN }}
175+
if: ${{ always() }}
176+
177+
publish:
178+
name: Publish released package to pypi.org
179+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
180+
runs-on: ubuntu-latest
181+
environment: PyPI
182+
needs: [test, test-packages]
183+
permissions:
184+
attestations: write
185+
id-token: write
186+
187+
steps:
188+
- name: Download packages built by build-and-inspect-python-package
189+
uses: actions/download-artifact@v4
190+
with:
191+
name: Packages
192+
path: dist
193+
194+
- name: Upload package to PyPI
195+
uses: pypa/gh-action-pypi-publish@release/v1
196+
197+
checks:
198+
runs-on: 'ubuntu-latest'
199+
continue-on-error: true
200+
strategy:
201+
matrix:
202+
check: ['style', 'spellcheck']
203+
204+
steps:
205+
- uses: actions/checkout@v4
206+
with:
207+
persist-credentials: false
208+
- name: Install the latest version of uv
209+
uses: astral-sh/setup-uv@v4
210+
- name: Install tox
211+
run: uv tool install tox --with=tox-uv
212+
- name: Show tox config
213+
run: tox c -e ${{ matrix.check }}
214+
- name: Run check
215+
run: tox -e ${{ matrix.check }}

0 commit comments

Comments
 (0)