mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
chore(repo): remove dead code and useless tests (#3375)
This commit is contained in:
1 parent
7e177a1c90
commit
1cd62eb661
1391 files changed
+783
-120415
No files matched your search
@@ -416,8 +416,6 @@ fn gather_wasm_inputs(project_root: &Path) -> Result<StepInputs> {
|
||||
PathBuf::from("../tools/ci/src/app_wasm.rs"),
|
||||
PathBuf::from("../tools/ci/src/common.rs"),
|
||||
PathBuf::from("../tools/ci/src/lib.rs"),
|
||||
PathBuf::from("../tools/ci/templates/libfluxcore_wrapper.js"),
|
||||
PathBuf::from("../tools/ci/templates/libfluxcore_wrapper.d.ts"),
|
||||
markdown_parser_rust_dir.join("Cargo.toml"),
|
||||
],
|
||||
)?;
|
||||
@@ -575,41 +573,3 @@ fn quote_arg(arg: &str) -> String {
|
||||
format!("{arg:?}")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn rel_path_keys_are_posix_like() {
|
||||
assert_eq!(
|
||||
rel_path_key(Path::new("scripts/GenerateColorSystem.ts")),
|
||||
"scripts/GenerateColorSystem.ts"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wasm_inputs_cover_the_libfluxwebp_sources_and_headers() {
|
||||
let app_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fluxer_app");
|
||||
let inputs = gather_wasm_inputs(&app_dir).expect("gather wasm inputs");
|
||||
|
||||
for key in [
|
||||
"rust/libfluxwebp/Cargo.toml",
|
||||
"rust/libfluxwebp/Cargo.lock",
|
||||
"rust/libfluxwebp/src/lib.rs",
|
||||
"rust/libfluxwebp/shim/stdlib.h",
|
||||
"rust/libfluxwebp/simd/emmintrin.h",
|
||||
] {
|
||||
assert!(inputs.contains_key(key), "missing {key}");
|
||||
}
|
||||
assert!(inputs.keys().all(|key| !key.contains("/target/")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn display_command_quotes_globs() {
|
||||
assert_eq!(
|
||||
display_command("tcm", &["src", "--pattern", "**/*.module.css"]),
|
||||
"tcm src --pattern \"**/*.module.css\""
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -532,7 +532,6 @@ fn tree_differences(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::common::parse_version_instant;
|
||||
use chrono::{DateTime, TimeZone, Utc};
|
||||
use std::ffi::OsString;
|
||||
|
||||
@@ -571,16 +570,6 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_invalid_calver_time() {
|
||||
assert_eq!(
|
||||
parse_version_instant("2026.520.246000")
|
||||
.unwrap_err()
|
||||
.to_string(),
|
||||
"Invalid build version date/time: 2026.520.246000"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ghcr_auth_config_merges_existing_auths() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
@@ -624,35 +613,6 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn build_command_sets_bake_environment() {
|
||||
let command = CommandSpec::new("docker")
|
||||
.args(["buildx", "bake", "-f", "fluxer_app_proxy/docker-bake.hcl"])
|
||||
.env("IMAGE_REPO", "ghcr.io/example/fluxer-app-proxy")
|
||||
.env("BUILD_VERSION", "2026.520.1")
|
||||
.env("PUBLIC_ASSET_BASE_URL", DEFAULT_PUBLIC_ASSET_BASE_URL);
|
||||
|
||||
assert_eq!(command.program, OsString::from("docker"));
|
||||
assert_eq!(
|
||||
command.args,
|
||||
vec![
|
||||
OsString::from("buildx"),
|
||||
OsString::from("bake"),
|
||||
OsString::from("-f"),
|
||||
OsString::from("fluxer_app_proxy/docker-bake.hcl"),
|
||||
]
|
||||
);
|
||||
assert!(command.env.contains(&(
|
||||
OsString::from("BUILD_VERSION"),
|
||||
OsString::from("2026.520.1")
|
||||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hosted_bake_trims_the_local_asset_tree_by_default() {
|
||||
assert_eq!(DEFAULT_APP_PROXY_BUNDLE_LOCAL_ASSETS, "false");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dockerfile_guards_the_trim_on_an_absolute_asset_base_url() {
|
||||
let dockerfile = include_str!("../../../fluxer_app_proxy/Dockerfile");
|
||||
@@ -967,70 +927,6 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dockerfile_injects_one_canonical_asset_tree_into_every_architecture() {
|
||||
let dockerfile = include_str!("../../../fluxer_app_proxy/Dockerfile");
|
||||
for entry in [
|
||||
"ARG APP_ASSETS_REF=app-assets",
|
||||
"ARG APP_ASSETS_PLATFORM=$BUILDPLATFORM",
|
||||
"FROM --platform=${APP_ASSETS_PLATFORM} ${APP_ASSETS_REF} AS app-static",
|
||||
"COPY --from=app-static /assets ./static/",
|
||||
] {
|
||||
assert!(
|
||||
dockerfile.contains(entry),
|
||||
"every architecture must serve the injected canonical tree, so the Dockerfile must contain {entry}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dockerfile_prepares_the_asset_tree_once_before_the_architecture_stages() {
|
||||
let dockerfile = include_str!("../../../fluxer_app_proxy/Dockerfile");
|
||||
let canonical = dockerfile
|
||||
.split("FROM alpine:3.24 AS app-assets")
|
||||
.nth(1)
|
||||
.expect("app-assets stage");
|
||||
let (canonical, per_architecture) = canonical
|
||||
.split_once("AS app-static")
|
||||
.expect("app-static stage");
|
||||
|
||||
for entry in ["apk add --no-cache brotli", "precompress_assets.sh"] {
|
||||
assert!(
|
||||
canonical.contains(entry),
|
||||
"the canonical asset tree is prepared once, so {entry} must run in the app-assets stage"
|
||||
);
|
||||
assert!(
|
||||
!per_architecture.contains(entry),
|
||||
"{entry} must not run again per architecture or the trees stop being byte-identical"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bake_publishes_the_canonical_asset_image() {
|
||||
let bake = include_str!("../../../fluxer_app_proxy/docker-bake.hcl");
|
||||
for entry in [
|
||||
"target \"app-assets-image\"",
|
||||
"${BUILD_VERSION}-assets",
|
||||
"type=registry",
|
||||
"APP_ASSETS_REF = APP_ASSETS_REF",
|
||||
"APP_ASSETS_PLATFORM = APP_ASSETS_PLATFORM",
|
||||
] {
|
||||
assert!(bake.contains(entry), "docker-bake.hcl must contain {entry}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn canonical_assets_platform_falls_back_to_the_bake_default() {
|
||||
let bake = include_str!("../../../fluxer_app_proxy/docker-bake.hcl");
|
||||
let declared =
|
||||
format!("variable \"APP_ASSETS_PLATFORM\" {{ default = \"{AMD64_PLATFORM}\" }}");
|
||||
assert!(
|
||||
bake.contains(&declared),
|
||||
"the parity gate reads APP_ASSETS_PLATFORM and falls back to {AMD64_PLATFORM}, so docker-bake.hcl must declare the same default"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn self_hosted_workflow_keeps_assets_same_origin() {
|
||||
let workflow = include_str!("../../../.github/workflows/build-app-proxy-self-hosted.yaml");
|
||||
|
||||
@@ -13,8 +13,9 @@ use tempfile::TempDir;
|
||||
|
||||
const LIBFLUXCORE_WASM_BINDGEN_VERSION: &str = "0.2.128";
|
||||
const LIBFLUXCORE_WASM_SIZE_BUDGET_BYTES: u64 = 300 * 1024;
|
||||
const LIBFLUXCORE_WRAPPER_JS: &str = include_str!("../templates/libfluxcore_wrapper.js");
|
||||
const LIBFLUXCORE_WRAPPER_DTS: &str = include_str!("../templates/libfluxcore_wrapper.d.ts");
|
||||
const LIBFLUXCORE_INDEX: &str = "// SPDX-License-Identifier: AGPL-3.0-or-later\n\n\
|
||||
export * from './libfluxcore_bindgen.js';\n\
|
||||
export {default} from './libfluxcore_bindgen.js';\n";
|
||||
const LIBFLUXWEBP_SIMD_WASM_SIZE_BUDGET_BYTES: u64 = 672 * 1024;
|
||||
const LIBFLUXWEBP_SCALAR_WASM_SIZE_BUDGET_BYTES: u64 = 288 * 1024;
|
||||
const LIBFLUXWEBP_WASM_IMPORT_MODULE: &str = "./libfluxwebp_bg.js";
|
||||
@@ -27,12 +28,6 @@ pub struct BuildAppWasmArgs {
|
||||
app_dir: Option<PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Args, Clone)]
|
||||
pub struct BuildMarkdownParserWasmArgs {
|
||||
#[arg(long)]
|
||||
app_dir: Option<PathBuf>,
|
||||
}
|
||||
|
||||
pub fn run_build_app_wasm(args: BuildAppWasmArgs) -> Result<()> {
|
||||
let app_dir = resolve_app_dir(args.app_dir)?;
|
||||
build_markdown_parser_wasm(&app_dir)?;
|
||||
@@ -40,11 +35,6 @@ pub fn run_build_app_wasm(args: BuildAppWasmArgs) -> Result<()> {
|
||||
build_libfluxwebp_wasm(&app_dir)
|
||||
}
|
||||
|
||||
pub fn run_build_markdown_parser_wasm(args: BuildMarkdownParserWasmArgs) -> Result<()> {
|
||||
let app_dir = resolve_app_dir(args.app_dir)?;
|
||||
build_markdown_parser_wasm(&app_dir)
|
||||
}
|
||||
|
||||
const WASM_CC_ENV: &str = "CC_wasm32_unknown_unknown";
|
||||
const WASM_AR_ENV: &str = "AR_wasm32_unknown_unknown";
|
||||
|
||||
@@ -255,21 +245,13 @@ fn build_libfluxcore_wasm(app_dir: &Path) -> Result<()> {
|
||||
)
|
||||
.with_context(|| format!("Failed to copy {}", bindgen_wasm_dts_path.display()))?;
|
||||
|
||||
fs::write(
|
||||
out_dir.join("libfluxcore.js"),
|
||||
libfluxcore_index_js_content(),
|
||||
)
|
||||
.with_context(|| {
|
||||
fs::write(out_dir.join("libfluxcore.js"), LIBFLUXCORE_INDEX).with_context(|| {
|
||||
format!(
|
||||
"Failed to write {}",
|
||||
out_dir.join("libfluxcore.js").display()
|
||||
)
|
||||
})?;
|
||||
fs::write(
|
||||
out_dir.join("libfluxcore.d.ts"),
|
||||
libfluxcore_index_dts_content(),
|
||||
)
|
||||
.with_context(|| {
|
||||
fs::write(out_dir.join("libfluxcore.d.ts"), LIBFLUXCORE_INDEX).with_context(|| {
|
||||
format!(
|
||||
"Failed to write {}",
|
||||
out_dir.join("libfluxcore.d.ts").display()
|
||||
@@ -680,25 +662,6 @@ fn write_with_spdx(path: &Path, content: &str) -> Result<()> {
|
||||
.with_context(|| format!("Failed to write {}", path.display()))
|
||||
}
|
||||
|
||||
fn libfluxcore_index_js_content() -> String {
|
||||
format!(
|
||||
"// SPDX-License-Identifier: AGPL-3.0-or-later\n\n\
|
||||
import {{crop_rotate_rgba_raw}} from './libfluxcore_bindgen.js';\n\
|
||||
{LIBFLUXCORE_WRAPPER_JS}\n\
|
||||
export * from './libfluxcore_bindgen.js';\n\
|
||||
export {{default}} from './libfluxcore_bindgen.js';\n"
|
||||
)
|
||||
}
|
||||
|
||||
fn libfluxcore_index_dts_content() -> String {
|
||||
format!(
|
||||
"// SPDX-License-Identifier: AGPL-3.0-or-later\n\n\
|
||||
export * from './libfluxcore_bindgen.js';\n\
|
||||
export {{default}} from './libfluxcore_bindgen.js';\n\n\
|
||||
{LIBFLUXCORE_WRAPPER_DTS}"
|
||||
)
|
||||
}
|
||||
|
||||
fn libfluxcore_package_json_content() -> String {
|
||||
let manifest = serde_json::json!({
|
||||
"name": "libfluxcore",
|
||||
@@ -733,7 +696,7 @@ fn libfluxcore_package_json_content() -> String {
|
||||
fn libfluxcore_readme_content() -> &'static str {
|
||||
"<!-- SPDX-License-Identifier: AGPL-3.0-or-later -->\n\
|
||||
# libfluxcore\n\n\
|
||||
Rust WebAssembly helpers and JavaScript codec wrappers for Fluxer media processing.\n"
|
||||
Rust WebAssembly helpers for Fluxer media processing.\n"
|
||||
}
|
||||
|
||||
fn markdown_wasm_bytes_content(wasm: &[u8]) -> String {
|
||||
@@ -779,16 +742,6 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn markdown_wasm_bytes_content_matches_legacy_node_output() {
|
||||
assert_eq!(
|
||||
markdown_wasm_bytes_content(b"hello"),
|
||||
"// SPDX-License-Identifier: AGPL-3.0-or-later\n\n\
|
||||
export const MARKDOWN_PARSER_WASM_BASE64 =\n\
|
||||
\t'aGVsbG8=';\n"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn libfluxcore_build_keeps_its_output_in_the_crate_target_dir() {
|
||||
let package_dir = Path::new("/repo/fluxer_app/rust/libfluxcore");
|
||||
@@ -817,14 +770,6 @@ export const MARKDOWN_PARSER_WASM_BASE64 =\n\
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn libfluxcore_index_reexports_bindgen_module() {
|
||||
let content = libfluxcore_index_js_content();
|
||||
assert!(content.contains("import {crop_rotate_rgba_raw} from './libfluxcore_bindgen.js';"));
|
||||
assert!(content.contains("export * from './libfluxcore_bindgen.js';"));
|
||||
assert!(content.contains("export function crop_rotate_rgba("));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn libfluxcore_bindgen_js_reset_hook_is_inserted() {
|
||||
let content =
|
||||
|
||||
+2
-17
@@ -1,8 +1,8 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use crate::common::{
|
||||
CALVER_SCHEME, CalverEnv, append_github_env, append_github_output, micro_segment,
|
||||
month_day_segment, parse_version_instant, resolve_calver, trim_option,
|
||||
CALVER_SCHEME, CalverEnv, append_github_output, micro_segment, month_day_segment,
|
||||
parse_version_instant, resolve_calver, trim_option,
|
||||
};
|
||||
use anyhow::Result;
|
||||
use chrono::{Datelike, Timelike, Utc};
|
||||
@@ -13,10 +13,6 @@ use std::env;
|
||||
pub struct ResolveCalverArgs {
|
||||
#[arg(long)]
|
||||
github_output: bool,
|
||||
#[arg(long)]
|
||||
github_env: bool,
|
||||
#[arg(long, default_value = "BUILD_VERSION")]
|
||||
env_name: String,
|
||||
}
|
||||
|
||||
pub fn run(args: ResolveCalverArgs) -> Result<()> {
|
||||
@@ -37,9 +33,6 @@ pub fn run(args: ResolveCalverArgs) -> Result<()> {
|
||||
("calver_scheme", CALVER_SCHEME),
|
||||
])?;
|
||||
}
|
||||
if args.github_env {
|
||||
append_github_env(&[(args.env_name.as_str(), resolved.as_str())])?;
|
||||
}
|
||||
println!("{resolved}");
|
||||
Ok(())
|
||||
}
|
||||
@@ -128,12 +121,4 @@ mod tests {
|
||||
|
||||
assert_eq!(version, "2026.109.0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn calver_rejects_invalid_time() {
|
||||
assert_eq!(
|
||||
calver_outputs("2026.520.246000").unwrap_err().to_string(),
|
||||
"Invalid build version date/time: 2026.520.246000"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -333,115 +333,4 @@ mod tests {
|
||||
|
||||
assert_eq!(missing_app_wasm_artifact(root), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn image_dockerfiles_include_the_release_label_block() {
|
||||
const REQUIRED: [&str; 8] = [
|
||||
"LABEL org.opencontainers.image.vendor=\"Fluxer\"",
|
||||
"LABEL org.opencontainers.image.url=\"https://fluxer.app\"",
|
||||
"LABEL org.opencontainers.image.documentation=\"https://docs.fluxer.app\"",
|
||||
"LABEL org.opencontainers.image.source=\"https://github.com/fluxerapp/fluxer\"",
|
||||
"LABEL org.opencontainers.image.version=\"${BUILD_VERSION}\"",
|
||||
"LABEL org.opencontainers.image.revision=\"${SOURCE_SHA}\"",
|
||||
"LABEL org.opencontainers.image.created=\"${SOURCE_DATE}\"",
|
||||
"LABEL app.fluxer.build-version=\"${BUILD_VERSION}\"",
|
||||
];
|
||||
|
||||
for (name, title, dockerfile) in [
|
||||
(
|
||||
"fluxer_admin",
|
||||
"fluxer-admin",
|
||||
include_str!("../../../fluxer_admin/Dockerfile"),
|
||||
),
|
||||
(
|
||||
"fluxer_api",
|
||||
"fluxer-api",
|
||||
include_str!("../../../fluxer_api/Dockerfile"),
|
||||
),
|
||||
(
|
||||
"fluxer_app_proxy",
|
||||
"fluxer-app-proxy",
|
||||
include_str!("../../../fluxer_app_proxy/Dockerfile"),
|
||||
),
|
||||
(
|
||||
"fluxer_docs",
|
||||
"fluxer-docs",
|
||||
include_str!("../../../fluxer_docs/Dockerfile"),
|
||||
),
|
||||
(
|
||||
"fluxer_gateway",
|
||||
"fluxer-gateway",
|
||||
include_str!("../../../fluxer_gateway/Dockerfile"),
|
||||
),
|
||||
(
|
||||
"fluxer_gifs",
|
||||
"fluxer-gifs",
|
||||
include_str!("../../../fluxer_gifs/Dockerfile"),
|
||||
),
|
||||
(
|
||||
"fluxer_media_proxy",
|
||||
"fluxer-media-proxy",
|
||||
include_str!("../../../fluxer_media_proxy/Dockerfile"),
|
||||
),
|
||||
(
|
||||
"fluxer_messages",
|
||||
"fluxer-messages",
|
||||
include_str!("../../../fluxer_messages/Dockerfile"),
|
||||
),
|
||||
(
|
||||
"fluxer_push",
|
||||
"fluxer-push",
|
||||
include_str!("../../../fluxer_push/Dockerfile"),
|
||||
),
|
||||
(
|
||||
"fluxer_snowflakes",
|
||||
"fluxer-snowflakes",
|
||||
include_str!("../../../fluxer_snowflakes/Dockerfile"),
|
||||
),
|
||||
(
|
||||
"fluxer_static",
|
||||
"fluxer-static",
|
||||
include_str!("../../../fluxer_static/Dockerfile"),
|
||||
),
|
||||
(
|
||||
"fluxer_unfurl",
|
||||
"fluxer-unfurl",
|
||||
include_str!("../../../fluxer_unfurl/Dockerfile"),
|
||||
),
|
||||
(
|
||||
"fluxer_users",
|
||||
"fluxer-users",
|
||||
include_str!("../../../fluxer_users/Dockerfile"),
|
||||
),
|
||||
] {
|
||||
assert!(
|
||||
dockerfile.contains("ARG SOURCE_SHA"),
|
||||
"{name}/Dockerfile must declare ARG SOURCE_SHA"
|
||||
);
|
||||
assert!(
|
||||
dockerfile.contains("ARG SOURCE_DATE"),
|
||||
"{name}/Dockerfile must declare ARG SOURCE_DATE"
|
||||
);
|
||||
assert!(
|
||||
dockerfile.contains(&format!("LABEL org.opencontainers.image.title=\"{title}\"")),
|
||||
"{name}/Dockerfile must declare the title {title}"
|
||||
);
|
||||
let licenses = match name {
|
||||
"fluxer_static" => "AGPL-3.0-or-later AND CC-BY-SA-4.0 AND CC-BY-4.0",
|
||||
_ => "AGPL-3.0-or-later",
|
||||
};
|
||||
assert!(
|
||||
dockerfile.contains(&format!(
|
||||
"LABEL org.opencontainers.image.licenses=\"{licenses}\""
|
||||
)),
|
||||
"{name}/Dockerfile must declare the licenses {licenses}"
|
||||
);
|
||||
for label in REQUIRED {
|
||||
assert!(
|
||||
dockerfile.contains(label),
|
||||
"{name}/Dockerfile must declare {label}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6077,14 +6077,6 @@ fn print_tree(root: &Path, max_depth: usize) -> Result<()> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::common::parse_version_instant;
|
||||
use chrono::{DateTime, TimeZone, Utc};
|
||||
|
||||
fn dt(year: i32, month: u32, day: u32, hour: u32, minute: u32, second: u32) -> DateTime<Utc> {
|
||||
Utc.with_ymd_and_hms(year, month, day, hour, minute, second)
|
||||
.single()
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn live_manifest(platform: &str, arch: &str, shell: &str) -> Value {
|
||||
json!({
|
||||
@@ -6249,40 +6241,6 @@ mod tests {
|
||||
fs::write(path, contents).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolves_explicit_calver_with_precedence() {
|
||||
let calver_env = CalverEnv {
|
||||
build_version: Some("2026.520.1".to_string()),
|
||||
fluxer_build_version: Some("2026.521.2".to_string()),
|
||||
fluxer_build_date: Some("2026-05-22T03:04:05Z".to_string()),
|
||||
};
|
||||
assert_eq!(
|
||||
resolve_calver(&calver_env, dt(2026, 5, 1, 0, 0, 0)).unwrap(),
|
||||
"2026.520.1"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolves_generated_calver_from_date_override() {
|
||||
let calver_env = CalverEnv {
|
||||
fluxer_build_date: Some("2026-05-20T01:02:03Z".to_string()),
|
||||
..CalverEnv::default()
|
||||
};
|
||||
assert_eq!(
|
||||
resolve_calver(&calver_env, dt(2026, 1, 1, 0, 0, 0)).unwrap(),
|
||||
"2026.520.10203"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_invalid_explicit_time() {
|
||||
let error = parse_version_instant("2026.520.246000").unwrap_err();
|
||||
assert_eq!(
|
||||
error.to_string(),
|
||||
"Invalid build version date/time: 2026.520.246000"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn matrix_skip_flags_filter_individual_arches() {
|
||||
let mut args = matrix_args();
|
||||
@@ -6389,57 +6347,6 @@ mod tests {
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_build_desktop_workflow_step_dispatches_to_a_desktop_step() {
|
||||
let steps = BUILD_DESKTOP_WORKFLOW
|
||||
.lines()
|
||||
.filter_map(|line| line.trim().strip_prefix("--step "))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert!(steps.contains(&"stage_handoff"));
|
||||
for step in steps {
|
||||
assert!(
|
||||
<DesktopStep as ValueEnum>::from_str(step, false).is_ok(),
|
||||
"build-desktop.yaml dispatches unknown desktop step {step}"
|
||||
);
|
||||
}
|
||||
assert!(matches!(
|
||||
<DesktopStep as ValueEnum>::from_str("stage_handoff", false),
|
||||
Ok(DesktopStep::StageHandoff)
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_github_release_is_the_only_destination_for_built_artifacts() {
|
||||
for job in ["build", "upload", "publish_release"] {
|
||||
let body = workflow_job(job);
|
||||
for forbidden in [
|
||||
"S3_BUCKET",
|
||||
"S3_ENDPOINT",
|
||||
"AWS_ACCESS_KEY_ID",
|
||||
"AWS_SECRET_ACCESS_KEY",
|
||||
"DOWNLOADS_S3",
|
||||
"_handoff/",
|
||||
] {
|
||||
assert!(
|
||||
!body.contains(forbidden),
|
||||
"{job} must not reference {forbidden} now that the downloads bucket is gone"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
workflow_step_names(workflow_job("publish_release")),
|
||||
vec![
|
||||
"Checkout source",
|
||||
"Set up Rust toolchain (CI helpers)",
|
||||
"Download GitHub release assets",
|
||||
"Create token",
|
||||
"Publish GitHub desktop release",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_job_handoff_travels_as_github_actions_artifacts() {
|
||||
let build = workflow_job("build");
|
||||
|
||||
@@ -138,16 +138,6 @@ const DESKTOP_NATIVE_ADDONS: &[DesktopNativeAddon] = &[
|
||||
pkg_config: &[],
|
||||
special: DesktopNativeSpecialBuild::None,
|
||||
},
|
||||
DesktopNativeAddon {
|
||||
package_dir: "linux-screen-capture",
|
||||
package_name: "@fluxer/linux-screen-capture",
|
||||
crate_name: "fluxer_linux_screen_capture",
|
||||
node_file_stem: "linux-screen-capture",
|
||||
required_platform: Some("linux"),
|
||||
features: &[],
|
||||
pkg_config: &[],
|
||||
special: DesktopNativeSpecialBuild::None,
|
||||
},
|
||||
DesktopNativeAddon {
|
||||
package_dir: "mac-app-audio",
|
||||
package_name: "@fluxer/mac-app-audio",
|
||||
@@ -1006,7 +996,7 @@ mod tests {
|
||||
assert!(names.contains(&"win-game-capture"));
|
||||
assert!(names.contains(&"app-store"));
|
||||
assert!(names.contains(&"gateway-socket"));
|
||||
assert_eq!(DESKTOP_NATIVE_ADDONS.len(), 23);
|
||||
assert_eq!(DESKTOP_NATIVE_ADDONS.len(), 22);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1095,45 +1085,6 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn platform_tags_match_legacy_node_helper() {
|
||||
assert_eq!(platform_tag("linux", "x64").unwrap(), "linux-x64-gnu");
|
||||
assert_eq!(platform_tag("darwin", "arm64").unwrap(), "darwin-arm64");
|
||||
assert_eq!(platform_tag("win32", "x64").unwrap(), "win32-x64-msvc");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rust_targets_match_legacy_node_helper() {
|
||||
assert_eq!(
|
||||
rust_target_for_platform("linux", "arm64").unwrap(),
|
||||
"aarch64-unknown-linux-gnu"
|
||||
);
|
||||
assert_eq!(
|
||||
rust_target_for_platform("darwin", "x64").unwrap(),
|
||||
"x86_64-apple-darwin"
|
||||
);
|
||||
assert_eq!(
|
||||
rust_target_for_platform("win32", "arm64").unwrap(),
|
||||
"aarch64-pc-windows-msvc"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dynamic_library_names_match_legacy_node_helper() {
|
||||
assert_eq!(
|
||||
cargo_dynamic_library_file_name("fluxer_webauthn", "linux").unwrap(),
|
||||
"libfluxer_webauthn.so"
|
||||
);
|
||||
assert_eq!(
|
||||
cargo_dynamic_library_file_name("fluxer-webauthn", "darwin").unwrap(),
|
||||
"libfluxer_webauthn.dylib"
|
||||
);
|
||||
assert_eq!(
|
||||
cargo_dynamic_library_file_name("fluxer_webauthn", "win32").unwrap(),
|
||||
"fluxer_webauthn.dll"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn redistributable_runtime_import_detection_matches_legacy_patterns() {
|
||||
assert!(is_redistributable_runtime_import("vcruntime140.dll"));
|
||||
@@ -1210,11 +1161,4 @@ mod tests {
|
||||
assert!(assert_system32_dependent_load_flag(&unset, "linux").is_ok());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn linux_library_bundling_denylist_matches_legacy_prefixes() {
|
||||
assert!(!should_bundle_linux_library("libc.so.6"));
|
||||
assert!(!should_bundle_linux_library("ld-linux-x86-64.so.2"));
|
||||
assert!(should_bundle_linux_library("libfido2.so.1"));
|
||||
}
|
||||
}
|
||||
@@ -51,47 +51,3 @@ pub(crate) fn sha256_file(path: &Path) -> Result<String> {
|
||||
fs::File::open(path).with_context(|| format!("Failed to open {}", path.display()))?;
|
||||
sha256_reader(file).with_context(|| format!("Failed to read {}", path.display()))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn remove_file_if_exists_removes_files_and_ignores_missing_paths() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let path = temp.path().join("artifact.txt");
|
||||
fs::write(&path, "artifact").unwrap();
|
||||
|
||||
remove_file_if_exists(&path).unwrap();
|
||||
remove_file_if_exists(&path).unwrap();
|
||||
|
||||
assert!(!path.exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_dir_if_exists_removes_directories_and_ignores_missing_paths() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let path = temp.path().join("dist");
|
||||
fs::create_dir_all(path.join("nested")).unwrap();
|
||||
fs::write(path.join("nested").join("artifact.txt"), "artifact").unwrap();
|
||||
|
||||
remove_dir_if_exists(&path).unwrap();
|
||||
remove_dir_if_exists(&path).unwrap();
|
||||
|
||||
assert!(!path.exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn write_json_pretty_creates_parent_directories_and_writes_pretty_json() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let path = temp.path().join("nested").join("manifest.json");
|
||||
|
||||
write_json_pretty(&path, &json!({ "name": "fluxer", "version": 1 })).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
fs::read_to_string(path).unwrap(),
|
||||
"{\n \"name\": \"fluxer\",\n \"version\": 1\n}\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,6 @@ pub(crate) enum GatewayStep {
|
||||
Eqwalizer,
|
||||
Typecheck,
|
||||
Eunit,
|
||||
Bench,
|
||||
AllChecks,
|
||||
Clean,
|
||||
}
|
||||
@@ -112,7 +111,6 @@ pub(crate) fn run_gateway_step(
|
||||
GatewayStep::Eqwalizer => run_eqwalizer(gateway_dir, eqwalizer_profile),
|
||||
GatewayStep::Typecheck => run_eqwalizer(gateway_dir, eqwalizer_profile),
|
||||
GatewayStep::Eunit => run_rebar(gateway_dir, ["as", "test", "eunit"]),
|
||||
GatewayStep::Bench => run_rebar(gateway_dir, ["eunit", "--module=guild_member_list_bench"]),
|
||||
GatewayStep::AllChecks => {
|
||||
run_gateway_check_step("Step 1/5: Format check (erlfmt)", || {
|
||||
run_gateway_step(gateway_dir, GatewayStep::FmtCheck, eqwalizer_profile)
|
||||
@@ -436,30 +434,6 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gateway_nif_build_plan_matches_legacy_artifact_layout() {
|
||||
let gateway_dir = Path::new("/repo/fluxer_gateway");
|
||||
let builds = gateway_nif_builds(gateway_dir, NifBuildProfile::Release, "lib", "so");
|
||||
|
||||
assert_eq!(builds.len(), 2);
|
||||
assert_eq!(
|
||||
builds[0],
|
||||
GatewayNifBuild {
|
||||
crate_name: "push_markdown_plaintext_nif".to_string(),
|
||||
native_dir: PathBuf::from(
|
||||
"/repo/fluxer_gateway/native/push_markdown_plaintext_nif"
|
||||
),
|
||||
cargo_args: vec![OsString::from("build"), OsString::from("--release")],
|
||||
artifact_path: PathBuf::from(
|
||||
"/repo/fluxer_gateway/native/push_markdown_plaintext_nif/target/release/libpush_markdown_plaintext_nif.so"
|
||||
),
|
||||
output_path: PathBuf::from(
|
||||
"/repo/fluxer_gateway/priv/push_markdown_plaintext_nif.so"
|
||||
),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn debug_build_plan_omits_release_arg_and_uses_debug_target_dir() {
|
||||
let build = gateway_nif_build(
|
||||
|
||||
@@ -919,29 +919,6 @@ mod tests {
|
||||
assert_eq!(services.len(), 18);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_component_has_a_build_workflow() {
|
||||
let directory = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.github/workflows");
|
||||
let mut workflows = String::new();
|
||||
for entry in fs::read_dir(&directory).expect("the workflow directory should be readable") {
|
||||
let path = entry.expect("the workflow entry should be readable").path();
|
||||
if path
|
||||
.extension()
|
||||
.is_some_and(|extension| extension == "yaml")
|
||||
{
|
||||
workflows
|
||||
.push_str(&fs::read_to_string(&path).expect("the workflow should be readable"));
|
||||
}
|
||||
}
|
||||
for component in COMPONENTS {
|
||||
assert!(
|
||||
workflows.contains(component.image),
|
||||
"{} has no build workflow",
|
||||
component.image
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn manifest_requires_every_component() {
|
||||
let mut resolved = resolved_set();
|
||||
@@ -1302,26 +1279,6 @@ mod tests {
|
||||
assert!(error.contains("no bundle commit can be proven"), "{error}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn release_workflow_tags_the_bundle_commit_and_marks_it_latest() {
|
||||
let workflow = include_str!("../../../.github/workflows/release-image-set.yaml");
|
||||
for entry in [
|
||||
"--github-output",
|
||||
"BUNDLE_COMMIT: ${{ steps.resolve.outputs.bundle_commit }}",
|
||||
"--target \"${BUNDLE_COMMIT}\"",
|
||||
"--latest=true",
|
||||
] {
|
||||
assert!(
|
||||
workflow.contains(entry),
|
||||
"release-image-set.yaml must contain {entry}"
|
||||
);
|
||||
}
|
||||
assert!(
|
||||
!workflow.contains("${GITHUB_SHA}"),
|
||||
"the release tag must be cut at the bundle commit, not at the workflow ref"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn release_filenames_are_stable() {
|
||||
assert_eq!(
|
||||
|
||||
@@ -31,7 +31,6 @@ enum Command {
|
||||
AppDevServer(app_dev_server::AppDevServerArgs),
|
||||
BuildAppWasm(app_wasm::BuildAppWasmArgs),
|
||||
BuildAppProxy(app_proxy::BuildAppProxyArgs),
|
||||
BuildMarkdownParserWasm(app_wasm::BuildMarkdownParserWasmArgs),
|
||||
BuildDesktop(desktop::BuildDesktopArgs),
|
||||
BuildDesktopNativeAddon(desktop_native::BuildDesktopNativeAddonArgs),
|
||||
BuildGatewayNifs(gateway::BuildGatewayNifsArgs),
|
||||
@@ -48,7 +47,6 @@ pub async fn run() -> Result<()> {
|
||||
Command::AppDevServer(args) => app_dev_server::run(args).await,
|
||||
Command::BuildAppWasm(args) => app_wasm::run_build_app_wasm(args),
|
||||
Command::BuildAppProxy(args) => app_proxy::run(args).await,
|
||||
Command::BuildMarkdownParserWasm(args) => app_wasm::run_build_markdown_parser_wasm(args),
|
||||
Command::BuildDesktop(args) => desktop::run(args).await,
|
||||
Command::BuildDesktopNativeAddon(args) => {
|
||||
desktop_native::run_build_desktop_native_addon(args)
|
||||
|
||||
@@ -65,48 +65,3 @@ fn collapse_extra_blank_lines(source: &str) -> String {
|
||||
}
|
||||
output
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn write_file(path: &Path, contents: &str) {
|
||||
if let Some(parent) = path.parent() {
|
||||
fs::create_dir_all(parent).unwrap();
|
||||
}
|
||||
fs::write(path, contents).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_import_start_only_matches_line_starts() {
|
||||
assert_eq!(
|
||||
find_import_start("// import nope\nimport {x} from 'x';\n"),
|
||||
Some(15)
|
||||
);
|
||||
assert_eq!(find_import_start("const value = 'import nope';\n"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn collapse_extra_blank_lines_keeps_at_most_one_blank_line() {
|
||||
assert_eq!(collapse_extra_blank_lines("a\n\n\n\nb\n\nc"), "a\n\nb\n\nc");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clean_generated_files_removes_prelude_and_compacts_blank_lines() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let root = temp.path();
|
||||
let file = root.join("generated.ts");
|
||||
write_file(
|
||||
&file,
|
||||
"// header\n\n\nimport {x} from 'x';\n\n\n\nexport const y = x;\n\n",
|
||||
);
|
||||
write_file(&root.join("keep.txt"), "// header\n");
|
||||
|
||||
clean_generated_files(root).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
fs::read_to_string(file).unwrap(),
|
||||
"import {x} from 'x';\n\nexport const y = x;\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user