Skip to content

Fix mark the staging file sparse on Windows #664

Fix mark the staging file sparse on Windows

Fix mark the staging file sparse on Windows #664

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
rpm-spec:
name: RPM Spec
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install rpmbuild
run: sudo apt-get update && sudo apt-get install -y rpm
- name: Render the spec and build a source RPM
run: |
set -euo pipefail
# The release workflow ships whatever this produces to Copr, which
# rebuilds the SRPM from the imported spec with no defines of its own.
# Building one here catches a broken render, a stale placeholder or a
# malformed spec at PR time instead of at release time.
VERSION=$(grep -m1 '^version = ' Cargo.toml | cut -d'"' -f2)
RPM_TOP="$RUNNER_TEMP/rpmbuild"
mkdir -p "$RPM_TOP"/{SOURCES,SRPMS,SPECS,BUILD}
git archive --format=tar.gz --prefix="hydra-${VERSION}/" HEAD \
> "$RPM_TOP/SOURCES/hydra-${VERSION}.tar.gz"
# This job checks source-RPM metadata without release signing secrets.
python3 - "$RPM_TOP/SOURCES/hydra-official-plugins.zip" <<'PYZIP'
import sys, zipfile
with zipfile.ZipFile(sys.argv[1], "w") as archive:
archive.writestr("VALIDATION-ONLY.txt", "Not a distributable plugin bundle.\n")
PYZIP
scripts/render-rpm-spec.sh "" "$RPM_TOP/SPECS/hydra.spec"
grep -q "^%global _version ${VERSION}$" "$RPM_TOP/SPECS/hydra.spec"
rpmbuild -bs --define "_topdir $RPM_TOP" "$RPM_TOP/SPECS/hydra.spec"
# The tarball keeps the upstream name (hydra-<version>), but the
# package this spec builds is hydra-download-manager: plain "hydra"
# is THC-Hydra in the distro repos.
ls "$RPM_TOP"/SRPMS/hydra-download-manager-${VERSION}-*.src.rpm
fmt:
name: Code Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check code formatting
run: cargo fmt --all -- --check
clippy:
name: Clippy Linter
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Linux build dependencies (ALSA, X11)
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
pkg-config libasound2-dev libx11-dev libxrandr-dev \
libxcb1-dev libxkbcommon-dev
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Set up Rust cache
uses: Swatinem/rust-cache@v2
# --locked because this is the first job to resolve the whole workspace:
# a manifest version bumped without regenerating Cargo.lock fails here,
# on the pull request, instead of in publish-crates.yml after the merge,
# where `cargo publish --locked` refuses to run at all.
- name: Run clippy checks
run: cargo clippy --locked --all-targets --all-features -- -D warnings
audit:
name: Security Audit
needs: [clippy]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install cargo-audit
uses: taiki-e/install-action@v2
with:
tool: cargo-audit
# Accepted advisories live in .cargo/audit.toml with their rationale;
# anything new, including unmaintained or unsound crates, fails here.
- name: Audit Cargo.lock against the RustSec database
run: cargo audit --deny warnings
test:
name: Test
needs: [fmt, clippy]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Linux build dependencies (ALSA, X11)
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
pkg-config libasound2-dev libx11-dev libxrandr-dev \
libxcb1-dev libxkbcommon-dev
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Set up Rust cache
uses: Swatinem/rust-cache@v2
- name: Run debug tests
run: cargo test --all-targets --all-features
- name: Run release tests
run: cargo test --release --all-targets --all-features
ffi-abi:
name: FFI ABI Conformance
needs: [fmt, clippy]
# Three platforms, because the failures this job exists to catch are
# platform-specific by nature: a struct that packs differently, a symbol the
# linker cannot find, a system library the static archive needs and does not
# declare. A Linux-only run would find none of them.
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
# fetch-depth: 0, and only in this job. The old-header check compiles
# every include/hydra.h this project has ever published against the
# library built here, and it finds them by tag. A shallow clone has no
# tags and the check would have nothing to run.
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Set up Rust cache
uses: Swatinem/rust-cache@v2
# install-action has no cbindgen build and falls back to cargo-binstall,
# whose upgrade step fails on the macOS runner image. Pinned so a newer
# cbindgen cannot change the generated header under the --check below.
- name: Install cbindgen
run: cargo install cbindgen --version 0.29.4 --locked
# The committed header is a published ABI artifact. If it no longer
# matches the Rust definitions it was generated from, third parties are
# compiling against a description of a library that does not exist.
- name: Check include/hydra.h is up to date
if: runner.os != 'Windows'
run: scripts/gen-ffi-header.sh --check
- name: Run the FFI test suite
run: cargo test -p hya-ffi --all-targets
# The Windows runners ship MSVC but do not put cl.exe on PATH, so a C
# compiler has to be arranged for before anything can be compiled.
- name: Set up the MSVC environment
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
# The checks Rust tests structurally cannot perform: that a C compiler and
# a C++ compiler both accept the header, that all three sides agree on
# struct layout, that a second #include is harmless, and that every symbol
# the header promises is really in the archive.
#
# One script on all three platforms - it drives cl where cl is the
# toolchain. A second copy of it in PowerShell here would be a copy that
# nobody can run locally and that drifts from the real one.
- name: Build and run the C ABI smoke test
shell: bash
env:
MSYS_NO_PATHCONV: '1'
MSYS2_ARG_CONV_EXCL: '*'
MSYS2_ENV_CONV_EXCL: '*'
# No published header may be skipped silently. Without this a
# checkout that somehow has no tags would report a pass for a check
# that never ran.
HYDRA_REQUIRE_LEGACY_HEADERS: '1'
run: scripts/ffi-c-example.sh
# The same script again under the other Linux compiler. GCC and Clang
# disagree about which warnings exist and, historically, about how a
# struct with mixed field widths is padded - and the header is a
# published artifact that has to survive both. Only on Linux: macOS has
# one system compiler and Windows has MSVC, both already covered above.
- name: Build and run the C ABI smoke test with Clang
if: runner.os == 'Linux'
shell: bash
env:
CC: clang
CXX: clang++
HYDRA_REQUIRE_LEGACY_HEADERS: '1'
run: scripts/ffi-c-example.sh
# And whether the change was ALLOWED. header-check above proves the header
# still matches the Rust; this proves the Rust did not move anything ABI 1
# froze. Last, because it also verifies that every symbol the baseline
# promises is really in the archive - and the archive is what the step
# above builds. The rules, and what to do when this fails, are in
# docs/ffi/ABI.md.
- name: Check the ABI 1 stability contract
shell: bash
run: scripts/ffi-abi-compat.sh
coverage:
name: Code Coverage
runs-on: ubuntu-latest
needs: [fmt, clippy]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Linux build dependencies (ALSA, X11)
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
pkg-config libasound2-dev libx11-dev libxrandr-dev \
libxcb1-dev libxkbcommon-dev
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools
- name: Set up Rust cache
uses: Swatinem/rust-cache@v2
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov
- name: Generate coverage report
run: |
cargo llvm-cov --workspace --all-features --lcov --output-path lcov.info \
--ignore-filename-regex '(/examples/|/benches/)'
- name: Include terminal plugin E2E in coverage
run: |
rustup target add wasm32-wasip1
cargo build --manifest-path examples/plugins/direct/Cargo.toml --release --target wasm32-wasip1
HYDRA_E2E_SKIP_BUILD=1 HYDRA_E2E_CLI="$PWD/target/llvm-cov-target/debug/hydra" \
LLVM_PROFILE_FILE="$PWD/target/llvm-cov-target/hydra-tui-%p-%m.profraw" \
python3 scripts/plugins/plugin-tui-e2e.py
cargo llvm-cov report --lcov --output-path lcov.info \
--ignore-filename-regex '(/examples/|/benches/)'
- name: Coverage summary
run: |
cargo llvm-cov report --summary-only \
--ignore-filename-regex '(/examples/|/benches/)'
- name: Upload to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: false
plugin-sdks:
name: Wasm plugin SDKs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-wasip1
- uses: actions/setup-go@v5
with:
go-version: '1.24'
- uses: actions/setup-node@v4
with:
node-version: '22'
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: Swatinem/rust-cache@v2
- name: Verify script runtime lockfile
run: cargo metadata --locked --manifest-path plugins/sdk/runtime/Cargo.toml --format-version 1 > /dev/null
- name: Install WASI C compiler
run: |
curl --fail --location --retry 3 https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-34/wasi-sdk-34.0-x86_64-linux.tar.gz -o "$RUNNER_TEMP/wasi-sdk.tar.gz"
tar -xzf "$RUNNER_TEMP/wasi-sdk.tar.gz" -C "$RUNNER_TEMP"
echo "WASI_SDK_PATH=$RUNNER_TEMP/wasi-sdk-34.0-x86_64-linux" >> "$GITHUB_ENV"
- name: Scaffold, build, validate and execute all five SDKs
run: python3 plugins/sdk/test.py
- name: Test official bundle staging
run: python3 -m unittest discover -s scripts/plugins -p 'test_stage_official.py'
- name: Test and package the official YouTube plugin
run: |
cargo test --manifest-path plugins/hydra-youtube/Cargo.toml
python3 plugins/build.py hydra-youtube
- name: Verify package signing with disposable keys
run: |
sudo apt-get update && sudo apt-get install -y minisign
cargo build -p hya-cli --bin hydra
python3 scripts/plugins/signing-e2e.py
- name: Exercise plugin lifecycle and download through the CLI
run: python3 scripts/plugins/plugin-e2e.py
- name: Exercise terminal plugin management through a PTY
run: python3 scripts/plugins/plugin-tui-e2e.py