ci: add workspace cargo test job (exclude Slint UI graph)

Run unit/doc tests for the shipping crates workspace on PRs without
compiling qbz-ui. Fix three green-blockers: local playlist schema for
tests, Track.work fixture, and a stale ListenBrainz doctest.
This commit is contained in:
Afonso Jorge Ramos committed 2026-07-10 00:52:05 +02:00
1 parent 5ba00ab4ef
commit 7a600a60f4
6 files changed
+126 -10

No files matched your search

+68
View File
@@ -0,0 +1,68 @@
name: Test crates
# Unit/doc tests for the shipping Rust workspace (no Slint UI graph).
# Intentionally excludes qbz / qbz-ui / qbz-dac-wizard / qbz-slint-common so
# CI never hits the 20–30 GB UI compile wall. Warm runs are a few seconds;
# cold first run is dominated by dependency compile + rust-cache restore.
on:
pull_request:
branches: [pre-release, main]
paths:
- "crates/**"
- "scripts/cargo-test.sh"
- ".github/workflows/test-crates.yml"
push:
branches: [pre-release]
paths:
- "crates/**"
- "scripts/cargo-test.sh"
- ".github/workflows/test-crates.yml"
workflow_dispatch:
concurrency:
group: test-crates-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: cargo test (workspace, no UI)
runs-on: ubuntu-24.04
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- name: System dependencies
run: |
# Non-UI crates still link Linux audio / D-Bus stubs (qbz-audio).
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential pkg-config \
libasound2-dev libjack-jackd2-dev \
libdbus-1-dev libssl-dev
- name: Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cargo cache
uses: Swatinem/rust-cache@v2
with:
workspaces: crates -> target
shared-key: test-crates-linux
cache-on-failure: true
- name: cargo test
env:
CARGO_TERM_COLOR: always
CARGO_BUILD_JOBS: "2"
# Keyring / credentials tests skip themselves when CI=true.
CI: "true"
run: |
echo "::group::rustc / cargo"
rustc -V
cargo -V
echo "::endgroup::"
START=$(date +%s)
./scripts/cargo-test.sh
END=$(date +%s)
echo "cargo test wall time: $((END - START))s"
+3
View File
@@ -82,3 +82,6 @@ AGENTS.md
# /crates/Cargo.lock # tracked for reproducible CI builds
test-results/
# Isolated cargo test target dir (scripts / agents)
/crates/target-test/
+10 -10
View File
@@ -12,7 +12,7 @@
//! ## Usage
//!
//! ```no_run
//! use qbz_integrations::{ListenBrainzClient, ListenBrainzConfig, ListenType};
//! use qbz_integrations::{ListenBrainzClient, ListenBrainzConfig};
//!
//! async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let config = ListenBrainzConfig {
@@ -23,15 +23,15 @@
//!
//! let client = ListenBrainzClient::with_config(config);
//!
//! // Submit now playing
//! client.submit_listen(
//! ListenType::PlayingNow,
//! "Artist",
//! "Track",
//! Some("Album"),
//! None, // No timestamp for now playing
//! None, // No MBIDs
//! ).await?;
//! // Now playing (no timestamp)
//! client
//! .submit_playing_now("Artist", "Track", Some("Album"), None)
//! .await?;
//!
//! // Scrobble after the track finishes
//! client
//! .submit_listen("Artist", "Track", Some("Album"), 1_700_000_000, None)
//! .await?;
//!
//! Ok(())
//! }
+17
View File
@@ -105,8 +105,25 @@ fn now_ms() -> i64 {
/// Create the local-playlist tables. Idempotent (`IF NOT EXISTS`), run by
/// `LibraryDatabase::open` next to the rest of the schema.
pub fn init_schema(conn: &Connection) -> Result<()> {
// `local_playlists.folder_id` references the shared sidebar folders table
// owned by `LibraryDatabase`. Create it here too so this module's schema
// is self-contained (unit tests open an in-memory DB and only call
// `init_schema`; production already creates `playlist_folders` first).
conn.execute_batch(
r#"
CREATE TABLE IF NOT EXISTS playlist_folders (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
icon_type TEXT DEFAULT 'preset',
icon_preset TEXT DEFAULT 'folder',
icon_color TEXT DEFAULT '#6366f1',
custom_image_path TEXT,
is_hidden INTEGER DEFAULT 0,
position INTEGER DEFAULT 0,
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL
);
CREATE TABLE IF NOT EXISTS local_playlists (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
@@ -327,6 +327,7 @@ mod tests {
id,
title: title.to_string(),
version: None,
work: None,
isrc: None,
duration: 0,
track_number: 0,
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Run the shipping-stack unit/doc tests (crates workspace).
#
# Excludes the Slint UI compile graph (qbz-ui + dependents). Building those for
# tests re-triggers the UI "memory wall" and is unnecessary: qbz-ui has no
# #[test]s, and the binary crate's tests need a full Slint link.
#
# Usage:
# ./scripts/cargo-test.sh # default: workspace minus UI graph
# ./scripts/cargo-test.sh -- --lib # extra args after -- go to cargo test
# CARGO_BUILD_JOBS=1 ./scripts/cargo-test.sh
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
export CARGO_BUILD_JOBS="${CARGO_BUILD_JOBS:-2}"
exec cargo test \
--manifest-path crates/Cargo.toml \
--workspace \
--exclude qbz \
--exclude qbz-ui \
--exclude qbz-dac-wizard \
--exclude qbz-slint-common \
--no-fail-fast \
"$@"