Skip to content

Commit

Permalink
chore: Use uv instead of poetry (#94)
Browse files Browse the repository at this point in the history
Closes #85 

drive-by: Add `pre-commit` checks

---------

Co-authored-by: Alec Edgington <[email protected]>
  • Loading branch information
aborgna-q and cqc-alec authored Nov 18, 2024
1 parent 85f1727 commit cbe79cf
Show file tree
Hide file tree
Showing 13 changed files with 1,363 additions and 483 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Continuous integration
on:
push:
branches:
- main
- main
pull_request:
branches:
- main
Expand Down Expand Up @@ -71,10 +71,10 @@ jobs:
run: cargo test --verbose --no-default-features
- name: Tests with all features
run: cargo test --verbose --all-features

rs-semver-checks:
needs: [check]
if: ${{ github.event_name == 'pull_request' }}
uses: CQCL/hugrverse-actions/.github/workflows/rs-semver-checks.yml@main
secrets:
GITHUB_PAT: ${{ secrets.HUGRBOT_PAT }}
GITHUB_PAT: ${{ secrets.HUGRBOT_PAT }}
21 changes: 10 additions & 11 deletions .github/workflows/missing-ops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Detect missing operation definitions
on:
push:
branches:
- main
- main
pull_request:
branches:
- main
Expand All @@ -16,6 +16,9 @@ env:
CARGO_TERM_COLOR: always
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
# Pinned version for the uv package manager
UV_VERSION: "0.5.1"
UV_FROZEN: 1

jobs:
missing-optypes:
Expand All @@ -31,18 +34,14 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
- name: Set up uv
uses: astral-sh/setup-uv@v3
with:
python-version: '3.12'
cache: "poetry"
- name: Update the project dependencies
run: poetry -C tests update
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Run the missing op types test
id: check_missing_optypes
run: poetry -C tests run -- cargo test --test integration -- --ignored missing_optypes
run: uv run -- cargo test --test integration -- --ignored missing_optypes
- name: Set output flags
id: check_status
if: always()
Expand All @@ -69,4 +68,4 @@ jobs:
timeout-variable: "MISSING_OPS_MSG_SENT"
secrets:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
GITHUB_PAT: ${{ secrets.HUGRBOT_PAT }}
GITHUB_PAT: ${{ secrets.HUGRBOT_PAT }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/target
Cargo.lock

# Python dirs
.pytest_cache
.venv
94 changes: 94 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0 # Use the ref you want to point at
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-toml
- id: check-vcs-permalinks
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
exclude: |
(?x)^(
tests/data/.*
)$
- id: trailing-whitespace
exclude: |
(?x)^(
tests/data/.*
)$
- id: fix-byte-order-marker
- id: mixed-line-ending
# Python-specific
- id: check-ast
- id: check-docstring-first
- id: debug-statements

- repo: local
hooks:
- id: ruff-format
name: ruff format
description: Format python code with `ruff`.
entry: uv run ruff format
language: system
files: \.py$
pass_filenames: false
- id: ruff-check
name: ruff
description: Check python code with `ruff`.
entry: uv run ruff check --fix --exit-non-zero-on-fix
language: system
files: \.py$
pass_filenames: false
- id: mypy-check
name: mypy
description: Check python code with `mypy`.
entry: uv run mypy .
language: system
files: \.py$
pass_filenames: false
- id: cargo-fmt
name: cargo format
description: Format rust code with `cargo fmt`.
entry: cargo fmt --all -- --check
language: system
files: \.rs$
pass_filenames: false
- id: cargo-check
name: cargo check
description: Check rust code with `cargo check`.
entry: cargo check --all --all-features --workspace
language: system
files: \.rs$
pass_filenames: false
- id: cargo-test
name: cargo test
description: Run tests with `cargo test`.
entry: cargo test --all-features --workspace
language: system
files: \.rs$
pass_filenames: false
- id: cargo-clippy
name: cargo clippy
description: Run clippy lints with `cargo clippy`.
entry: cargo clippy --all-targets --all-features --workspace -- -D warnings
language: system
files: \.rs$
pass_filenames: false
- id: cargo-doc
name: cargo doc
description: Generate documentation with `cargo doc`.
entry: sh -c "RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features --workspace"
language: system
files: \.rs$
pass_filenames: false
- id: py-test
name: pytest
description: Run python tests
entry: uv run pytest
language: system
files: \.py$
pass_filenames: false
Loading

0 comments on commit cbe79cf

Please sign in to comment.