Skip to content

Commit 37a601e

Browse files
authored
build(python)!: migrate to uv (#71)
- Uses [uv] to manage python dependencies and tools. - Added mypy to pre-commit hooks (and updated/ran them) - Created CONTRIBUTING.md doc and revise some README docs - Reviewed nurfile - update RTD and dependabot config [uv]: https://docs.astral.sh/uv/
1 parent 0f8248f commit 37a601e

22 files changed

Lines changed: 1357 additions & 130 deletions

.config/.readthedocs.yaml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ build:
1414
rust: latest
1515
python: latest
1616
jobs:
17+
pre_create_environment:
18+
- >-
19+
UV_INSTALL_DIR="${HOME}/.local/bin" &&
20+
curl -LsSf https://astral.sh/uv/install.sh | sh
21+
- ${HOME}/.local/bin/uv sync --group docs
1722
post_create_environment:
1823
- corepack enable
1924
- corepack prepare --activate yarn@4.9.2
@@ -22,15 +27,14 @@ build:
2227
- yarn install
2328
- yarn build:debug
2429
- yarn docs
30+
build:
31+
html:
32+
- >-
33+
${HOME}/.local/bin/uv run
34+
mkdocs build --config-file docs/mkdocs.yml
35+
post_build:
36+
- mkdir -p ${READTHEDOCS_OUTPUT}/html/
37+
- mv docs/site/* ${READTHEDOCS_OUTPUT}/html
2538

2639
mkdocs:
2740
configuration: docs/mkdocs.yml
28-
29-
30-
# Optionally declare the Python requirements required to build your docs
31-
32-
python:
33-
install:
34-
- requirements: docs/requirements.txt
35-
- method: pip
36-
path: '.'

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ updates:
3535
npm:
3636
patterns:
3737
- "*"
38-
- package-ecosystem: pip
38+
- package-ecosystem: uv
3939
directory: /
4040
schedule:
4141
interval: "weekly"
4242
groups:
43-
pip:
43+
uv-pip:
4444
patterns:
4545
- "*"

.github/workflows/bump-n-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
- name: Setup nushell
4545
uses: hustcer/setup-nu@v3
4646
with:
47-
version: '0.106.0'
47+
version: ${{ vars.NU_SHELL_VERSION || '*' }}
4848

4949
- name: Install cargo-binstall
5050
uses: cargo-bins/cargo-binstall@main

.github/workflows/docs.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,18 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- uses: actions/checkout@v4
24-
- uses: actions/setup-python@v5
24+
- uses: astral-sh/setup-uv@v6
2525
with:
26-
python-version: 3.x
26+
enable-cache: true
2727
- uses: actions/setup-node@v4
2828
with:
2929
node-version: 20.x
3030
- run: yarn install
31-
- name: Build Node.js type definitions
32-
run: yarn build:debug
33-
- name: Generate Node.js API docs
34-
run: yarn docs
35-
- run: pip install -r docs/requirements.txt
36-
- run: pip install .
37-
- run: mkdocs build --config-file docs/mkdocs.yml --strict
31+
- name: Setup nushell
32+
uses: hustcer/setup-nu@v3
33+
with:
34+
version: ${{ vars.NU_SHELL_VERSION || '*' }}
35+
- run: nu -c "use nurfile *; nur docs build"
3836
- name: Save docs build as artifact
3937
uses: actions/upload-artifact@v4
4038
with:
@@ -47,7 +45,11 @@ jobs:
4745
- uses: actions/checkout@v4
4846
- name: Setup Rust
4947
run: rustup update --no-self-update
50-
- run: cargo doc --no-deps --lib -p rf24-rs -p rf24ble-rs
48+
- name: Setup nushell
49+
uses: hustcer/setup-nu@v3
50+
with:
51+
version: ${{ vars.NU_SHELL_VERSION || '*' }}
52+
- run: nu -c "use nurfile *; nur docs rs"
5153
- name: save docs as artifact
5254
uses: actions/upload-artifact@v4
5355
with:

.github/workflows/pre-commit.yml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,16 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v4
15-
- uses: actions/setup-python@v5
15+
- uses: astral-sh/setup-uv@v6
1616
id: python-setup
1717
with:
18-
python-version: 3.x
19-
cache: "pip"
20-
cache-dependency-path: examples/python/requirements*.txt
21-
- name: Install workflow tools
22-
run: >-
23-
python -m pip install
24-
-r examples/python/requirements.txt
25-
-r examples/python/requirements-dev.txt
26-
- run: mypy
18+
enable-cache: true
2719
- name: Cache pre-commit environments
2820
uses: actions/cache@v4
2921
with:
3022
path: '~/.cache/pre-commit'
31-
key: pre-commit-${{ steps.python-setup.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
32-
- run: pip install pre-commit
33-
- run: pre-commit run --show-diff-on-failure --color=always --all-files
23+
key: pre-commit-${{ steps.python-setup.outputs.uv-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
24+
- run: uvx pre-commit run --show-diff-on-failure --color=always --all-files
3425

3526
lint-rust:
3627
runs-on: ubuntu-latest

.github/workflows/rust.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ jobs:
4141
uses: cargo-bins/cargo-binstall@main
4242
- name: Install cargo-llvm-cov and cargo-nextest
4343
run: cargo binstall -y cargo-nextest cargo-llvm-cov
44+
- name: Setup nushell
45+
uses: hustcer/setup-nu@v3
46+
with:
47+
version: ${{ vars.NU_SHELL_VERSION || '*' }}
4448
- name: Cache deps
4549
uses: actions/cache@v4
4650
with:
@@ -49,17 +53,11 @@ jobs:
4953
- run: rustup component add llvm-tools-preview
5054
# this enables a tool (for default toolchain) needed to measure code coverage.
5155
- name: Run tests
52-
run: >-
53-
cargo llvm-cov --no-report nextest
54-
-p rf24-rs
55-
-p rf24ble-rs
56-
--lib
57-
--tests
58-
--color always
59-
--profile ci
56+
run: nu -c "use nurfile *; nur test --profile ci"
6057
- name: Generate coverage reports
61-
run: cargo llvm-cov report --lcov --output-path lcov.info
58+
run: nu -c "use nurfile *; nur test lcov"
6259
- uses: codecov/codecov-action@v5
60+
if: github.repository == 'nRF24/rf24-rs'
6361
with:
6462
token: ${{ secrets.CODECOV_TOKEN }}
6563
files: lcov.info
@@ -68,20 +66,24 @@ jobs:
6866
publish:
6967
name: Publish
7068
runs-on: ubuntu-latest
71-
if: startswith(github.ref, 'refs/tags')
69+
if: startswith(github.ref, 'refs/tags/')
7270
permissions:
7371
contents: write
7472
steps:
7573
- uses: actions/checkout@v4
7674
with:
7775
persist-credentials: false
76+
- name: Setup nushell
77+
uses: hustcer/setup-nu@v3
78+
with:
79+
version: ${{ vars.NU_SHELL_VERSION || '*' }}
7880
- name: Get pkg from tag
7981
id: pkg
80-
shell: bash
81-
run: |
82-
tag=${{ github.ref_name }}
83-
pkg=$(echo "$tag" | sed -E 's;([^/]+)/.*;\1;')
84-
echo "name=$pkg" >> "$GITHUB_OUTPUT"
82+
shell: nu {0}
83+
run: |-
84+
let tag = ${{ github.ref_name }}
85+
let pkg = $tag | parse "{name}/{version}" | first
86+
$"name=($pkg | get name)\n" | save --append $env.GITHUB_OUTPUT
8587
- name: Install Rust
8688
run: rustup update stable --no-self-update
8789
- run: cargo publish -p ${{ steps.pkg.outputs.name }}

.pre-commit-config.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@ repos:
1414
exclude: .yarn/releases/yarn.*js
1515
- id: mixed-line-ending
1616
args: ['--fix=lf']
17-
- id: requirements-txt-fixer
1817
- repo: https://github.com/astral-sh/ruff-pre-commit
1918
# Ruff version.
20-
rev: v0.9.10
19+
rev: v0.12.7
2120
hooks:
2221
# Run the linter.
23-
- id: ruff
22+
- id: ruff-check
2423
# Run the formatter.
2524
- id: ruff-format
2625
- repo: https://github.com/streetsidesoftware/cspell-cli
27-
rev: v9.0.1
26+
rev: v9.2.0
2827
hooks:
2928
- id: cspell # Spell check changed files
29+
- repo: https://github.com/pre-commit/mirrors-mypy
30+
rev: 'v1.17.0'
31+
hooks:
32+
- id: mypy

0 commit comments

Comments
 (0)