Skip to content

Commit 10cf7fb

Browse files
ci: Clean documentation, and refactor workflow.
1 parent d2413d8 commit 10cf7fb

5 files changed

Lines changed: 89 additions & 77 deletions

File tree

.github/README.md

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,8 @@
11
# Edge Python CI/CD
22

3-
One workflow, [`main.yml`](main.yml), drives the whole monorepo, so the Actions tab
4-
shows a single "CI / CD" run per push/PR with every job as a node in one graph. Each
5-
package's logic lives in a **composite action** under [`../actions/`](../actions);
6-
`main.yml` only wires the dependency graph. The composite actions are not workflows
7-
and do not appear in the Actions tab.
3+
One workflow, [`main.yml`](main.yml), drives the whole monorepo, so the Actions tab shows a single "CI / CD" run per push/PR with every job as a node in one graph. Each package's logic lives in a **composite action** under [`../actions/`](../actions); `main.yml` only wires the dependency graph. The composite actions are not workflows and do not appear in the Actions tab.
84

9-
```
10-
compiler-check ┐
11-
runtime-lint ─┴─► compiler ─► runtime ─┬─► host (matrix) ─┐
12-
└─► std (matrix) ─┤
13-
cli-release (matrix, starts at t=0) ───────────────────────┴─► cli-test
14-
│ (push to main)
15-
cdn ◄── demo ◄── docs ◄───────────┘
16-
(docs builds on every run; deploys only on push to main)
17-
```
18-
19-
`compiler-check`, `runtime-lint` and `cli-release` start at t=0. If any job fails the
20-
dependents never run (`needs:`), so a red build stops the deploys, including the docs
21-
deploy. The
22-
`host` and `std` matrices use `fail-fast: false` so one capability / package failure
23-
still reports the others. `cli-release` is the slow heavy build, so it starts
24-
immediately and `cli-test` waits on `host`, `std`, and the release artifacts.
5+
`compiler-check`, `runtime-lint` and `cli-release` start at t=0. If any job fails the dependents never run (`needs:`), so a red build stops the deploys, including the docs deploy. The `host` and `std` matrices use `fail-fast: false` so one capability / package failure still reports the others. `cli-release` is the slow heavy build, so it starts immediately and `cli-test` waits on `host`, `std`, and the release artifacts.
256

267
## Composite actions
278

@@ -38,24 +19,22 @@ immediately and `cli-test` waits on `host`, `std`, and the release artifacts.
3819

3920
## Cloudflare Pages
4021

41-
Three **Direct Upload** projects. Actions push prebuilt directories via
42-
`wrangler pages deploy`; Cloudflare doesn't clone or build.
22+
Three **Direct Upload** projects. Actions push prebuilt directories via `wrangler pages deploy`; Cloudflare doesn't clone or build.
4323

4424
| Project | Source | Production URL |
4525
|---------|--------|----------------|
4626
| `edge-python-cdn` | `_site/{compiler,runtime,std,host,cli}` (consolidates the old per-package `-runtime` / `-host` / `-std` projects) | `https://edge-python-cdn.pages.dev` |
4727
| `edge-python-demo` | `demo/` (wasm hashed for `version.json`, not bundled) | `https://edge-python-demo.pages.dev` |
4828
| `edge-python-docs` | `docs/out` (Nextra static export) | `https://edgepython.com` (custom domain; also `https://edge-python-docs.pages.dev`) |
4929

50-
All deploys run **only on pushes to `main`** and are pinned to the production `main`
51-
branch. PRs and tags never deploy; the next `main` push refreshes the projects.
30+
All deploys run **only on pushes to `main`** and are pinned to the production `main` branch. PRs and tags never deploy; the next `main` push refreshes the projects.
5231

5332
### Cloudflare and GitHub setup
5433

5534
```bash
5635
# Wrangler CLI (Node 22+)
5736
npx wrangler login
58-
npx wrangler pages project create edge-python-cdn --production-branch=main
37+
npx wrangler pages project create edge-python-cdn --production-branch=main
5938
npx wrangler pages project create edge-python-demo --production-branch=main
6039
npx wrangler pages project create edge-python-docs --production-branch=main
6140
```
@@ -73,8 +52,7 @@ Rotate: create new token -> update secret -> revoke old token.
7352

7453
## Releases
7554

76-
Pushing a `v*` tag runs the pipeline; the `compiler` build job uploads
77-
`compiler_lib.wasm` to the matching Release. Tag must match workspace version.
55+
Pushing a `v*` tag runs the pipeline; the `compiler` build job uploads `compiler_lib.wasm` to the matching Release. Tag must match workspace version.
7856

