Skip to content

Commit 562ff9e

Browse files
committed
refactor: build docs with justfile and uvx
Replace scripts/build-site.py with justfile recipes and run Zensical and the Python checks on demand with uvx, dropping the project virtual environment (pyproject.toml, uv.lock). Windows recipes now use Git Bash, so the build assembly is shared across platforms.
1 parent ca744f1 commit 562ff9e

7 files changed

Lines changed: 55 additions & 387 deletions

File tree

‎.github/workflows/deploy.yml‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ jobs:
5555

5656
- name: Verify TOML, JSON and YAML round trips
5757
run: |
58-
uv sync --locked
5958
cargo run --locked --example fixtures -- .cache/config-generator-fixtures
60-
uv run --locked python tests/config-generator/roundtrip.py .cache/config-generator-fixtures/roundtrip.json
59+
uvx --with 'PyYAML>=6,<7' python tests/config-generator/roundtrip.py .cache/config-generator-fixtures/roundtrip.json
6160
6261
build:
6362
name: Build and test standalone SPA
@@ -86,14 +85,15 @@ jobs:
8685
config-generator/package-lock.json
8786
tests/config-generator/package-lock.json
8887
88+
- uses: extractions/setup-just@v4
89+
8990
- name: Install frontend dependencies
9091
run: npm ci --prefix config-generator
9192

9293
- name: Build documentation and standalone generator
9394
run: |
94-
uv sync --locked
95-
uv run --locked python scripts/build-site.py
96-
uv run --locked python tests/config-generator/check-site.py
95+
just build
96+
uvx python tests/config-generator/check-site.py
9797
9898
- name: Install browser test dependencies
9999
run: npm ci --prefix tests/config-generator
@@ -106,7 +106,7 @@ jobs:
106106
env:
107107
BROWSER_CHANNEL: chromium
108108
run: |
109-
uv run --locked python tests/config-generator/preview-server.py &
109+
uvx python tests/config-generator/preview-server.py &
110110
preview_pid=$!
111111
trap 'kill "$preview_pid" 2>/dev/null || true' EXIT
112112
curl --fail --silent --show-error --retry 30 --retry-connrefused --retry-delay 1 --retry-max-time 60 \
@@ -119,7 +119,7 @@ jobs:
119119
BROWSER_CHANNEL: chromium
120120
run: |
121121
npm run build --prefix config-generator -- --outDir "$PWD/.cache/generic-site"
122-
uv run --locked python tests/config-generator/run-browser.py --directory .cache/generic-site --script tests/config-generator/browser-generic.mjs
122+
uvx python tests/config-generator/run-browser.py --directory .cache/generic-site --script tests/config-generator/browser-generic.mjs
123123
124124
- name: Assemble Pages artifact
125125
run: |

‎AGENTS.md‎

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,14 @@ Credentials are generated with the browser Crypto API. All input, validation, an
4848

4949
## Running the documentation locally
5050

