mirror of
https://github.com/block/buzz.git
synced 2026-11-09 02:41:57 +00:00
Merge remote-tracking branch 'origin/main' into codex/sandpit-agent-security
* origin/main: (22 commits) feat(relay): add admin HTTP routes for member restriction management (#7302) fix(relay): fire kick live side effects at convergence; persist target; fence re-add race with held lock (#7298) feat(relay): add atomic complete read-state snapshots (#7572) fix(desktop): register macOS badges for new and existing installs (#7783) fix(mobile): avoid opening empty threads on message tap (#7756) fix(workflows): make deletion persistent and retryable (#7735) fix(mobile): preserve thread replies through refresh failures (#7757) fix(mobile): keep iOS message menu actions responsive after rebuilds (#7758) fix(relay): exclude ephemeral activity from message quota (#7736) release: push gateway chart 0.3.1 (#7749) fix(push): label plaintext push gateway service as HTTP (#7717) Replace personal and internal data in desktop test fixtures (#7748) Add mobile VISION (#7710) fix(mobile): keep relay sessions stable during push lease updates (#7745) fix(desktop): keep managed agent avatars usable across communities (#7732) fix(mobile): fail open when age checks are unavailable (#7714) fix(ci): don't run desktop tests for purely mobile client changes (#7709) fix(mobile): temporarily disable age gating (#7708) feat(db): expose connection setup metrics (#7286) Isolate S3 storage metrics from the relay (#7543) ... Signed-off-by: Alex Rosenzweig <arosenzweig@squareup.com>
This commit is contained in:
140
scripts/ci-selection.test.mjs
Normal file
140
scripts/ci-selection.test.mjs
Normal file
@@ -0,0 +1,140 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { execFileSync, spawnSync } from "node:child_process";
|
||||
import {
|
||||
existsSync,
|
||||
mkdtempSync,
|
||||
mkdirSync,
|
||||
readFileSync,
|
||||
rmSync,
|
||||
writeFileSync,
|
||||
} from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { dirname, join } from "node:path";
|
||||
import { after, test } from "node:test";
|
||||
|
||||
const workflow = readFileSync(
|
||||
new URL("../.github/workflows/ci.yml", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const scratch = mkdtempSync(join(tmpdir(), "buzz-ci-selection-"));
|
||||
after(() => rmSync(scratch, { recursive: true, force: true }));
|
||||
const actionSha = workflow.match(/uses: dorny\/paths-filter@([a-f0-9]{40})/)[1];
|
||||
const filters = workflow
|
||||
.match(/ {10}filters: \|\n([\s\S]*?)(?= {6}- name:)/)[1]
|
||||
.split("\n")
|
||||
.map((line) => line.slice(12))
|
||||
.join("\n");
|
||||
// GitHub-hosted runners prepare pinned actions beside RUNNER_TEMP before any
|
||||
// steps run. Reuse that bundle, without another download in the selection gate.
|
||||
// Locally, point PATHS_FILTER_ACTION at dist/index.js from the pinned action.
|
||||
const actionPath =
|
||||
process.env.PATHS_FILTER_ACTION ||
|
||||
(process.env.RUNNER_TEMP &&
|
||||
join(
|
||||
process.env.RUNNER_TEMP,
|
||||
"..",
|
||||
"_actions",
|
||||
"dorny",
|
||||
"paths-filter",
|
||||
actionSha,
|
||||
"dist",
|
||||
"index.js",
|
||||
));
|
||||
assert.ok(
|
||||
actionPath && existsSync(actionPath),
|
||||
`Set PATHS_FILTER_ACTION to the local dist/index.js from dorny/paths-filter@${actionSha}`,
|
||||
);
|
||||
function select(paths) {
|
||||
const repo = mkdtempSync(join(scratch, "repo-"));
|
||||
const git = (...args) =>
|
||||
execFileSync("git", args, { cwd: repo, stdio: "pipe", timeout: 10000 });
|
||||
git("init", "-q");
|
||||
// Fixture repositories must not inherit developer machine hooks.
|
||||
mkdirSync(join(repo, "empty-hooks"));
|
||||
git("config", "core.hooksPath", join(repo, "empty-hooks"));
|
||||
git(
|
||||
"-c",
|
||||
"user.name=CI fixture",
|
||||
"-c",
|
||||
"user.email=ci@example.com",
|
||||
"-c",
|
||||
"commit.gpgsign=false",
|
||||
"commit",
|
||||
"-q",
|
||||
"--allow-empty",
|
||||
"-m",
|
||||
"fixture",
|
||||
"-s",
|
||||
);
|
||||
for (const path of paths) {
|
||||
mkdirSync(dirname(join(repo, path)), { recursive: true });
|
||||
writeFileSync(join(repo, path), "fixture\n");
|
||||
}
|
||||
git("add", ".");
|
||||
const output = join(repo, "action-output");
|
||||
writeFileSync(output, "");
|
||||
const child = spawnSync(process.execPath, [actionPath], {
|
||||
cwd: repo,
|
||||
encoding: "utf8",
|
||||
timeout: 30000,
|
||||
env: {
|
||||
...process.env,
|
||||
INPUT_BASE: "HEAD",
|
||||
INPUT_FILTERS: filters,
|
||||
INPUT_TOKEN: "",
|
||||
INPUT_REF: "",
|
||||
GITHUB_OUTPUT: output,
|
||||
"INPUT_PREDICATE-QUANTIFIER":
|
||||
workflow.match(/predicate-quantifier: ['"]?([\w-]+)/)?.[1] ?? "some",
|
||||
},
|
||||
});
|
||||
assert.equal(child.status, 0, child.stdout + child.stderr);
|
||||
return Object.fromEntries(
|
||||
[
|
||||
...readFileSync(output, "utf8").matchAll(
|
||||
/^(rust|desktop|desktop-rust|web|mobile)<<([^\n]+)\n(true|false)\n\2/gm,
|
||||
),
|
||||
].map(([, key, , value]) => [key, value]),
|
||||
);
|
||||
}
|
||||
const scenarios = [
|
||||
[
|
||||
"mobile source and tests",
|
||||
[
|
||||
"mobile/lib/features/age_gate/age_signal_provider.dart",
|
||||
"mobile/test/features/age_gate/age_signal_provider_test.dart",
|
||||
],
|
||||
["mobile"],
|
||||
],
|
||||
["mobile lockfile", ["mobile/pubspec.lock"], ["mobile"]],
|
||||
["mobile release script", ["scripts/mobile-release.sh"], ["mobile"]],
|
||||
["desktop", ["desktop/src/main.tsx"], ["desktop"]],
|
||||
["Tauri", ["desktop/src-tauri/src/main.rs"], ["desktop", "desktop-rust"]],
|
||||
["relay", ["crates/buzz-relay/src/main.rs"], ["rust"]],
|
||||
["migration", ["migrations/123.sql"], ["rust"]],
|
||||
["shared workflow", [".github/workflows/ci.yml"], ["rust", "mobile"]],
|
||||
[
|
||||
"mixed mobile and relay",
|
||||
["mobile/lib/main.dart", "crates/buzz-core/src/lib.rs"],
|
||||
["rust", "mobile"],
|
||||
],
|
||||
[
|
||||
"mixed mobile and desktop",
|
||||
["mobile/lib/main.dart", "desktop/src/main.tsx"],
|
||||
["desktop", "mobile"],
|
||||
],
|
||||
["web", ["web/src/main.tsx"], ["web"]],
|
||||
["documentation", ["README.md"], []],
|
||||
];
|
||||
for (const [name, paths, expected] of scenarios) {
|
||||
test(`real paths-filter: ${name}`, () => {
|
||||
const outputs = select(paths);
|
||||
assert.equal(Object.keys(outputs).length, 5);
|
||||
assert.deepEqual(
|
||||
Object.keys(outputs)
|
||||
.filter((key) => outputs[key] === "true")
|
||||
.sort(),
|
||||
expected.sort(),
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -104,6 +104,12 @@ run_unit_tests() {
|
||||
run_test_step "buzz-db unit tests" \
|
||||
cargo test -p buzz-db --lib -- --nocapture
|
||||
|
||||
run_test_step "buzz-media storage snapshot serialization test" \
|
||||
cargo test -p buzz-media --lib bucket_index::tests::bucket_snapshot_json_round_trip_preserves_community_keys -- --exact --nocapture
|
||||
|
||||
run_test_step "buzz-admin completed snapshot persistence test" \
|
||||
cargo test -p buzz-admin storage_snapshot_tests::failed_fold_never_invokes_snapshot_persistence -- --exact --nocapture
|
||||
|
||||
# Multi-tenant conformance gate: independent replay checker + golden
|
||||
# fixtures (buzz-conformance). Pure in-process trace replay, no infra.
|
||||
run_test_step "buzz-conformance tests" \
|
||||
@@ -142,6 +148,9 @@ run_unit_tests() {
|
||||
|
||||
run_test_step "buzz-relay side-effects helper tests" \
|
||||
cargo test -p buzz-relay --lib handlers::side_effects::tests:: -- --nocapture
|
||||
|
||||
run_test_step "buzz-relay storage snapshot tests" \
|
||||
cargo test -p buzz-relay --lib storage_sweep::tests:: -- --nocapture
|
||||
}
|
||||
|
||||
# ---- DB / integration tests (infra required) --------------------------------
|
||||
|
||||
Reference in New Issue
Block a user