perf(repo): parallelise api tests and cache image builds in ghcr (#1984)

This commit is contained in:
Hampus authored and GitHub committed 2026-08-24 21:24:39 +02:00
1 parent 3afad20e36
commit c226eb7211
38 files changed
+701 -264

No files matched your search

+22 -20
View File
@@ -6,9 +6,6 @@ use anyhow::Result;
use std::env;
use std::path::Path;
const DEFAULT_TEST_WORKSPACE_CONCURRENCY: &str = "2";
const DEFAULT_API_TEST_WORKERS: &str = "2";
fn task_run(args: &[&str]) -> Result<()> {
run_command(
args,
@@ -22,8 +19,6 @@ fn task_run(args: &[&str]) -> Result<()> {
fn test_env() -> Vec<(String, Option<String>)> {
let nats_url = env::var("FLUXER_NATS_URL").unwrap_or_else(|_| default_test_nats_url());
let api_workers =
env::var("API_TEST_MAX_WORKERS").unwrap_or_else(|_| DEFAULT_API_TEST_WORKERS.to_owned());
vec![
("FLUXER_NATS_URL".to_owned(), Some(nats_url.clone())),
(
@@ -32,12 +27,7 @@ fn test_env() -> Vec<(String, Option<String>)> {
),
(
"FLUXER_NATS_JETSTREAM_URL".to_owned(),
Some(env::var("FLUXER_NATS_JETSTREAM_URL").unwrap_or_else(|_| nats_url.clone())),
),
("API_TEST_MAX_WORKERS".to_owned(), Some(api_workers.clone())),
(
"API_TEST_MAX_CONCURRENCY".to_owned(),
Some(env::var("API_TEST_MAX_CONCURRENCY").unwrap_or(api_workers)),
Some(env::var("FLUXER_NATS_JETSTREAM_URL").unwrap_or(nats_url)),
),
]
}
@@ -68,27 +58,39 @@ pub fn run_typecheck() -> Result<i32> {
pub fn run_test() -> Result<i32> {
run_generators(false)?;
let workspace_concurrency = env::var("PNPM_TEST_WORKSPACE_CONCURRENCY")
.unwrap_or_else(|_| DEFAULT_TEST_WORKSPACE_CONCURRENCY.to_owned());
let env = test_env();
run_command(
&[
"pnpm",
"-r",
&format!("--workspace-concurrency={workspace_concurrency}"),
let mut args = vec!["pnpm".to_owned(), "-r".to_owned()];
if let Ok(concurrency) = env::var("PNPM_TEST_WORKSPACE_CONCURRENCY") {
args.push(format!("--workspace-concurrency={concurrency}"));
}
args.extend(
[
"--filter",
"!fluxer_api",
"--filter",
"!fluxer",
"--filter",
"!fluxer_desktop",
"--if-present",
"test",
],
]
.into_iter()
.map(str::to_owned),
);
let env = test_env();
run_command(
&args.iter().map(String::as_str).collect::<Vec<_>>(),
RunOptions {
env: env.clone(),
load_default_env: false,
..RunOptions::default()
},
)?;
task_run(&[
"cargo",
"test",
"--manifest-path",
"fluxer_desktop/native/rust/Cargo.toml",
])?;
run_command(
&["pnpm", "--filter", "fluxer_api", "test"],
RunOptions {