Skip to content

Refactor for UV!#7

Open
EVWorth wants to merge 3 commits intosunnypilot:masterfrom
EVWorth:refactor-for-uv
Open

Refactor for UV!#7
EVWorth wants to merge 3 commits intosunnypilot:masterfrom
EVWorth:refactor-for-uv

Conversation

@EVWorth
Copy link
Copy Markdown

@EVWorth EVWorth commented Mar 15, 2026

## Summary

Replaces ad-hoc Python environment bootstrapping in CI with a proper `uv`-managed project, removing manual setup steps and aligning the repo with standard `uv` conventions.

## Changes

### `pyproject.toml` (new)
Declares the project and its dependency groups. The `docs` group pins `zensical`, which was previously installed imperatively via `pip install uv && uv pip install --system zensical`. The `requires-python = "~=3.12.0"` constraint replaces the per-command `--python 3.12` flags scattered across workflows and tool docstrings.

### CI workflows
Both `build-docs.yml` and `sync-docs-discourse.yml`:
- Replace the two-step `actions/setup-python` + `pip install uv` setup with `astral-sh/setup-uv@v7`
- `build-docs` now runs `uv run --group docs zensical build`, resolving deps from `pyproject.toml`
- Drop `--python 3.12` from all `uv run` invocations (covered by `pyproject.toml`)
- Fix `workflow_dispatch` input defaults from string `"false"` to boolean `false`

### `.gitignore`
Adds `uv.lock` to prevent an accidental unannounced lockfile commit.

### `tools/` docstrings
Updates `Run:` instructions in all five test files and `sync_to_discourse.py` from `python3 tools/...` to `uv run python tools/...`.

## Why

The previous approach bootstrapped `uv` inside each workflow job manually, then bypassed the project model entirely with `--system`. This makes the repo a proper `uv` project so dependency management is declarative, reproducible, and consistent between local dev and CI.

## Testing

- `uv run --group docs zensical build` — verified locally ✓
- All CI test steps use `uv run python tools/test_*.py` with no version flag, relying on `pyproject.toml`'s `requires-python` constraint

EVWorth added 2 commits March 14, 2026 21:00
Introduces pyproject.toml defining the project's dependency groups
(zensical under [docs]) and uv configuration. Adds uv.lock to .gitignore.
Replace actions/setup-python + manual pip install uv steps with the
astral-sh/setup-uv@v7 action in both CI workflows. Drop explicit
--python 3.12 flags now that pyproject.toml pins requires-python.
Fix workflow_dispatch boolean defaults (string -> bool). Update run
instructions in tool docstrings to use `uv run python`.
Copilot AI review requested due to automatic review settings March 15, 2026 02:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the repo’s Python usage in CI and tooling to follow a uv-managed project model, moving dependency/spec configuration into pyproject.toml and updating workflows and tool instructions accordingly.

Changes:

  • Adds a pyproject.toml defining Python requirements and a docs dependency group for zensical.
  • Updates CI workflows to use astral-sh/setup-uv@v7 and run commands via uv run (including --group docs for doc builds).
  • Updates tool/test docstrings to recommend running via uv run, and ignores uv.lock.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pyproject.toml Introduces uv project metadata, Python requirement, and docs dependency group.
.github/workflows/build-docs.yml Switches doc build job setup to setup-uv and runs build via uv run --group docs.
.github/workflows/sync-docs-discourse.yml Switches test/sync jobs to setup-uv, updates workflow_dispatch boolean defaults, and runs tools via uv run.
.gitignore Adds uv.lock to ignored files.
tools/sync_to_discourse.py Updates usage instructions to remove explicit --python 3.12 flags.
tools/test_converter.py Updates run instructions to uv run python ....
tools/test_discourse_client.py Updates run instructions to uv run python ....
tools/test_nav_parser.py Updates run instructions to uv run python ....
tools/test_content_cache.py Updates run instructions to uv run python ....
tools/test_sync_to_discourse.py Updates run instructions to uv run python ....

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread pyproject.toml
Comment thread .github/workflows/build-docs.yml
Comment thread .github/workflows/sync-docs-discourse.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants