diff --git a/.github/actions/setup-skit/action.yml b/.github/actions/setup-skit/action.yml new file mode 100644 index 00000000..4472fa45 --- /dev/null +++ b/.github/actions/setup-skit/action.yml @@ -0,0 +1,84 @@ +# SPDX-FileCopyrightText: © 2025 StreamKit Contributors +# +# SPDX-License-Identifier: MPL-2.0 + +name: Set up Skit CI environment +description: > + Common prelude for Skit CI jobs on ubuntu-22.04: free disk space, install + Bun and optionally build the UI (streamkit-server embeds ./ui/dist via + RustEmbed), install the system packages needed by the Rust build (libvpx, + nasm), install the pinned Rust toolchain, and restore Swatinem/rust-cache. + The caller must run actions/checkout before invoking this action so the + action.yml file is resolvable on the runner. sccache is intentionally not + part of the prelude — it is per-job and Coverage opts out entirely. + +inputs: + rust-cache-key: + description: Swatinem/rust-cache shared-key. Jobs that share a target/ may share a key. + required: false + default: skit + rust-cache-workspaces: + description: > + Swatinem/rust-cache workspaces directive. Leave empty for the default + ("."); set to e.g. ". -> target/coverage" when redirecting Cargo's + target dir (cargo-llvm-cov). + required: false + default: "" + rust-components: + description: > + Comma-separated extra Rust toolchain components to install (e.g. + "rustfmt, clippy" or "llvm-tools-preview"). Empty means none beyond + the default profile. + required: false + default: "" + skip-ui-build: + description: > + If "true", skip building ./ui/dist. streamkit-server's RustEmbed + directive requires ./ui/dist to exist at compile time, so most Rust + jobs need this false. + required: false + default: "false" + +runs: + using: composite + steps: + - name: Free disk space + uses: jlumbroso/free-disk-space@main + with: + tool-cache: false + android: true + dotnet: true + haskell: true + large-packages: false + docker-images: true + swap-storage: false + + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: "1.3.5" + + - name: Build UI + if: inputs.skip-ui-build != 'true' + working-directory: ./ui + shell: bash + run: | + bun install --frozen-lockfile + bun run build + + - name: Install system dependencies (libvpx for VP9, nasm for AV1 assembly) + shell: bash + run: sudo apt-get update && sudo apt-get install -y libvpx-dev nasm + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: "1.95.0" + components: ${{ inputs.rust-components }} + + - uses: Swatinem/rust-cache@v2 + with: + shared-key: ${{ inputs.rust-cache-key }} + workspaces: ${{ inputs.rust-cache-workspaces }} + save-if: ${{ github.ref == 'refs/heads/main' }} + cache-on-failure: true diff --git a/.github/workflows/skit.yml b/.github/workflows/skit.yml index 23df34bd..fb01e273 100644 --- a/.github/workflows/skit.yml +++ b/.github/workflows/skit.yml @@ -13,38 +13,11 @@ jobs: name: Lint (fmt + clippy) runs-on: ubuntu-22.04 steps: - - name: Free disk space - uses: jlumbroso/free-disk-space@main - with: - tool-cache: false - android: true - dotnet: true - haskell: true - large-packages: false - docker-images: true - swap-storage: false - - uses: actions/checkout@v5 - - name: Setup Bun - uses: oven-sh/setup-bun@v2 + - uses: ./.github/actions/setup-skit with: - bun-version: "1.3.5" - - - name: Build UI - working-directory: ./ui - run: | - bun install --frozen-lockfile - bun run build - - - name: Install system dependencies (libvpx for VP9, nasm for AV1 assembly) - run: sudo apt-get update && sudo apt-get install -y libvpx-dev nasm - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@master - with: - toolchain: "1.95.0" - components: rustfmt, clippy + rust-components: "rustfmt, clippy" - name: Restore sccache cache uses: actions/cache/restore@v4 @@ -56,12 +29,6 @@ jobs: - uses: mozilla-actions/sccache-action@v0.0.9 - - uses: Swatinem/rust-cache@v2 - with: - shared-key: skit - save-if: ${{ github.ref == 'refs/heads/main' }} - cache-on-failure: true - - name: Check formatting run: cargo fmt --all -- --check @@ -91,37 +58,9 @@ jobs: name: Test runs-on: ubuntu-22.04 steps: - - name: Free disk space - uses: jlumbroso/free-disk-space@main - with: - tool-cache: false - android: true - dotnet: true - haskell: true - large-packages: false - docker-images: true - swap-storage: false - - uses: actions/checkout@v5 - - name: Setup Bun - uses: oven-sh/setup-bun@v2 - with: - bun-version: "1.3.5" - - - name: Build UI - working-directory: ./ui - run: | - bun install --frozen-lockfile - bun run build - - - name: Install system dependencies (libvpx for VP9, nasm for AV1 assembly) - run: sudo apt-get update && sudo apt-get install -y libvpx-dev nasm - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@master - with: - toolchain: "1.95.0" + - uses: ./.github/actions/setup-skit - name: Restore sccache cache uses: actions/cache/restore@v4 @@ -133,12 +72,6 @@ jobs: - uses: mozilla-actions/sccache-action@v0.0.9 - - uses: Swatinem/rust-cache@v2 - with: - shared-key: skit - save-if: ${{ github.ref == 'refs/heads/main' }} - cache-on-failure: true - - name: Run tests (GPU tests run separately on self-hosted runner) run: | cargo test --locked --workspace -- --skip gpu_tests:: @@ -167,49 +100,13 @@ jobs: # avoid the "sccache not installed" failure and unnecessary indirection. RUSTC_WRAPPER: "" steps: - - name: Free disk space - uses: jlumbroso/free-disk-space@main - with: - tool-cache: false - android: true - dotnet: true - haskell: true - large-packages: false - docker-images: true - swap-storage: false - - uses: actions/checkout@v5 - - name: Setup Bun - uses: oven-sh/setup-bun@v2 + - uses: ./.github/actions/setup-skit with: - bun-version: "1.3.5" - - - name: Build UI - working-directory: ./ui - run: | - bun install --frozen-lockfile - bun run build - - - name: Install system dependencies (libvpx for VP9, nasm for AV1 assembly) - run: sudo apt-get update && sudo apt-get install -y libvpx-dev nasm - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@master - with: - toolchain: "1.95.0" - components: llvm-tools-preview - - - uses: Swatinem/rust-cache@v2 - with: - shared-key: skit-coverage - # Point the cache at the same target dir we redirected Cargo to - # via CARGO_LLVM_COV_TARGET_DIR. Without this, rust-cache would - # cache the (empty) default target/ and skip the actual build - # artifacts under target/coverage. - workspaces: ". -> target/coverage" - save-if: ${{ github.ref == 'refs/heads/main' }} - cache-on-failure: true + rust-cache-key: skit-coverage + rust-cache-workspaces: ". -> target/coverage" + rust-components: llvm-tools-preview - name: Install cargo-llvm-cov and cargo-nextest uses: taiki-e/install-action@v2 @@ -297,37 +194,9 @@ jobs: name: Build runs-on: ubuntu-22.04 steps: - - name: Free disk space - uses: jlumbroso/free-disk-space@main - with: - tool-cache: false - android: true - dotnet: true - haskell: true - large-packages: false - docker-images: true - swap-storage: false - - uses: actions/checkout@v5 - - name: Setup Bun - uses: oven-sh/setup-bun@v2 - with: - bun-version: "1.3.5" - - - name: Build UI - working-directory: ./ui - run: | - bun install --frozen-lockfile - bun run build - - - name: Install system dependencies (libvpx for VP9, nasm for AV1 assembly) - run: sudo apt-get update && sudo apt-get install -y libvpx-dev nasm - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@master - with: - toolchain: "1.95.0" + - uses: ./.github/actions/setup-skit - name: Restore sccache cache uses: actions/cache/restore@v4 @@ -339,12 +208,6 @@ jobs: - uses: mozilla-actions/sccache-action@v0.0.9 - - uses: Swatinem/rust-cache@v2 - with: - shared-key: skit - save-if: ${{ github.ref == 'refs/heads/main' }} - cache-on-failure: true - - name: Build all crates run: | cargo build --locked --workspace --release