Skip to content

Redesign: new editorial design language, drop tailwind for UnoCSS #27

Redesign: new editorial design language, drop tailwind for UnoCSS

Redesign: new editorial design language, drop tailwind for UnoCSS #27

Workflow file for this run

name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
line-endings:
name: Line endings (LF only)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dos2unix
run: sudo apt-get update && sudo apt-get install -y dos2unix
- name: Check that all tracked text files use LF
run: |
# dos2unix -ic lists files that contain CR characters.
# We feed it every text file tracked by git (-I excludes binary files in grep,
# and git's --eol filter would also work, but -ic is the canonical dos2unix check).
offenders=$(git ls-files -z | xargs -0 dos2unix -ic 2>/dev/null || true)
if [ -n "$offenders" ]; then
echo "::error::The following files contain CRLF or CR line endings; run dos2unix on them:"
printf '%s\n' "$offenders"
exit 1
fi
echo "All tracked files use LF line endings."
formatting:
name: leptosfmt --check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install stable Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo bin
uses: actions/cache@v4
with:
path: ~/.cargo/bin
key: cargo-bin-leptosfmt-0.1.33
- name: Install leptosfmt
run: |
if ! command -v leptosfmt >/dev/null 2>&1; then
cargo install leptosfmt --version 0.1.33 --locked
fi
- name: Run leptosfmt --check
run: leptosfmt --check src
rustfmt:
name: cargo fmt --check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install stable Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Run cargo fmt --check
run: cargo fmt --all -- --check
clippy:
name: cargo clippy
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Install nightly Rust
uses: dtolnay/rust-toolchain@nightly
with:
targets: wasm32-unknown-unknown
components: clippy
- name: Cache cargo registry and target
uses: Swatinem/rust-cache@v2
with:
key: clippy
- name: Run cargo clippy
run: cargo clippy --target wasm32-unknown-unknown --all-targets --no-deps -- -D warnings
test:
name: cargo test
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Install stable Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry and target
uses: Swatinem/rust-cache@v2
with:
key: test
- name: Run cargo test
run: cargo test --all-targets --no-fail-fast
wasm-test:
name: wasm-pack test (headless Firefox)
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: Install nightly Rust
uses: dtolnay/rust-toolchain@nightly
with:
targets: wasm32-unknown-unknown
- name: Cache cargo registry and target
uses: Swatinem/rust-cache@v2
with:
key: wasm-test
- name: Install wasm-pack
# wasm-pack ships pre-built binaries; the official installer is the
# fastest path on Linux runners (cargo install would compile from
# source for several minutes).
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Run browser tests
# ubuntu-latest already ships Firefox; geckodriver is auto-fetched
# by wasm-pack in a version that matches the installed browser.
run: wasm-pack test --headless --firefox --test wasm
build:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Install nightly Rust
uses: dtolnay/rust-toolchain@nightly
with:
targets: wasm32-unknown-unknown
- name: Cache cargo registry and target
uses: Swatinem/rust-cache@v2
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install npm dependencies (UnoCSS)
run: npm ci
- name: Install Trunk
run: |
wget -qO- https://github.com/trunk-rs/trunk/releases/download/v0.21.14/trunk-x86_64-unknown-linux-gnu.tar.gz \
| tar -xzf- -C /usr/local/bin
- name: Build with Trunk
run: trunk build --release
- name: Asset size budget
# Fails the build if any critical asset exceeds its gzipped budget.
# Budgets carry roughly +25% headroom over the current sizes so
# routine changes don't trip them, but a careless dependency
# bump or stylesheet bloat will. Update the budget alongside the
# change that exceeds it, with a clear justification in the PR.
run: |
set -euo pipefail
fail=0
check() {
local pattern="$1"
local label="$2"
local budget_kb="$3"
local file
file=$(ls dist/$pattern 2>/dev/null | head -n1 || true)
if [ -z "$file" ]; then
echo "::error::Budget check: no file matching dist/$pattern"
fail=1
return
fi
local size_b
size_b=$(gzip -c -9 "$file" | wc -c)
local size_kb=$(( (size_b + 1023) / 1024 ))
if [ "$size_kb" -gt "$budget_kb" ]; then
echo "::error::$label is ${size_kb} KB gz, budget is ${budget_kb} KB ($file)"
fail=1
else
echo "OK: $label = ${size_kb} KB gz (budget ${budget_kb} KB) -- $file"
fi
}
check 'odp-*_bg.wasm' 'wasm' 230
check 'base-*.css' 'base CSS' 5
check 'uno.generated-*.css' 'UnoCSS bundle' 10
check 'repo_graph.css' 'repo_graph CSS' 2
check 'odp-*.js' 'wasm-bindgen JS' 20
if [ "$fail" -ne 0 ]; then
echo "::error::One or more assets exceeded their size budget."
exit 1
fi
- name: Critical icon classes present
# UnoCSS preset-icons silently emits nothing when an icon class
# cannot be resolved (missing iconify pack, typo, etc.), which
# would ship a working build with invisible buttons. Assert that
# the icons we actually rely on made it into the generated CSS.
run: |
set -euo pipefail
css=$(ls dist/uno.generated-*.css | head -n1)
required="i-lucide-moon i-lucide-sun i-lucide-menu i-lucide-x i-lucide-arrow-right i-lucide-github i-lucide-play"
missing=""
for cls in $required; do
grep -qF ".$cls" "$css" || missing="$missing $cls"
done
if [ -n "$missing" ]; then
echo "::error::UnoCSS did not emit rules for:$missing"
echo "::error::Likely cause: missing iconify pack in node_modules (run 'npm ci'), or class typo in src/."
exit 1
fi
echo "OK: all required icon utilities present in $css"
lighthouse:
name: Lighthouse (mobile, soft)
runs-on: ubuntu-latest
timeout-minutes: 15
# Soft mode: this job MUST NOT block PR merges. It exists to
# surface regressions in performance / accessibility / SEO / best
# practices, not to gate them. Once scores stabilize we'll flip
# to strict assertions in a follow-up.
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Install nightly Rust
uses: dtolnay/rust-toolchain@nightly
with:
targets: wasm32-unknown-unknown
- name: Cache cargo registry and target
uses: Swatinem/rust-cache@v2
with:
key: lighthouse-build
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install npm dependencies (UnoCSS)
run: npm ci
- name: Install Trunk
run: |
wget -qO- https://github.com/trunk-rs/trunk/releases/download/v0.21.14/trunk-x86_64-unknown-linux-gnu.tar.gz \
| tar -xzf- -C /usr/local/bin
- name: Build with Trunk
run: trunk build --release
- name: Install Lighthouse CI
# ubuntu-latest ships Google Chrome; @lhci/cli discovers it
# automatically. Pin to the 0.14.x line for stability.
run: npm install --no-save @lhci/cli@0.14.x
- name: Run Lighthouse CI (soft)
# `|| true` belts `continue-on-error`'s suspenders: a transient
# lhci failure (Chrome crash, port collision) still leaves the
# job green so we always reach the summary + artifact steps.
run: npx lhci autorun --config=lighthouserc.json || true
- name: Summarize scores
# Extract median category scores from each Lighthouse report
# and post a compact table to the workflow run summary so
# reviewers don't have to download the artifact for the
# at-a-glance number.
run: |
set -euo pipefail
shopt -s nullglob
files=(lhci-reports/lhr-*.json)
if [ ${#files[@]} -eq 0 ]; then
echo "::warning::No Lighthouse reports were produced."
exit 0
fi
{
echo "| URL | Perf | A11y | Best | SEO |"
echo "|---|---|---|---|---|"
for f in "${files[@]}"; do
node -e "
const r = require('./$f');
const c = r.categories;
const pct = k => Math.round(c[k].score * 100);
console.log(\`| \${r.finalUrl} | \${pct('performance')} | \${pct('accessibility')} | \${pct('best-practices')} | \${pct('seo')} |\`);
"
done
} | tee -a "$GITHUB_STEP_SUMMARY"
- name: Upload Lighthouse reports
if: always()
uses: actions/upload-artifact@v4
with:
name: lighthouse-reports
path: lhci-reports/
retention-days: 14