7957
1. Bump `version` under `[workspace.package]` in root `Cargo.toml` (every crate inherits via `version.workspace = true`). Run `cargo check` to refresh `Cargo.lock`, commit.
8058
2. Tag and push:
@@ -84,18 +62,10 @@ git tag v0.1.0
8462
git push origin v0.1.0
8563
```
8664

87-
On tag push: `compiler-check` lints, then the `compiler` build job optimizes the
88-
artifact and attaches it to a fresh Release with auto-generated notes. The CDN, demo
89-
and docs deploys do not run on tags; they already deployed from the preceding `main` push.
65+
On tag push: `compiler-check` lints, then the `compiler` build job optimizes the artifact and attaches it to a fresh Release with auto-generated notes. The CDN, demo and docs deploys do not run on tags; they already deployed from the preceding `main` push.
9066

91-
Nothing is published to crates.io, distribution is the `.wasm` on the Release.
92-
`starter-module` carries its own version and isn't bumped with the workspace.
67+
Nothing is published to crates.io, distribution is the `.wasm` on the Release. `starter-module` carries its own version and isn't bumped with the workspace.
9368

94-
Consumer crates pick up the release automatically: `compiler/Cargo.toml` declares
95-
`links = "compiler_lib"` and `compiler/build.rs` downloads
96-
`<repository>/releases/download/v<version>/compiler_lib.wasm` into `OUT_DIR`.
97-
Downstreams read `DEP_COMPILER_LIB_WASM` in their own `build.rs`, see
98-
[root README](../../README.md#consume-the-release-from-a-rust-host). Tag bumps flow via `cargo update`.
69+
Consumer crates pick up the release automatically: `compiler/Cargo.toml` declares `links = "compiler_lib"` and `compiler/build.rs` downloads `<repository>/releases/download/v<version>/compiler_lib.wasm` into `OUT_DIR`. Downstreams read `DEP_COMPILER_LIB_WASM` in their own `build.rs`, see [root README](../../README.md#consume-the-release-from-a-rust-host). Tag bumps flow via `cargo update`.
9970

100-
Gated behind the default-on `prebuilt` feature. Producer-side compiler steps pass
101-
`--no-default-features` to avoid fetching the asset that this same pipeline uploads later.
71+
Gated behind the default-on `prebuilt` feature. Producer-side compiler steps pass `--no-default-features` to avoid fetching the asset that this same pipeline uploads later.

.github/actions/cli/action.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: CLI
2-
description: cli/ is its own workspace. release = lint/check + build per target; test = cargo test.
2+
description: cli/ is its own workspace. lint = clippy + check; release = build per target; test = cargo test.
33

44
inputs:
55
mode:
6-
description: "release | test"
6+
description: "lint | release | test"
77
required: true
88
target:
99
description: Rust target triple (release mode).
@@ -13,12 +13,31 @@ inputs:
1313
runs:
1414
using: composite
1515
steps:
16+
- name: Toolchain (lint)
17+
if: inputs.mode == 'lint'
18+
uses: dtolnay/rust-toolchain@stable
19+
with:
20+
components: clippy
21+
22+
- name: Cache Rust (lint)
23+
if: inputs.mode == 'lint'
24+
uses: Swatinem/rust-cache@v2
25+
with:
26+
workspaces: cli -> cli/target
27+
28+
- name: Clippy and check
29+
if: inputs.mode == 'lint'
30+
shell: bash
31+
working-directory: cli
32+
run: |
33+
cargo clippy --all-targets -- -D warnings
34+
cargo check
35+
1636
- name: Toolchain (release)
1737
if: inputs.mode == 'release'
1838
uses: dtolnay/rust-toolchain@stable
1939
with:
2040
targets: ${{ inputs.target }}
21-
components: clippy
2241

2342
- name: Install musl tools
2443
if: inputs.mode == 'release' && contains(inputs.target, 'linux-musl')
@@ -32,15 +51,6 @@ runs:
3251
workspaces: cli -> cli/target
3352
key: ${{ inputs.target }}
3453

35-
# Lint + check once, anchored to the linux x86 target so the matrix doesn't repeat it.
36-
- name: Clippy and check
37-
if: inputs.mode == 'release' && inputs.target == 'x86_64-unknown-linux-musl'
38-
shell: bash
39-
working-directory: cli
40-
run: |
41-
cargo clippy --release --target "${{ inputs.target }}" -- -D warnings
42-
cargo check --release --target "${{ inputs.target }}"
43-
4454
- name: Build release
4555
if: inputs.mode == 'release'
4656
shell: bash

.github/actions/docs/action.yml

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
name: Docs build & deploy
2-
description: Build the Nextra static export (docs/out); deploy to edge-python-docs when deploy=true.
1+
name: Docs
2+
description: Nextra static export. build = next build + upload docs/out; deploy = pull artifact + push to edge-python-docs.
33

44
inputs:
5-
deploy:
6-
description: true to deploy after a successful build.
7-
required: false
8-
default: "false"
5+
mode:
6+
description: "build | deploy"
7+
required: true
98
cloudflare-api-token:
109
description: Cloudflare API token (deploy only).
1110
required: false
@@ -18,25 +17,44 @@ inputs:
1817
runs:
1918
using: composite
2019
steps:
21-
- uses: actions/setup-node@v6
20+
- name: Setup Node
21+
if: inputs.mode == 'build'
22+
uses: actions/setup-node@v6
2223
with:
2324
node-version: "22"
2425
cache: npm
2526
cache-dependency-path: docs/package-lock.json
2627

2728
# Reproducible install from the committed lockfile.
2829
- name: Install
30+
if: inputs.mode == 'build'
2931
shell: bash
3032
working-directory: docs
3133
run: npm ci
3234

3335
- name: Build
36+
if: inputs.mode == 'build'
3437
shell: bash
3538
working-directory: docs
3639
run: npm run build
3740

41+
- name: Upload static export
42+
if: inputs.mode == 'build'
43+
uses: actions/upload-artifact@v6
44+
with:
45+
name: docs-out
46+
path: docs/out
47+
retention-days: 1
48+
49+
- name: Download static export
50+
if: inputs.mode == 'deploy'
51+
uses: actions/download-artifact@v8
52+
with:
53+
name: docs-out
54+
path: docs/out
55+
3856
- name: Deploy to Cloudflare Pages
39-
if: inputs.deploy == 'true'
57+
if: inputs.mode == 'deploy'
4058
uses: cloudflare/wrangler-action@v4
4159
with:
4260
apiToken: ${{ inputs.cloudflare-api-token }}

.github/workflows/main.yml

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
name: CI / CD
22

3-
# Single pipeline for the whole monorepo. Each job's logic lives in a composite
4-
# action under .github/actions/<pkg>; this file only wires the dependency graph.
5-
#
6-
# compiler-check ┐
7-
# runtime-lint ─┴─► compiler ─► runtime ─┬─► host (matrix) ─┐
8-
# └─► std (matrix) ─┤
9-
# cli-release (matrix, starts at t=0) ─────────────────────┴─► cli-test
10-
# │ (push to main)
11-
# cdn ◄── demo ◄── docs ◄────────┘
12-
# docs deploys only on push to main, gated behind the full pipeline.
3+
# Single pipeline for the whole monorepo. Each job's logic lives in a composite action under .github/actions/<pkg>; this file only wires the dependency graph.
134

145
on:
156
push:
@@ -95,9 +86,20 @@ jobs:
9586
with:
9687
package: ${{ matrix.package }}
9788

98-
# Starts at t=0 (no needs): the heavy release build runs in parallel; cli-test awaits its artifacts.
89+
# Clippy + check once (no matrix); gates the release build.
90+
cli-lint:
91+
name: CLI / Lint and Check
92+
runs-on: ubuntu-latest
93+
steps:
94+
- uses: actions/checkout@v6
95+
- uses: ./.github/actions/cli
96+
with:
97+
mode: lint
98+
99+
# Heavy release build per target; starts as soon as cli-lint is green.
99100
cli-release:
100101
name: CLI / Release (${{ matrix.target }})
102+
needs: [cli-lint]
101103
strategy:
102104
fail-fast: false
103105
matrix:
@@ -142,7 +144,7 @@ jobs:
142144

143145
demo:
144146
name: Demo
145-
needs: [cli-test]
147+
needs: [cdn]
146148
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
147149
runs-on: ubuntu-latest
148150
steps:
@@ -152,14 +154,27 @@ jobs:
152154
cloudflare-api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
153155
cloudflare-account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
154156

155-
docs:
157+
# Builds on every run (PR gate) and uploads the static export for docs-deploy.
158+
docs-build:
156159
name: Docs / Build
157160
needs: [cli-test]
158161
runs-on: ubuntu-latest
159162
steps:
160163
- uses: actions/checkout@v6
161164
- uses: ./.github/actions/docs
162165
with:
163-
deploy: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
166+
mode: build
167+
168+
# Tail of the cdn -> demo -> docs deploy chain; main pushes only.
169+
docs-deploy:
170+
name: Docs / Deploy
171+
needs: [demo, docs-build]
172+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
173+
runs-on: ubuntu-latest
174+
steps:
175+
- uses: actions/checkout@v6
176+
- uses: ./.github/actions/docs
177+
with:
178+
mode: deploy
164179
cloudflare-api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
165180
cloudflare-account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

cli/src/uninstall.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ pub fn run() -> Result<()> {
2727
// Tell the script which prompt path the user already answered.
2828
cmd.env("EDGE_UNINSTALL_REMOVE_BROWSER", if remove_browser { "1" } else { "0" });
2929
// Point at the install dir derived from where this binary lives, so non-default installs still clean up.
30-
if let Ok(exe) = std::env::current_exe() {
31-
if let Some(dir) = exe.parent() {
30+
if let Ok(exe) = std::env::current_exe()
31+
&& let Some(dir) = exe.parent() {
3232
cmd.env("EDGE_INSTALL_DIR", dir);
3333
}
34-
}
3534

3635
let status = cmd.status().map_err(|e| anyhow!("running bash: {e}"))?;
3736
let _ = std::fs::remove_file(&temp);

0 commit comments

Comments
 (0)