fix: pyright diagnotics #169
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
- alpha | |
- beta | |
pull_request: | |
branches: | |
- main | |
- alpha | |
- beta | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
env: | |
CARGO_TERM_COLOR: always | |
PYTHON_VERSION: 3.12 | |
jobs: | |
# Should run on every push and PR | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cargo build | |
run: cargo build --verbose --locked | |
- name: Cargo test | |
run: cargo test --verbose | |
- name: Cargo fmt | |
run: cargo fmt --check | |
- name: Cargo clippy | |
run: cargo clippy --all-targets | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
- name: Sync project | |
run: uv sync --locked | |
- 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: Stubtest | |
run: uv run task stubtest | |
# Should run on every push and PR, but only run semantic-release on push | |
release: | |
name: Run semantic-release | |
runs-on: ubuntu-latest | |
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' }} | |
linux: | |
runs-on: ${{ matrix.platform.runner }} | |
needs: release | |
strategy: | |
matrix: | |
platform: | |
- runner: ubuntu-latest | |
target: x86_64 | |
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 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.platform.target }} | |
args: --release --out dist --find-interpreter | |
sccache: 'true' | |
manylinux: auto | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-linux-${{ matrix.platform.target }} | |
path: dist | |
windows: | |
runs-on: ${{ matrix.platform.runner }} | |
needs: release | |
strategy: | |
matrix: | |
platform: | |
- runner: windows-latest | |
target: x64 | |
- runner: windows-latest | |
target: x86 | |
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 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
architecture: ${{ matrix.platform.target }} | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.platform.target }} | |
args: --release --out dist --find-interpreter | |
sccache: 'true' | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-windows-${{ matrix.platform.target }} | |
path: dist | |
macos: | |
runs-on: ${{ matrix.platform.runner }} | |
needs: release | |
strategy: | |
matrix: | |
platform: | |
- runner: macos-latest | |
target: x86_64 | |
- runner: macos-14 | |
target: aarch64 | |
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 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.platform.target }} | |
args: --release --out dist --find-interpreter | |
sccache: 'true' | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-macos-${{ matrix.platform.target }} | |
path: dist | |
sdist: | |
runs-on: ubuntu-latest | |
needs: release | |
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 sdist | |
uses: PyO3/maturin-action@v1 | |
with: | |
command: sdist | |
args: --out dist | |
- name: Upload sdist | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-sdist | |
path: dist | |
# For branch protection rules | |
check: | |
if: always() | |
needs: | |
- linux | |
- windows | |
- macos | |
- sdist | |
runs-on: ubuntu-latest | |
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-latest | |
environment: pypi | |
permissions: | |
id-token: write | |
attestations: write | |
steps: | |
- uses: actions/download-artifact@v4 | |
- name: Generate artifact attestation | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-path: 'wheels-*/*' | |
- name: Publish to PyPI | |
uses: PyO3/maturin-action@v1 | |
with: | |
command: upload | |
args: --non-interactive --skip-existing wheels-*/* |