-
Notifications
You must be signed in to change notification settings - Fork 6
171 lines (144 loc) · 5.21 KB
/
Copy pathharp.yml
File metadata and controls
171 lines (144 loc) · 5.21 KB
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
name: harp
on:
pull_request:
push:
branches:
- main
release:
types: [published]
workflow_dispatch:
inputs:
publish-docs-website:
description: "Publish docs website to GitHub Pages?"
default: "false"
jobs:
# ---- Tests ----
tests:
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.11", "3.12", "3.13"]
fail-fast: false
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v8.3.2
with:
enable-cache: true
- name: Install python dependencies
run: uv sync --group dev --python ${{ matrix.python-version }}
- name: Run codespell
run: uv run codespell
- name: Run ruff format
run: uv run ruff format --check
- name: Run ruff check
run: uv run ruff check
- name: Run pyright
run: uv run pyright
- name: Run pytest
run: uv run pytest --cov harp
- name: Build
run: uv build --all-packages
# ---- Release build ----
build-release:
runs-on: ubuntu-latest
name: Build release distributions
needs: tests
if: github.event_name == 'release' && github.event.action == 'published'
permissions:
# gh release upload attaches the distributions to the release.
contents: write
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v8.3.2
with:
enable-cache: true
- name: Build
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.release.tag_name }}
run: uv build --all-packages
- name: Verify setuptools-scm applied the release tag
shell: bash
run: |
ls -1 dist/
if ls dist/*-0.0.0.tar.gz >/dev/null 2>&1; then
echo "::error::Built version 0.0.0, so setuptools-scm did not apply the tag. Check that every pyproject.toml still declares a tool.setuptools_scm table."
exit 1
fi
- name: Remove internal-only packages from dist
shell: bash
run: rm -f dist/harp_benchmarks-*
- name: Upload wheels as artifact
uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
- name: Upload release assets
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload --repo ${{ github.repository }} ${{ github.event.release.tag_name }} dist/* --clobber
# ---- Publish to PyPI ----
publish-to-pypi:
runs-on: ubuntu-latest
name: Publish to PyPI
needs: build-release
environment: pypi
permissions:
# uv publish exchanges this token with PyPI trusted publishing.
id-token: write
steps:
- name: Download wheels artifact
uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- uses: astral-sh/setup-uv@v8.3.2
with:
enable-cache: true
- name: Publish to PyPI
run: uv publish
# ---- Build docs ----
build-docs:
name: Build documentation
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v8.3.2
with:
enable-cache: true
- name: Install dependencies
run: uv sync --group docs
- name: Build documentation
run: uv run mkdocs build --strict
- name: Collect documentation website artifact
uses: actions/upload-pages-artifact@v5
with:
path: site/
# ---- Publish docs ----
publish-docs:
name: Publish documentation to GitHub Pages
runs-on: ubuntu-latest
needs: [build-docs, publish-to-pypi]
permissions:
# Both required by actions/deploy-pages.
pages: write
id-token: write
environment:
name: documentation-website
url: ${{ steps.publish.outputs.page_url }}
if: |
!cancelled() && !failure() && needs.build-docs.result == 'success'
&& (
(github.event_name == 'release' && !github.event.release.prerelease)
|| (github.event_name == 'workflow_dispatch' && github.event.inputs.publish-docs-website == 'true')
|| (github.event_name == 'push' && vars.CONTINUOUS_DOCUMENTATION)
)
steps:
- name: Publish to GitHub Pages
id: publish
uses: actions/deploy-pages@v5