fix: bundle a2ui before tests

main
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
- runtime: node
task: test
command: pnpm test
command: pnpm canvas:a2ui:bundle && pnpm test
- runtime: node
task: build
command: pnpm build
@ -88,7 +88,7 @@ jobs:
command: pnpm format
- runtime: bun
task: test
command: bunx vitest run
command: pnpm canvas:a2ui:bundle && bunx vitest run
- runtime: bun
task: build
command: bunx tsc -p tsconfig.json
@ -200,7 +200,7 @@ jobs:
command: pnpm lint
- runtime: node
task: test
command: pnpm test
command: pnpm canvas:a2ui:bundle && pnpm test
- runtime: node
task: build
command: pnpm build

View File

@ -27,23 +27,49 @@ INPUT_PATHS=(
"$A2UI_APP_DIR"
)
collect_files() {
local path
for path in "${INPUT_PATHS[@]}"; do
if [[ -d "$path" ]]; then
find "$path" -type f -print0
else
printf '%s\0' "$path"
fi
done
compute_hash() {
ROOT_DIR="$ROOT_DIR" node --input-type=module - "${INPUT_PATHS[@]}" <<'NODE'
import { createHash } from "node:crypto";
import { promises as fs } from "node:fs";
import path from "node:path";
const rootDir = process.env.ROOT_DIR ?? process.cwd();
const inputs = process.argv.slice(2);
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() {
collect_files \
| LC_ALL=C sort -z \
| xargs -0 shasum -a 256 \
| shasum -a 256 \
| awk '{print $1}'
for (const input of inputs) {
await walk(input);
}
function normalize(p) {
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)"