51-
Requires Python 3.10+ and [uv](https://docs.astral.sh/uv/).
51+
Requires [uv](https://docs.astral.sh/uv/); `uvx` fetches the pinned Zensical and Python on demand, so no project virtual environment is created.
5252

5353
```sh
54-
uv sync --locked
55-
uv run --locked zensical serve -f tuic/zensical.toml
56-
uv run --locked zensical serve -f wind/zensical.toml
54+
just docs
55+
just docs-wind
5756
```
5857

59-
Each documentation site has its own `zensical.toml` and `docs/`; the development server serves only one site at a time, and the configuration generator runs separately with the Vite server above. When adding a documentation site, create `<project>/zensical.toml` and `<project>/docs/`, and add it to the site list in `scripts/build-site.py` and to the portal links.
58+
Each documentation site has its own `zensical.toml` and `docs/`; the development server serves only one site at a time, and the configuration generator runs separately with the Vite server above. When adding a documentation site, create `<project>/zensical.toml` and `<project>/docs/`, and add it to the `build` recipe in `justfile` and to the portal links.
6059

6160
## Combined build and validation
6261

@@ -71,14 +70,14 @@ cargo clippy --target wasm32-unknown-unknown --lib --locked -- -D warnings
7170
npm run check --prefix config-generator
7271

7372
# Build all documentation sites and the standalone generator into site/; no publishing
74-
uv run --locked python scripts/build-site.py
75-
uv run --locked python tests/config-generator/check-site.py
73+
just build
74+
uvx python tests/config-generator/check-site.py
7675

7776
# Assemble a site preview (/, /tuic/, /wind/)
78-
uv run --locked python tests/config-generator/preview-server.py
77+
uvx python tests/config-generator/preview-server.py
7978
```
8079

81-
Preview: `http://127.0.0.1:8765/`, `http://127.0.0.1:8765/tuic/`, `http://127.0.0.1:8765/config-generator/`, `http://127.0.0.1:8765/wind/`. Run `npm ci --prefix config-generator` first to install the frontend dependencies; the combined script clean-builds each documentation site, places the standalone generator under `site/config-generator/`, and copies `portal/index.html` to `site/index.html`. Stop the documentation development servers before a clean build to avoid cache conflicts.
80+
Preview: `http://127.0.0.1:8765/`, `http://127.0.0.1:8765/tuic/`, `http://127.0.0.1:8765/config-generator/`, `http://127.0.0.1:8765/wind/`. Run `npm ci --prefix config-generator` first to install the frontend dependencies; the combined build clean-builds each documentation site, places the standalone generator under `site/config-generator/`, and copies `portal/index.html` to `site/index.html`. Stop the documentation development servers before a clean build to avoid cache conflicts.
8281

8382
### Standalone format parsing and real TUIC checks
8483

@@ -87,10 +86,10 @@ Preview: `http://127.0.0.1:8765/`, `http://127.0.0.1:8765/tuic/`, `http://127.0.
8786
cargo run --locked --example fixtures -- .cache/config-generator-fixtures
8887

8988
# Python 3.11+ independent parsers for tomllib, json, and PyYAML
90-
uv run --locked --with 'PyYAML>=6,<7' python tests/config-generator/roundtrip.py .cache/config-generator-fixtures/roundtrip.json
89+
uvx --with 'PyYAML>=6,<7' python tests/config-generator/roundtrip.py .cache/config-generator-fixtures/roundtrip.json
9190

9291
# Call the neighboring TUIC's real parsing functions and run a local SOCKS5 -> TUIC -> TCP echo
93-
uv run --locked python tests/config-generator/check-rust.py --offline
92+
uvx python tests/config-generator/check-rust.py --offline
9493
```
9594

9695
The real parsing check requires the neighboring `../tuic`, its submodules, cached dependencies, and the corresponding build tools; omit `--offline` when the dependency cache is missing. The auxiliary Cargo project writes only to `.cache/`, starts from TUIC's lock file, and does not modify TUIC manifests, sources, lock files, or submodules. The loopback allowance applies only to the in-memory test configuration, and error diagnostics never print configuration contents.
@@ -104,17 +103,17 @@ npm ci --prefix tests/config-generator
104103
node tests/config-generator/browser.mjs
105104

106105
# Test the built standalone artifact; the temporary local server shuts down with the test
107-
uv run --locked python tests/config-generator/run-browser.py
106+
uvx python tests/config-generator/run-browser.py
108107

109108
# Use the deployment prefix for the assembled site build
110-
uv run --locked python tests/config-generator/run-browser.py --directory site/config-generator --prefix /config-generator/
109+
uvx python tests/config-generator/run-browser.py --directory site/config-generator --prefix /config-generator/
111110

112111
# Alternatively use Playwright's bundled Chromium, matching CI
113112
npm exec --prefix tests/config-generator -- playwright install chromium
114113
BROWSER_CHANNEL=chromium node tests/config-generator/browser.mjs
115114
```
116115

117-
`PLAYWRIGHT_MODULE_PATH` can point to an existing Playwright module directory; `BROWSER_CHANNEL` accepts `msedge`, `chrome`, and `chromium`, with CI defaulting to `chromium`. The standalone Vite development server uses `PREVIEW_URL=http://127.0.0.1:8080/`. The tests cover WASM loading, standalone page structure, pairing consistency, user removal, TLS switching, input validation, forwarding edits, copy/download, escaping, mobile, theming, no external requests, and no input persistence; screenshots go to `.cache/`. The reuse check builds with `schema/example.xml` into `.cache/generic-site` and runs `uv run --locked python tests/config-generator/run-browser.py --directory .cache/generic-site --script tests/config-generator/browser-generic.mjs`; see the DSL documentation for the full command. CI likewise keeps the default site artifacts for later publishing.
116+
`PLAYWRIGHT_MODULE_PATH` can point to an existing Playwright module directory; `BROWSER_CHANNEL` accepts `msedge`, `chrome`, and `chromium`, with CI defaulting to `chromium`. The standalone Vite development server uses `PREVIEW_URL=http://127.0.0.1:8080/`. The tests cover WASM loading, standalone page structure, pairing consistency, user removal, TLS switching, input validation, forwarding edits, copy/download, escaping, mobile, theming, no external requests, and no input persistence; screenshots go to `.cache/`. The reuse check builds with `schema/example.xml` into `.cache/generic-site` and runs `uvx python tests/config-generator/run-browser.py --directory .cache/generic-site --script tests/config-generator/browser-generic.mjs`; see the DSL documentation for the full command. CI likewise keeps the default site artifacts for later publishing.
118117

119118
## DSL and maintenance conventions
120119

@@ -143,7 +142,7 @@ Configuration state is modified only by the Rust `Session`. Svelte submits gener
143142
| `wind/zensical.toml` / `wind/docs/` | Wind Chinese protocol specifications and design documents (single publishing source) |
144143
| `wind/docs/specs/` | Wind English specifications and RFC template, published under `/wind/specs/` and kept in sync with the Chinese editions |
145144
| `portal/index.html` | Site root portal page |
146-
| `scripts/build-site.py` | Build all documentation sites and the generator and assemble them into `site/`; does not publish |
145+
| `justfile` | Build, check, and preview recipes; the `build` recipe assembles all documentation sites and the generator into `site/` without publishing |
147146
| `tests/config-generator/` | Standalone parser, real TUIC, site, and browser checks |
148147
| `.github/workflows/deploy.yml` | GitHub Pages build and publish workflow |
149148

@@ -153,7 +152,7 @@ The main documentation is maintained only in Simplified Chinese; the English spe
153152

154153
The [CI and Pages workflow](.github/workflows/deploy.yml) runs on pull requests, pushes to `main`, and manual triggers:
155154

156-
- `check`: nightly rustfmt, stable native and WASM Clippy, Rust/XML DSL tests, and independent TOML/JSON/YAML parsing round trips. Python is pinned to 3.13, and dependencies use `uv.lock`.
155+
- `check`: nightly rustfmt, stable native and WASM Clippy, Rust/XML DSL tests, and independent TOML/JSON/YAML parsing round trips. Python is pinned to 3.13 via `UV_PYTHON`, and tools run on demand with `uvx`.
157156
- `build`: builds the standalone SPA with wasm-pack, the Svelte checker, and Vite, assembles all documentation sites, checks site links and assets, and then runs the TUIC and no-TUIC-field XML reuse browser regressions through the locked Playwright/Chromium. Rust, uv, and npm use dependency caching.
158157
- `deploy`: depends on `check` and `build` succeeding, and publishes only on pushes to `main` or manual runs; Pages write and OIDC permissions are granted only to this job, while pull requests only validate and build.
159158

‎config-generator/AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ v4 替换 v3 描述格式,旧 XML 需要迁移;已生成的 TUIC 配置保
1212
$env:CONFIG_SCHEMA = 'schema/example.xml'
1313
try {
1414
npm run build --prefix config-generator -- --outDir ../.cache/generic-site
15-
uv run --locked python tests/config-generator/run-browser.py --directory .cache/generic-site --script tests/config-generator/browser-generic.mjs
15+
uvx python tests/config-generator/run-browser.py --directory .cache/generic-site --script tests/config-generator/browser-generic.mjs
1616
} finally {
1717
Remove-Item Env:CONFIG_SCHEMA
1818
npm run wasm --prefix config-generator

‎justfile‎

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
# Use the native shell on Windows; Unix keeps just's default `sh` shell.
1+
# Recipes assume a POSIX shell: Unix keeps just's default `sh`, Windows uses Git Bash.
2+
# Git Bash (`bash`) must be on PATH when running `just` on Windows.
23

3-
set windows-shell := ["powershell.exe", "-NoLogo", "-NoProfile", "-Command"]
4+
set windows-shell := ["bash", "-c"]
5+
6+
# Pinned Zensical version, run on demand with `uvx`.
7+
zensical := 'zensical==0.0.59'
48

59
# Show the available repository tasks.
610
default:
711
@just --list
812

9-
# Install locked Python and Node.js dependencies.
13+
# Install Node.js dependencies.
1014
setup:
11-
uv sync --locked
1215
npm ci --prefix config-generator
1316
npm ci --prefix tests/config-generator
1417

@@ -26,11 +29,11 @@ wasm:
2629

2730
# Start the TUIC documentation development server.
2831
docs:
29-
uv run --locked zensical serve -f tuic/zensical.toml
32+
uvx '{{zensical}}' serve -f tuic/zensical.toml
3033

3134
# Start the Wind documentation development server.
3235
docs-wind:
33-
uv run --locked zensical serve -f wind/zensical.toml
36+
uvx '{{zensical}}' serve -f wind/zensical.toml
3437

3538
# Run formatting, native/WASM Rust checks, tests, and Svelte checks.
3639
check:
@@ -40,22 +43,39 @@ check:
4043
cargo clippy --target wasm32-unknown-unknown --lib --locked -- -D warnings
4144
npm run check --prefix config-generator
4245

46+
# Build the TUIC documentation site into tuic/site/.
47+
build-docs-tuic:
48+
uvx '{{zensical}}' build --clean -f tuic/zensical.toml
49+
50+
# Build the Wind documentation site into wind/site/.
51+
build-docs-wind:
52+
uvx '{{zensical}}' build --clean -f wind/zensical.toml
53+
54+
# Build the standalone configuration generator for the /config-generator/ prefix.
55+
build-generator:
56+
npm run build --prefix config-generator -- --base /config-generator/
57+
4358
# Build every documentation site and the standalone generator under site/.
44-
build:
45-
uv run --locked python scripts/build-site.py
59+
build: build-docs-tuic build-docs-wind build-generator
60+
rm -rf site
61+
mkdir -p site
62+
cp -r tuic/site site/tuic
63+
cp -r wind/site site/wind
64+
cp -r config-generator/dist site/config-generator
65+
cp portal/index.html site/index.html
4666

4767
# Build and validate the assembled site.
4868
site-check: build
49-
uv run --locked python tests/config-generator/check-site.py
69+
uvx python tests/config-generator/check-site.py
5070

5171
# Run browser regression tests against a temporary server for the generator dist/.
5272
browser:
53-
uv run --locked python tests/config-generator/run-browser.py
73+
uvx python tests/config-generator/run-browser.py
5474

5575
# Run browser regression tests against the assembled deployment build.
5676
browser-site: build
57-
uv run --locked python tests/config-generator/run-browser.py --directory site/config-generator --prefix /config-generator/
77+
uvx python tests/config-generator/run-browser.py --directory site/config-generator --prefix /config-generator/
5878

5979
# Build, validate, and serve the assembled site preview.
6080
preview: site-check
61-
uv run --locked python tests/config-generator/preview-server.py
81+
uvx python tests/config-generator/preview-server.py

‎pyproject.toml‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

‎scripts/build-site.py‎

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)