-
Notifications
You must be signed in to change notification settings - Fork 19
157 lines (145 loc) · 4.41 KB
/
build_test_deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Build-Test-Deploy
on:
push:
branches:
- main
- maint/*
tags:
- '*'
pull_request:
branches:
- main
- maint/*
schedule:
# 8am EST / 9am EDT Mondays
- cron: '0 13 * * 1'
workflow_dispatch:
defaults:
run:
shell: bash
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
if: |
github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
|| ! contains(github.event.head_commit.message, '[skip ci]')
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install build dependencies
run: pip install --upgrade pip build twine
- name: Build sdist and wheel
run: python -m build -s -w
- name: Check distributions
run: twine check dist/*
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
test:
needs: [build]
runs-on: ${{ matrix.os }}
strategy:
matrix:
#os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
os: ['ubuntu-latest']
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']
architecture: ['x64', 'x86']
package: ['.', 'dist/*.whl', 'dist/*.tar.gz']
exclude:
# 32-bit is a Windows-only consideration
- os: ubuntu-latest
architecture: x86
- os: macos-latest
architecture: x86
# Only run newest on Windows/Mac
- os: windows-latest
python-version: 3.8
- os: windows-latest
python-version: 3.9
- os: macos-latest
python-version: 3.8
- os: macos-latest
python-version: 3.9
# Skip 32-bit Windows with Python 3.10 (see #42)
- os: windows-latest
architecture: x86
python-version: 3.10
env:
PACKAGE: ${{ matrix.package }}
TEMPLATEFLOW_HOME: /tmp/templateflow
steps:
- uses: actions/checkout@v4
- name: Fetch packages
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- uses: actions/cache@v4
with:
path: /var/lib/apt
key: apt-cache-v0
restore-keys: |
apt-cache-v0
- name: Install tex
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends dvipng texlive texlive-latex-extra cm-super
- name: Install package
run: pip install $PACKAGE
- name: Verify installation
run: python -c "import nireports; print(nireports.__version__)"
- name: Install test dependencies
run: pip install .[test]
- name: Restore cached templateflow
id: tf-cache-restore
uses: actions/cache/restore@v4
with:
path: /tmp/templateflow
key: templateflow-v1
- name: Fetch templates
run: |
python -c "from templateflow.api import get; get('Fischer344', desc=None, suffix='T2w')"
python -c "from templateflow.api import get; get('MNI152NLin6Asym', resolution=2, desc='LR', suffix='T1w')"
- name: Save templateflow cache
id: tf-cache-save
uses: actions/cache/save@v4
with:
path: /tmp/templateflow
key: ${{ steps.tf-cache-restore.outputs.cache-primary-key }}
- name: Run tests
run: pytest --cov nireports nireports
- uses: codecov/codecov-action@v4
if: ${{ always() }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
deploy:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Fetch packages
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}