Skip to content

Commit 113aedc

Browse files
authored
Gallery: the visualci-gallery Rust crate (sc-9298) (#197)
Renders the gallery contract's markup in Rust, byte for byte: Gallery displays as its HTML, and with the askama feature (0.16) it's safe HTML, so a template writes {{ gallery }} unescaped; the fetch feature reads the manifest for a build step. CI runs the golden fixtures, refusal messages and clippy; a release workflow publishes it to crates.io (a temporary token first, then trusted publishing).
1 parent 0bdc54e commit 113aedc

11 files changed

Lines changed: 1649 additions & 2 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,9 @@ jobs:
456456
# Its wheel carries the library's built script and stylesheet.
457457
- run: bin/assets && python3.14 -m pip install --quiet build && python3.14 -m build --wheel && unzip -l dist/*.whl | grep -q visualci_gallery/static/visualci_gallery/visualci_gallery.js
458458
working-directory: clients/gallery/python
459+
# The gallery's Rust renderer (its own workspace): the contract's golden fixtures, Askama included, and clippy.
460+
- run: cargo test --locked --all-features && cargo clippy --locked --all-features --all-targets -- -D warnings
461+
working-directory: clients/gallery/rust
459462
# The Compare two PDFs page runs crates/visualci-wasm in the browser (scripts/wasm.mjs builds it).
460463
- run: rustup target add wasm32-unknown-unknown
461464
# Compile cache (kache, as Cargo's rustc wrapper): the R2 bucket every machine shares (KACHE_BUCKET), else the
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Publish the visualci-gallery crate (clients/gallery/rust) to crates.io. Runs for a gallery-rust-v* tag (matching the
2+
# version in its Cargo.toml) or by hand. crates.io's trusted publishing (OIDC from this workflow) works only for a crate
3+
# that already exists, so the first publish uses a temporary token in the CRATES_IO_TOKEN secret (kept in 1Password as
4+
# visualci-crates-io-publish-token, Nathan's Tasks sc-9327). After that, trusted publishing is set up for this workflow,
5+
# the secret is deleted and the token revoked; without the secret, the workflow publishes through OIDC.
6+
name: Release gallery crate
7+
8+
on:
9+
push:
10+
tags: ["gallery-rust-v*"]
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
id-token: write
16+
17+
jobs:
18+
publish:
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 15
21+
env:
22+
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
23+
defaults:
24+
run:
25+
working-directory: clients/gallery/rust
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: The tag matches the crate's version
29+
if: startsWith(github.ref, 'refs/tags/gallery-rust-v')
30+
run: |
31+
version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
32+
test "gallery-rust-v$version" = "$GITHUB_REF_NAME" || { echo "tag $GITHUB_REF_NAME, crate $version"; exit 1; }
33+
- run: cargo test --locked --all-features
34+
- id: oidc
35+
if: env.CRATES_IO_TOKEN == ''
36+
uses: rust-lang/crates-io-auth-action@v1
37+
- run: cargo publish --locked
38+
env:
39+
CARGO_REGISTRY_TOKEN: ${{ env.CRATES_IO_TOKEN || steps.oidc.outputs.token }}

‎clients/gallery/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ variables.
1212
pipeline.
1313
- [`python/`](python/README.md): the `visualci-gallery` package, standard library only, with the library's files for
1414
Django's static files.
15+
- [`rust/`](rust/README.md): the `visualci-gallery` crate, from plain Rust or an Askama template.
1516

16-
A pnpm workspace: `pnpm install && pnpm build && pnpm test` here. Coming: the Rust crate, emitting the contract's
17-
markup for the JS library to hydrate.
17+
The JS packages are a pnpm workspace: `pnpm install && pnpm build && pnpm test` here.

‎clients/gallery/rust/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target/

0 commit comments

Comments
 (0)