Skip to content

chore: switch to uv and nox #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions .config/.readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ build:
tools:
rust: latest
python: latest

mkdocs:
configuration: docs/mkdocs.yml


# Optionally declare the Python requirements required to build your docs

python:
install:
- requirements: docs/requirements.txt
- method: pip
path: docs/
jobs:
pre_create_environment:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
build:
html:
- uvx nox -s docs-build
post_build:
- mkdir -p $READTHEDOCS_OUTPUT/html/
- mv docs/site/* $READTHEDOCS_OUTPUT/html
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ updates:
actions:
patterns:
- "*"
- package-ecosystem: pip
- package-ecosystem: uv
directory: /
schedule:
interval: "weekly"
groups:
pip:
uv-pip:
patterns:
- "*"
- package-ecosystem: cargo
Expand Down
23 changes: 8 additions & 15 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,13 @@ jobs:
with:
path: ~/.cargo
key: ${{ runner.os }}-docs-cargo-${{ hashFiles('Cargo.lock') }}
- uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: 3.x
cache: 'pip'
cache-dependency-path: docs/requirements.txt
- name: Install workflow deps
run: |
pip install -r docs/requirements.txt
pip install --force-reinstall -v docs/
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Build docs
working-directory: docs
run: mkdocs build
run: uvx nox -s docs-build
- name: Upload docs build as artifact
uses: actions/upload-artifact@v4
with:
Expand All @@ -84,11 +79,9 @@ jobs:
with:
path: ~/.cargo
key: ${{ runner.os }}-docs-cargo-${{ hashFiles('Cargo.lock') }}
- name: Install just
uses: taiki-e/install-action@v2
with:
tool: just
- run: just docs-rs
- name: Install uv
uses: astral-sh/setup-uv@v5
- run: uvx nox -s docs-rs
- name: upload rustdoc build as artifact
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/bump-n-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
workflow_dispatch:
inputs:
component:
description: The version component to increase
type: choice
required: true
default: patch
Expand Down
46 changes: 19 additions & 27 deletions .github/workflows/run-dev-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- run: rustup update --no-self-update
- run: rustup component add llvm-tools-preview

# https://docs.rs/openssl/latest/openssl/#automatic
Expand All @@ -56,8 +57,11 @@ jobs:
with:
python-version: 3.x

- name: Install workflow deps
run: python3 -m pip install meson
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"

# # https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages
- name: Install ninja (Linux)
Expand All @@ -78,18 +82,6 @@ jobs:
- if: runner.os == 'Linux'
run: sudo apt-get update

- name: Install clang v7
if: runner.os == 'Linux'
uses: ./.github/install-clang-action
with:
version: '7'

- name: Collect Coverage for clang v7
if: runner.os == 'Linux'
env:
CLANG_VERSION: '7'
run: just test ci

- name: Install clang v8
if: runner.os == 'Linux'
uses: ./.github/install-clang-action
Expand All @@ -100,7 +92,7 @@ jobs:
if: runner.os == 'Linux'
env:
CLANG_VERSION: '8'
run: just test ci
run: uvx nox -s test -- --profile ci

- name: Install clang v9
uses: ./.github/install-clang-action
Expand All @@ -110,7 +102,7 @@ jobs:
- name: Collect Coverage for clang v9
env:
CLANG_VERSION: '9'
run: just test ci
run: uvx nox -s test -- --profile ci

- name: Install clang v10
uses: ./.github/install-clang-action
Expand All @@ -120,7 +112,7 @@ jobs:
- name: Collect Coverage for clang v10
env:
CLANG_VERSION: '10'
run: just test ci
run: uvx nox -s test -- --profile ci

- name: Install clang 11
uses: ./.github/install-clang-action
Expand All @@ -130,7 +122,7 @@ jobs:
- name: Collect Coverage for clang v11
env:
CLANG_VERSION: '11'
run: just test ci
run: uvx nox -s test -- --profile ci

- name: Install clang 12
uses: ./.github/install-clang-action
Expand All @@ -140,7 +132,7 @@ jobs:
- name: Collect Coverage for clang v12
env:
CLANG_VERSION: '12'
run: just test ci
run: uvx nox -s test -- --profile ci

- name: Install clang 13
uses: ./.github/install-clang-action
Expand All @@ -150,7 +142,7 @@ jobs:
- name: Collect Coverage for clang v13
env:
CLANG_VERSION: '13'
run: just test ci
run: uvx nox -s test -- --profile ci

- name: Install clang 14
uses: ./.github/install-clang-action
Expand All @@ -160,7 +152,7 @@ jobs:
- name: Collect Coverage for clang v14
env:
CLANG_VERSION: '14'
run: just test ci
run: uvx nox -s test -- --profile ci

- name: Install clang 15
uses: ./.github/install-clang-action
Expand All @@ -170,7 +162,7 @@ jobs:
- name: Collect Coverage for clang v15
env:
CLANG_VERSION: '15'
run: just test ci
run: uvx nox -s test -- --profile ci

- name: Install clang 16
uses: ./.github/install-clang-action
Expand All @@ -180,7 +172,7 @@ jobs:
- name: Collect Coverage for clang v16
env:
CLANG_VERSION: '16'
run: just test ci
run: uvx nox -s test -- --profile ci

- name: Install clang 17
uses: ./.github/install-clang-action
Expand All @@ -190,7 +182,7 @@ jobs:
- name: Collect Coverage for clang v17
env:
CLANG_VERSION: '17'
run: just test ci
run: uvx nox -s test -- --profile ci

- name: Install clang 18
uses: ./.github/install-clang-action
Expand All @@ -200,10 +192,10 @@ jobs:
- name: Collect Coverage for clang v18
env:
CLANG_VERSION: '18'
run: just test all
run: uvx nox -s test -- --profile all

- name: Generate Coverage HTML report
run: just pretty-cov
run: uvx nox -s pretty-cov

- name: Upload coverage data
uses: actions/upload-artifact@v4
Expand All @@ -214,7 +206,7 @@ jobs:
- name: Generate Coverage lcov report
run: |
rm coverage.json
just lcov
uvx nox -s lcov

- uses: codecov/codecov-action@v5
with:
Expand Down
78 changes: 78 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Contributing

This project requires the following tools installed:

- :simple-rust: [rust](https://rustup.rs/)
- :simple-uv: [`uv` (Python Project management tool)](https://docs.astral.sh/uv/)

## Getting started

After checking out the repo locally, use

```sh
uv sync
```

This creates a venv at ".venv/" in repo root (if it doesn't exist).
It also installs dev dependencies like `pre-commit`, `nox`, `ruff`, and `mypy`.

See [`uv sync` docs](https://docs.astral.sh/uv/reference/cli/#uv-sync)
for more detailed usage.

> [!TIP]
> To register the pre-commit hooks, use:
>
> ```shell
> uv run pre-commit install
> ```

## Running tests

First ensure that the following cargo-managed binaries are installed:

- [`cargo-llvm-cov`](https://github.com/taiki-e/cargo-llvm-cov)
- [`cargo-nextest`](https://nexte.st/docs/installation/pre-built-binaries/)
- [`llvm-cov-pretty`](https://crates.io/crates/llvm-cov-pretty) is used only for the optional `nox -s pretty-cov` task. Without this installed, `nox -s llvm-cov` will suffice.

Use nox to run tests:

```sh
uv run nox -s test
```

Different test profiles are still defined in .config/nextest.toml.
The above command uses the "default" profile, but to mimic the CI, use:

```sh
uv run nox -s test -- --profile ci
```

To generate a coverage report:

```sh
uv run nox -s llvm-cov -- --open
```

The `-- --open` part is optional. It opens the built coverage report in your default browser.

The uploaded codecov report is generated with

```sh
uv run nox -s lcov
```

## Generating docs

To view the docs locally, use

```sh
uv run nox -s docs -- --open
```

The `-- --open` part is optional. It opens the built docs in your default browser.

In CI, docs are built using

```sh
uv run nox -s docs-build
```
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion bindings/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ cpp-linter -help
| `Cargo.toml` | Metadata about the binding's rust package (which _is not_ intended to be published to crates.io). |
| `../../cpp_linter.pyi` | The typing stubs for the package (located in repo root). |
| `../../pyproject.toml` | Metadata about the python package (located in repo root). |
| `requirements-dev.txt` | The dependencies used in development (not needed for runtime/production). |

Hidden files and folders are not described in the table above.
If they are not ignored by a gitignore specification, then they should be considered
Expand Down
1 change: 0 additions & 1 deletion bindings/python/requirements-dev.txt

This file was deleted.

2 changes: 1 addition & 1 deletion cpp-linter/src/rest_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ const MAX_RETRIES: u8 = 5;
/// This method respects both primary and secondary rate limits.
/// In the event where the secondary rate limits is reached,
/// this function will wait for a time interval specified the server and retry afterward.
async fn send_api_request(
pub async fn send_api_request(
client: &Client,
request: Request,
rate_limit_headers: &RestApiRateLimitHeaders,
Expand Down
8 changes: 8 additions & 0 deletions cspell.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ words:
- Boolish
- bugprone
- chrono
- clippy
- codecov
- codspeed
- consts
Expand All @@ -31,11 +32,13 @@ words:
- mdbook
- mkdocs
- msvc
- mypy
- napi
- nextest
- nonminimal
- peekable
- pkgs
- posargs
- positionals
- posix
- preprocess
Expand All @@ -49,7 +52,11 @@ words:
- ratelimit
- reqwest
- revparse
- rustdoc
- rustup
- sdist
- serde
- Shen
- superfences
- tada
- tasklist
Expand All @@ -58,6 +65,7 @@ words:
- twemoji
- vararg
- venv
- Xianpeng
ignorePaths:
- .env/**
- .venv/**
Expand Down
Loading
Loading