fix: bundle a2ui before tests

This commit is contained in:
Peter Steinberger 2026-01-27 15:38:31 +00:00
parent e4518d2271
commit 3817e0ce2c
2 changed files with 44 additions and 18 deletions

View File

@ -76,7 +76,7 @@ jobs:
command: pnpm lint command: pnpm lint
- runtime: node - runtime: node
task: test task: test
command: pnpm test command: pnpm canvas:a2ui:bundle && pnpm test
- runtime: node - runtime: node
task: build task: build
command: pnpm build command: pnpm build
@ -88,7 +88,7 @@ jobs:
command: pnpm format command: pnpm format
- runtime: bun - runtime: bun
task: test task: test
command: bunx vitest run command: pnpm canvas:a2ui:bundle && bunx vitest run
- runtime: bun - runtime: bun
task: build task: build
command: bunx tsc -p tsconfig.json command: bunx tsc -p tsconfig.json
@ -200,7 +200,7 @@ jobs:
command: pnpm lint command: pnpm lint
- runtime: node - runtime: node
task: test task: test
command: pnpm test command: pnpm canvas:a2ui:bundle && pnpm test
- runtime: node - runtime: node
task: build task: build
command: pnpm build command: pnpm build

View File

@ -27,23 +27,49 @@ INPUT_PATHS=(
"$A2UI_APP_DIR" "$A2UI_APP_DIR"
) )
collect_files() { compute_hash() {
local path ROOT_DIR="$ROOT_DIR" node --input-type=module - "${INPUT_PATHS[@]}" <<'NODE'
for path in "${INPUT_PATHS[@]}"; do import { createHash } from "node:crypto";
if [[ -d "$path" ]]; then import { promises as fs } from "node:fs";
find "$path" -type f -print0 import path from "node:path";
else
printf '%s\0' "$path" const rootDir = process.env.ROOT_DIR ?? process.cwd();
fi const inputs = process.argv.slice(2);
done const files = [];
async function walk(entryPath) {
const st = await fs.stat(entryPath);
if (st.isDirectory()) {
const entries = await fs.readdir(entryPath);
for (const entry of entries) {
await walk(path.join(entryPath, entry));
}
return;
}
files.push(entryPath);
} }
compute_hash() { for (const input of inputs) {
collect_files \ await walk(input);
| LC_ALL=C sort -z \ }
| xargs -0 shasum -a 256 \
| shasum -a 256 \ function normalize(p) {
| awk '{print $1}' return p.split(path.sep).join("/");
}
files.sort((a, b) => normalize(a).localeCompare(normalize(b)));
const hash = createHash("sha256");
for (const filePath of files) {
const rel = normalize(path.relative(rootDir, filePath));
hash.update(rel);
hash.update("\0");
hash.update(await fs.readFile(filePath));
hash.update("\0");
}
process.stdout.write(hash.digest("hex"));
NODE
} }
current_hash="$(compute_hash)" current_hash="$(compute_hash)"