101 lines
3.0 KiB
YAML
101 lines
3.0 KiB
YAML
# Machine-enforced checks for news-triage, mirroring runway's CI shape.
|
|
|
|
name: Check
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
|
|
jobs:
|
|
check:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
# The toolchain, its components and the wasm target all come from
|
|
# rust-toolchain.toml, so there is one place that says which Rust this is.
|
|
- name: Install the pinned toolchain
|
|
run: |
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
|
|
| sh -s -- -y --default-toolchain none
|
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
|
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: cargo-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
|
|
restore-keys: cargo-${{ runner.os }}-
|
|
|
|
- name: Formatting
|
|
run: cargo fmt --all --check
|
|
|
|
- name: Clippy
|
|
run: cargo clippy --workspace --all-targets -- -D warnings
|
|
|
|
- name: Tests
|
|
run: cargo test --workspace
|
|
|
|
- name: The frontend still builds for the browser
|
|
run: cargo check -p news-web --target wasm32-unknown-unknown
|
|
|
|
guardrails:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install the pinned toolchain
|
|
run: |
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
|
|
| sh -s -- -y --default-toolchain none
|
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
|
|
|
- name: No unused dependencies
|
|
run: |
|
|
cargo install cargo-machete --locked
|
|
cargo machete
|
|
|
|
- name: Licences and advisories
|
|
run: |
|
|
cargo install cargo-deny --locked
|
|
cargo deny check
|
|
|
|
bundle:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install the pinned toolchain
|
|
run: |
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
|
|
| sh -s -- -y --default-toolchain none
|
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
|
|
|
- name: Install Trunk
|
|
run: |
|
|
curl -fsSL https://github.com/trunk-rs/trunk/releases/download/v0.21.14/trunk-x86_64-unknown-linux-gnu.tar.gz \
|
|
| tar -xzC /usr/local/bin trunk
|
|
|
|
- run: npm ci
|
|
|
|
- name: Build the frontend
|
|
working-directory: crates/news-web
|
|
run: trunk build --release
|
|
|
|
# Printed on every run and enforced, because a bundle grows one
|
|
# convenient dependency at a time and nobody notices until it is 2.5 MB.
|
|
# That was v1's. This budget is comfortably above today's and well below
|
|
# that, so it is a ratchet rather than a rubber stamp.
|
|
- name: WASM bundle size
|
|
run: |
|
|
wasm=$(find crates/news-web/dist -name '*.wasm' -print -quit)
|
|
size=$(stat -c %s "$wasm")
|
|
budget=1800000
|
|
echo "$wasm is $size bytes (budget $budget, v1 shipped 2500000)"
|
|
if [ "$size" -gt "$budget" ]; then
|
|
echo "over budget by $((size - budget)) bytes" >&2
|
|
exit 1
|
|
fi
|