CI / Formatting, tests and builds (push) Successful in 2m49s
Le runner n'a pas Nix: l'étape Windows de la CI (#93) était sautée. Elle prend maintenant aussi le chemin des paquets du système: `gcc-mingw-w64-x86-64` et la cible rustup `x86_64-pc-windows-gnu`. `scripts/build-libvpx.sh` sait construire la libvpx statique pour Windows (LIBVPX_TARGET, CROSS), une fois, dans le cache de la CI. Sans l'un ni l'autre, l'étape le dit et passe, comme celles de PipeWire et de GStreamer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
213 lines
8.7 KiB
YAML
213 lines
8.7 KiB
YAML
# rustscreen continuous integration.
|
|
#
|
|
# It runs on Gitea, on the `rustscreen-ci` runner, which is a host and not a
|
|
# container: the machine has no Docker daemon, but it has cargo, node and nasm.
|
|
# This runner is registered for this repository: Exoledge's only sees jobs from
|
|
# the Exoledge organization, and rustscreen lives under `heap`. The label is
|
|
# explicit so that an environment change shows up in the diff rather than in
|
|
# the middle of a run.
|
|
#
|
|
# Two precautions that cost a lot when forgotten:
|
|
#
|
|
# - libvpx is not provided by the system. `env-libvpx-sys` requires an explicit
|
|
# prefix, so the pipeline builds libvpx once into the cache and reuses it.
|
|
# Without that cache, every run would pay ten minutes of C compilation again.
|
|
# - caches are kept per repository. The runner is shared with other projects:
|
|
# a common `CARGO_TARGET_DIR` would make unrelated builds trample each other.
|
|
|
|
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
integrate:
|
|
name: Formatting, tests and builds
|
|
runs-on: rustscreen-ci
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Tools and caches
|
|
run: |
|
|
set -euo pipefail
|
|
# Caches live outside the repository, in a directory specific to this
|
|
# project: the CI machine is shared with others.
|
|
cache="${RUSTSCREEN_CACHE_DIR:-$HOME/.cache/rustscreen-ci}"
|
|
mkdir -p "$cache"
|
|
{
|
|
echo "CARGO_TARGET_DIR=$cache/cargo-target"
|
|
echo "VPX_PREFIX=$cache/libvpx"
|
|
echo "npm_config_cache=$cache/npm"
|
|
} >> "$GITHUB_ENV"
|
|
# nasm, file and desktop-file-validate may be installed by the runner's
|
|
# administrator in ~/.local/bin, outside the session PATH. When they
|
|
# are missing there, the pipeline falls back on what the system provides.
|
|
if [ -d "$HOME/.local/bin" ]; then
|
|
echo "PATH=$HOME/.local/bin:$PATH" >> "$GITHUB_ENV"
|
|
fi
|
|
|
|
- name: Versions
|
|
run: |
|
|
set -euo pipefail
|
|
cargo --version
|
|
cargo clippy --version
|
|
cargo fmt --version
|
|
node --version
|
|
npm --version
|
|
nasm -v || echo "nasm missing: libvpx will be built without an assembler, slower encoding"
|
|
|
|
- name: libvpx library
|
|
run: |
|
|
set -euo pipefail
|
|
# The version is pinned by the script: beyond 1.13, the pre-generated
|
|
# bindings of `env-libvpx-sys` are no longer enough.
|
|
if [ -f "$VPX_PREFIX/lib/libvpx.a" ]; then
|
|
echo "libvpx already built in $VPX_PREFIX"
|
|
else
|
|
./scripts/build-libvpx.sh "$VPX_PREFIX"
|
|
fi
|
|
{
|
|
echo "VPX_LIB_DIR=$VPX_PREFIX/lib"
|
|
echo "VPX_INCLUDE_DIR=$VPX_PREFIX/include"
|
|
echo "VPX_VERSION=1.13.0"
|
|
} >> "$GITHUB_ENV"
|
|
|
|
- name: Viewer dependencies
|
|
run: |
|
|
set -euo pipefail
|
|
cd apps/viewer
|
|
# `npm ci` rather than `npm install`: the lock file is the reference,
|
|
# the pipeline negotiates no version.
|
|
npm ci --no-audit --no-fund
|
|
|
|
- name: Viewer lint and types
|
|
run: |
|
|
set -euo pipefail
|
|
cd apps/viewer
|
|
npm run lint
|
|
npx tsc --noEmit
|
|
|
|
- name: Viewer tests
|
|
run: |
|
|
set -euo pipefail
|
|
cd apps/viewer
|
|
npm test
|
|
|
|
- name: Viewer bundle
|
|
run: |
|
|
set -euo pipefail
|
|
cd apps/viewer
|
|
npm run build
|
|
|
|
- name: Licenses
|
|
# Every shipped dependency stays compatible with Apache-2.0 (#59): a
|
|
# new crate under GPL, or without a license, fails here.
|
|
run: node scripts/check-licenses.mjs
|
|
|
|
- name: Formatting
|
|
run: cargo fmt --all --check
|
|
|
|
- name: Clippy
|
|
run: cargo clippy --workspace --all-targets -- -D warnings
|
|
|
|
- name: Tests
|
|
# The `export_bindings` tests write the TypeScript types: they run
|
|
# here, with the rest, and the "up to date" step only compares. A
|
|
# second cargo invocation, with different features, rebuilt half of
|
|
# the workspace (34 s, #78).
|
|
run: cargo test --workspace
|
|
|
|
- name: Wayland capture (PipeWire)
|
|
run: |
|
|
set -euo pipefail
|
|
# The feature requires libpipewire-0.3 and libclang (bindgen). The
|
|
# runner does not always have them: without them, the step says so and
|
|
# passes, and the release is the one that fails (see release.yml).
|
|
if pkg-config --exists libpipewire-0.3; then
|
|
cargo clippy -p rs-capture -p rs-session --features rs-session/pipewire --all-targets -- -D warnings
|
|
cargo test -p rs-capture --features pipewire
|
|
else
|
|
echo "libpipewire-0.3 missing on the runner: Wayland capture not checked"
|
|
fi
|
|
|
|
- name: Hardware encoding (VA-API)
|
|
run: |
|
|
set -euo pipefail
|
|
# The `vaapi` feature links GStreamer (#57). Without its development
|
|
# files the step says so and passes, like the PipeWire one. The
|
|
# encoder tests skip themselves on a runner without a GPU.
|
|
if pkg-config --exists gstreamer-app-1.0 gstreamer-video-1.0; then
|
|
cargo clippy -p rs-codec -p rs-session --features rs-session/vaapi --all-targets -- -D warnings
|
|
cargo test -p rs-codec --features vaapi
|
|
else
|
|
echo "GStreamer development files missing on the runner: hardware encoding not checked"
|
|
fi
|
|
|
|
- name: Windows build (cross-compiled)
|
|
run: |
|
|
set -euo pipefail
|
|
# Windows is built from Linux with mingw-w64 (#93). With Nix, the
|
|
# `windows` shell of the flake brings everything. Without it, the
|
|
# runner needs `gcc-mingw-w64-x86-64` and
|
|
# `rustup target add x86_64-pc-windows-gnu`; libvpx for Windows is
|
|
# then built once into the cache. Missing both, the step says so and
|
|
# passes, like the PipeWire one.
|
|
if command -v nix >/dev/null 2>&1; then
|
|
nix develop .#windows -c cargo clippy --workspace --all-targets -- -D warnings
|
|
nix develop .#windows -c cargo build -p rs-session --bin rustscreen-cli
|
|
elif command -v x86_64-w64-mingw32-gcc >/dev/null 2>&1 \
|
|
&& rustup target list --installed 2>/dev/null | grep -qx x86_64-pc-windows-gnu; then
|
|
win_vpx="$(dirname "$VPX_PREFIX")/libvpx-windows"
|
|
if [ ! -f "$win_vpx/lib/libvpx.a" ]; then
|
|
LIBVPX_TARGET=x86_64-win64-gcc CROSS=x86_64-w64-mingw32- \
|
|
./scripts/build-libvpx.sh "$win_vpx"
|
|
fi
|
|
export CARGO_BUILD_TARGET=x86_64-pc-windows-gnu
|
|
export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc
|
|
export CC_x86_64_pc_windows_gnu=x86_64-w64-mingw32-gcc
|
|
export AR_x86_64_pc_windows_gnu=x86_64-w64-mingw32-ar
|
|
export VPX_LIB_DIR="$win_vpx/lib" VPX_INCLUDE_DIR="$win_vpx/include" VPX_STATIC=1
|
|
export CARGO_TARGET_DIR="$CARGO_TARGET_DIR/windows"
|
|
cargo clippy --workspace --all-targets -- -D warnings
|
|
cargo build -p rs-session --bin rustscreen-cli
|
|
else
|
|
echo "neither Nix nor mingw-w64 with the Windows rustup target: the Windows build is not checked"
|
|
fi
|
|
|
|
- name: The binary starts
|
|
run: |
|
|
set -euo pipefail
|
|
# The pipeline does not stop at tests: it checks that the binary
|
|
# starts, because a product that does not start passes every unit
|
|
# test. The integration tests have already built it.
|
|
"$CARGO_TARGET_DIR/debug/rustscreen-cli" --version
|
|
|
|
- name: Release binary
|
|
# On main only: the whole stack in release costs more than a minute,
|
|
# and the release workflow rebuilds it anyway (#78).
|
|
if: github.event_name == 'push'
|
|
run: |
|
|
set -euo pipefail
|
|
cargo build --release -p rs-session --bin rustscreen-cli
|
|
"$CARGO_TARGET_DIR/release/rustscreen-cli" --version
|
|
|
|
- name: The TypeScript protocol is up to date
|
|
run: |
|
|
set -euo pipefail
|
|
# The protocol types are generated from Rust. A gap between the
|
|
# repository and the generated output means the viewer compiles
|
|
# against a stale protocol, which only shows in production.
|
|
# Written by the "Tests" step: all that is left is to compare.
|
|
# `status` rather than `diff`: a new type, never committed, counts too.
|
|
drift=$(git status --porcelain -- apps/viewer/src/proto apps/desktop/src/bindings)
|
|
if [ -n "$drift" ]; then
|
|
echo "$drift" >&2
|
|
echo "generated TypeScript types are out of date: run make proto and commit" >&2
|
|
exit 1
|
|
fi
|