-
Notifications
You must be signed in to change notification settings - Fork 11
187 lines (176 loc) · 5.21 KB
/
ci.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: CI
on:
pull_request:
push:
branches:
- main
- release/*
tags:
- v*.*.*
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
artifact_prefix: snaphu-py
jobs:
build-and-test:
strategy:
matrix:
include:
- label: Linux x86_64
runner: ubuntu-latest
- label: macOS x86_64
runner: macos-latest
- label: macOS arm64
runner: macos-14
fail-fast: false
name: Build & test (${{ matrix.label }})
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0, submodules: true }
- uses: actions/setup-python@v5
with: { python-version: ">=3.9" }
- run: pip install ".[raster,test]" -vv
- run: pytest -vv
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
min-reqs:
name: Build & test (minimum requirements)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0, submodules: true }
- uses: actions/setup-python@v5
with: { python-version: "3.9" }
- run: pip install -c ci/min-reqs.txt ".[raster,test]" -vv
- run: pytest -vv
no-optional-deps:
name: Build & test (no optional dependencies)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0, submodules: true }
- uses: actions/setup-python@v5
with: { python-version: ">=3.9" }
- run: pip install ".[test]" -vv
- run: pytest -vv
build-wheels:
if: github.event_name == 'push'
strategy:
matrix:
include:
- label: Linux x86_64
runner: ubuntu-latest
arch: x86_64
- label: macOS x86_64
runner: macos-latest
arch: x86_64
- label: macOS arm64
runner: macos-14
arch: arm64
fail-fast: false
name: Build, lint, & test wheels (${{ matrix.label }})
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0, submodules: true }
- uses: pypa/[email protected]
env:
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_TEST_REQUIRES: pytest>=6 pytest-cov>=3
CIBW_TEST_COMMAND: pytest {package}/test
- uses: actions/setup-python@v5
with: { python-version: ">=3.7" }
- run: |
pip install check-wheel-contents
check-wheel-contents ./wheelhouse/*.whl
- if: github.event_name == 'push'
uses: actions/upload-artifact@v4
with:
name: ${{ env.artifact_prefix }}-wheels-${{ matrix.runner }}-${{ matrix.arch }}
path: ./wheelhouse/*.whl
build-sdist:
name: Build & lint sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0, submodules: true }
- run: pipx run build --sdist
- run: pipx run twine check --strict dist/*
- if: github.event_name == 'push'
uses: actions/upload-artifact@v4
with:
name: ${{ env.artifact_prefix }}-sdist
path: dist/*.tar.gz
publish-to-testpypi:
if: github.event_name == 'push'
name: Publish to TestPyPI
needs: [build-wheels, build-sdist]
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/snaphu
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: ${{ env.artifact_prefix }}-*
path: dist/
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
create-release:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
name: Create a release
needs:
- build-and-test
- min-reqs
- no-optional-deps
- build-wheels
- build-sdist
- publish-to-testpypi
permissions:
contents: write
runs-on: ubuntu-latest
env:
name_and_tag: snaphu-py-${{ github.ref_name }}
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0, submodules: true }
- run: |
pipx run git-archive-all ${{ env.name_and_tag }}.zip
unzip -l ${{ env.name_and_tag }}.zip
- run: |
pipx run git-archive-all ${{ env.name_and_tag }}.tar.gz
tar -ztvf ${{ env.name_and_tag }}.tar.gz
- uses: softprops/action-gh-release@v2
with:
files: |
${{ env.name_and_tag }}.zip
${{ env.name_and_tag }}.tar.gz
generate_release_notes: true
publish-to-pypi:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
name: Publish to PyPI
needs:
- build-wheels
- build-sdist
- create-release
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/snaphu
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: ${{ env.artifact_prefix }}-*
path: dist/
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1