Repository navigation
Expand file tree
/
Copy pathmacos-e2e-source-digest.mjs
More file actions
66 lines (64 loc) · 2.14 KB
/
Copy pathmacos-e2e-source-digest.mjs
File metadata and controls
66 lines (64 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { execFileSync } from "node:child_process";
import { createHash } from "node:crypto";
import { readFileSync } from "node:fs";
const component = process.argv[2];
if (!["executor", "backend-rs"].includes(component)) {
throw new Error("Expected executor or backend-rs");
}
const startedAt = Date.now();
let fileCount = 0;
// Embedded JSON, SDK sources and shared prompts affect the compiled binary too.
// Use tracked inputs so build outputs cannot accidentally invalidate the key.
const groups = [
`${component}/Cargo.toml`,
`${component}/Cargo.lock`,
...(component === "executor"
? [
"executor/src",
"shared/rust",
"executor/crates",
"executor/vendor",
"sdk/plugin-auth",
"sdk/plugin-creator",
"shared/assets",
"shared/protocol",
]
: [
":(glob)backend-rs/*/Cargo.toml",
":(glob)backend-rs/*/src/**",
"backend-rs/src/task_export_docx/templates/thumbnail.jpeg",
"backend-rs/migrations",
"shared/rust",
"shared/assets/calendars",
"shared/assets/codex-models",
"shared/data/builtin-connector-apps.json",
]),
".github/ci/rust-toolchain",
".github/actions/setup-rust-cache/action.yml",
".github/scripts/build-macos-e2e-runtimes.sh",
];
const result = createHash("sha256").update("macos-arm64-e2e-v2\n");
for (const pattern of groups) {
const files = execFileSync("git", ["ls-files", "-z", "--", pattern], {
encoding: "utf8",
})
.split("\0")
.filter(Boolean)
.sort((left, right) => {
const a = left.split("/");
const b = right.split("/");
for (let index = 0; index < Math.min(a.length, b.length); index++) {
if (a[index] !== b[index]) return a[index] < b[index] ? -1 : 1;
}
return a.length - b.length;
});
if (!files.length) throw new Error(`No tracked source inputs for ${pattern}`);
for (const file of files) {
result.update(file).update("\0").update(readFileSync(file)).update("\0");
fileCount++;
}
}
console.error(
`Hashed ${fileCount} ${component} inputs in ${Date.now() - startedAt}ms`,
);
process.stdout.write(`${result.digest("hex")}\n`);