Skip to content

Refocus CrateBay on container management #200

Refocus CrateBay on container management

Refocus CrateBay on container management #200

Workflow file for this run

name: CI
on:
push:
branches: [master, rewrite/v2]
pull_request:
branches: [master, rewrite/v2]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
# -----------------------------------------------------------
# Rust formatting (single runner, fast gate)
# -----------------------------------------------------------
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Product surface guard
run: ./scripts/product-surface-guard.sh
- name: Tauri command surface guard
run: ./scripts/verify-tauri-command-surface.sh
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --check
# -----------------------------------------------------------
# Clippy & tests — matrix across macOS + Linux
# -----------------------------------------------------------
check:
name: Clippy & Tests (${{ matrix.name }})
runs-on: ${{ matrix.os }}
needs: fmt
strategy:
fail-fast: false
matrix:
include:
- name: macOS
os: macos-latest
install-protoc: brew install protobuf
# On macOS we can lint/test the whole workspace (excluding GUI which needs WebKitGTK)
clippy-args: --workspace --exclude cratebay-gui -- -D warnings
test-args: --workspace --exclude cratebay-gui
- name: Linux
os: ubuntu-latest
install-protoc: sudo apt-get update && sudo apt-get install -y protobuf-compiler
clippy-args: --workspace --exclude cratebay-gui -- -D warnings
test-args: --workspace --exclude cratebay-gui
- name: Windows
os: windows-latest
install-protoc: choco install protoc -y
# cratebay-gui requires WebView2 build tooling
clippy-args: --workspace --exclude cratebay-gui -- -D warnings
test-args: --workspace --exclude cratebay-gui
steps:
- uses: actions/checkout@v5
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Install protoc
run: ${{ matrix.install-protoc }}
# Linux-only: system libs required by Tauri / WebKitGTK (needed for
# workspace resolve even though we skip the GUI crate itself)
- name: Install Linux system dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get install -y \
libgtk-3-dev \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf
- name: Cargo cache
uses: Swatinem/rust-cache@v2
- name: Clippy
run: cargo clippy ${{ matrix.clippy-args }}
- name: Tests
run: cargo test ${{ matrix.test-args }} -- --test-threads=1
env:
RUST_BACKTRACE: 1
# -----------------------------------------------------------
# GUI backend Rust tests (src-tauri)
# -----------------------------------------------------------
gui-backend:
name: GUI Backend Rust (Ubuntu)
runs-on: ubuntu-latest
needs: fmt
steps:
- uses: actions/checkout@v5
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- name: Install Linux system dependencies
run: |
sudo apt-get install -y \
libgtk-3-dev \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf
- name: Cargo cache
uses: Swatinem/rust-cache@v2
with:
shared-key: gui-backend
- name: Cargo check
run: cargo check -p cratebay-gui
- name: Cargo tests
run: cargo test -p cratebay-gui
# -----------------------------------------------------------
# Built-in Linux runtime smoke — bundled QEMU/KVM runtime
# -----------------------------------------------------------
builtin-runtime-linux:
name: Built-in Runtime Smoke (Linux)
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v5
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- name: Install Linux runtime build dependencies
run: |
sudo apt-get install -y \
patchelf \
qemu-system-x86 \
squashfs-tools
- name: Install Zig
run: bash scripts/install-zig.sh
- name: Install cargo-zigbuild
run: cargo install cargo-zigbuild --locked --force
- name: Add musl target for runtime guest agent
run: rustup target add x86_64-unknown-linux-musl
- name: Cargo cache
uses: Swatinem/rust-cache@v2
with:
shared-key: builtin-runtime-linux
- name: Build bundled runtime assets
run: |
bash scripts/build-runtime-assets-alpine.sh x86_64
bash scripts/build-runtime-assets-linux.sh x86_64
- name: Run CLI + built-in runtime smoke
shell: bash
run: ./scripts/runtime-smoke-local-registry.sh
# -----------------------------------------------------------
# Prepare WSL runtime assets on Linux for Windows smoke tests
# -----------------------------------------------------------
wsl-runtime-assets:
name: WSL Runtime Assets (Linux)
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v5
- name: Build bundled WSL runtime assets
shell: bash
run: |
out_dir="${RUNNER_TEMP}/runtime-wsl"
bash scripts/build-runtime-assets-wsl.sh x86_64 "${out_dir}"
- name: Upload bundled WSL runtime assets
uses: actions/upload-artifact@v7
with:
name: runtime-wsl-x86_64
path: ${{ runner.temp }}/runtime-wsl/cratebay-runtime-wsl-x86_64/rootfs.tar
# -----------------------------------------------------------
# Built-in Windows runtime smoke — bundled WSL2 runtime
# -----------------------------------------------------------
builtin-runtime-windows:
name: Built-in Runtime Smoke (Windows)
runs-on: windows-latest
needs: [check, wsl-runtime-assets]
steps:
- uses: actions/checkout@v5
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Install protoc
run: choco install protoc -y
- name: Add Linux musl target for offline smoke image
run: rustup target add x86_64-unknown-linux-musl
- name: Cargo cache
uses: Swatinem/rust-cache@v2
with:
shared-key: builtin-runtime-windows
- name: Prepare bundled WSL runtime asset destination
shell: bash
run: |
dest="crates/cratebay-gui/src-tauri/runtime-wsl/cratebay-runtime-wsl-x86_64"
mkdir -p "${dest}"
rm -f "${dest}/rootfs.tar"
- name: Download bundled WSL runtime assets
uses: actions/download-artifact@v8
with:
name: runtime-wsl-x86_64
path: crates/cratebay-gui/src-tauri/runtime-wsl/cratebay-runtime-wsl-x86_64
- name: Run built-in runtime smoke
shell: bash
run: ./scripts/runtime-smoke-cli-only.sh
# -----------------------------------------------------------
# Frontend — Node / React lint & build
# -----------------------------------------------------------
frontend:
name: Frontend Lint, Build & Test (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: ["22", "24"]
defaults:
run:
working-directory: crates/cratebay-gui
steps:
- uses: actions/checkout@v5
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
cache-dependency-path: crates/cratebay-gui/pnpm-lock.yaml
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm run lint
- name: Type-check & build
run: pnpm run build
- name: Check i18n keys
run: pnpm run check:i18n
- name: Unit tests
run: pnpm run test:unit
- name: Unit tests with coverage
run: pnpm run test:coverage
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v7
with:
name: frontend-coverage-node${{ matrix.node-version }}
path: crates/cratebay-gui/coverage
if-no-files-found: ignore
# -----------------------------------------------------------
# Frontend E2E — Playwright browser validation
# -----------------------------------------------------------
frontend-e2e:
name: Frontend E2E (Playwright)
runs-on: ubuntu-latest
needs: frontend
defaults:
run:
working-directory: crates/cratebay-gui
steps:
- uses: actions/checkout@v5
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
cache: pnpm
cache-dependency-path: crates/cratebay-gui/pnpm-lock.yaml
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Install Playwright browser
run: npx playwright install --with-deps chromium
- name: Run end-to-end tests
run: npx playwright test
- name: Upload Playwright artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: playwright-report
path: |
output/playwright/report
output/playwright/results
if-no-files-found: ignore
# -----------------------------------------------------------
# Desktop shell smoke — real Tauri app on Linux
# -----------------------------------------------------------
desktop-smoke-linux:
name: Desktop Smoke (Tauri Linux)
runs-on: ubuntu-latest
needs: [frontend-e2e, builtin-runtime-linux]
steps:
- uses: actions/checkout@v5
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
cache: pnpm
cache-dependency-path: crates/cratebay-gui/pnpm-lock.yaml
- name: Install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- name: Install Linux desktop dependencies
run: |
sudo apt-get install -y \
libgtk-3-dev \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf \
xauth \
xvfb \
webkit2gtk-driver
- name: Cargo cache
uses: Swatinem/rust-cache@v2
with:
shared-key: desktop-smoke-linux
- name: Install tauri-driver
run: cargo install tauri-driver --locked --version 2.0.5
- name: Run desktop smoke
run: |
mkdir -p dist/desktop-smoke
set +e
xvfb-run -a -e /tmp/xvfb-run.log ./scripts/run-desktop-e2e-linux.sh
status=$?
set -e
if [[ -f /tmp/xvfb-run.log ]]; then
cp /tmp/xvfb-run.log dist/desktop-smoke/xvfb-run.log || true
echo "== Xvfb log (tail) =="
tail -n 200 /tmp/xvfb-run.log || true
fi
exit $status
- name: Upload desktop smoke artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: desktop-smoke-artifacts
path: dist/desktop-smoke
if-no-files-found: ignore
# -----------------------------------------------------------
# Release binary size check (macOS only — primary target)
# -----------------------------------------------------------
size-check:
name: Binary Size Check
runs-on: macos-latest
needs: check
steps:
- uses: actions/checkout@v5
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Install protoc
run: brew install protobuf
- name: Cargo cache
uses: Swatinem/rust-cache@v2
with:
shared-key: size-check
- name: Build release (CLI)
run: cargo build --release -p cratebay-cli
- name: Report binary sizes
run: |
echo "## Release binary sizes" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "| Binary | Size |" >> "$GITHUB_STEP_SUMMARY"
echo "|--------|------|" >> "$GITHUB_STEP_SUMMARY"
for bin in cratebay; do
path="target/release/$bin"
if [ -f "$path" ]; then
size_bytes=$(stat -f%z "$path")
size_mb=$(echo "scale=2; $size_bytes / 1048576" | bc)
echo "| $bin | ${size_mb} MB |" >> "$GITHUB_STEP_SUMMARY"
echo "$bin: ${size_mb} MB ($size_bytes bytes)"
fi
done
- name: Check binary size limit (20 MB each)
run: |
MAX_BYTES=$((20 * 1048576))
for bin in cratebay; do
path="target/release/$bin"
if [ -f "$path" ]; then
size=$(stat -f%z "$path")
if [ "$size" -gt "$MAX_BYTES" ]; then
echo "::error::$bin is $(echo "scale=2; $size/1048576" | bc) MB — exceeds 20 MB limit"
exit 1
fi
fi
done
echo "All binaries within size budget."
# -----------------------------------------------------------
# Performance benchmark (binary size + startup + idle RAM)
# -----------------------------------------------------------
perf-bench:
name: Performance Benchmark (${{ matrix.name }})
needs: check
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: macOS
os: macos-latest
install-protoc: brew install protobuf
- name: Linux
os: ubuntu-latest
install-protoc: sudo apt-get update && sudo apt-get install -y protobuf-compiler
steps:
- uses: actions/checkout@v5
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Install protoc
run: ${{ matrix.install-protoc }}
# Linux-only: system libs required by workspace resolve
- name: Install Linux system dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get install -y \
libgtk-3-dev \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf
- name: Cargo cache
uses: Swatinem/rust-cache@v2
with:
shared-key: perf-bench
- name: Build release binaries
run: cargo build --release -p cratebay-cli
- name: Run performance benchmarks
run: ./scripts/bench-perf.sh
- name: Write benchmark summary
if: always()
run: |
echo "## Performance Benchmark (${{ matrix.name }})" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
./scripts/bench-perf.sh 2>&1 || true
echo '```' >> "$GITHUB_STEP_SUMMARY"