Skip to content

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

Redesign: new editorial design language, drop tailwind for UnoCSS

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

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