-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (155 loc) · 4.63 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
name: CI
on:
push:
branches:
- main
- alpha
- beta
pull_request:
branches:
- main
- alpha
- beta
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
# Should run on every push and PR
test:
name: Test
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Cargo build
run: cargo build --workspace --verbose --locked
- name: Cargo test
run: cargo test --workspace --verbose
- name: Cargo fmt
run: cargo fmt --all --check
- name: Cargo clippy
run: cargo clippy --workspace --all-targets -- -D warnings
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Sync project
run: uv sync --locked --group ci
- name: Pytest
run: uv run pytest
- name: Ruff format
run: uv run ruff format --check
- name: Ruff lint
run: uv run ruff check --output-format=github
- name: Basedpyright
run: uv run basedpyright
- name: Stubtest
run: uv run task stubtest
- name: Check cargo dependencies
uses: EmbarkStudios/cargo-deny-action@v2
# Should run on every push and PR, but only run semantic-release on push
release:
name: Run semantic-release
runs-on: ubuntu-24.04
needs: test
permissions:
contents: write
issues: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Semantic Release
uses: docker://ghcr.io/codfish/semantic-release-action@sha256:71048986f7e28f024cbad0ef106a7ef20b9b0d322f3a8aa51d89f1c424e75061 # v3.3.0
# Only run on push events
if: github.event_name == 'push'
id: semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
plugins: |
[
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
]
outputs:
version: ${{ steps.semantic-release.outputs.release-version || format('0.0.0-dev+{0}', github.sha) }}
published: ${{ steps.semantic-release.outputs.new-release-published || 'false' }}
build:
runs-on: ${{ matrix.os.runner }}
needs: release
strategy:
matrix:
os:
- runner: ubuntu-24.04
name: linux
- runner: windows-2022
name: windows
- runner: macos-14
name: macos
target: [x86_64, aarch64]
command: [build]
include:
- args: --release --out dist
sccache: ${{ needs.release.outputs.published == 'false' }}
- command: sdist
os:
runner: ubuntu-24.04
args: --out dist
sccache: false
steps:
- uses: actions/checkout@v4
- name: Replace version in Cargo.toml
shell: pwsh
run: (Get-Content -Path Cargo.toml) -replace '^version = "0.0.0-dev"$', 'version = "${{ needs.release.outputs.version }}"' | Set-Content -Path Cargo.toml
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
command: ${{ matrix.command }}
target: ${{ matrix.target }}
args: ${{ matrix.args }}
sccache: ${{ matrix.sccache }}
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.command == 'sdist' && 'sdist' || format('{0}-{1}', matrix.os.name, matrix.target) }}
path: dist
# For branch protection rules
check:
if: always()
needs:
- build
runs-on: ubuntu-24.04
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
# Should run only on push
publish:
name: Publish to PyPI
needs:
- check
- release
if: needs.release.outputs.published == 'true' && github.event_name == 'push'
runs-on: ubuntu-24.04
environment: pypi
permissions:
id-token: write
attestations: write
steps:
- uses: actions/download-artifact@v4
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-path: "wheels-*/*"
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
with:
command: upload
args: --non-interactive --skip-existing wheels-*/*