Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Aggregate applicable CI into one required check

Manav Rathi4061ae54b64c
diff --git a/.github/checks/run.sh b/.github/checks/run.sh
index a535d99300..a1a7f7be25 100755
--- a/.github/checks/run.sh
+++ b/.github/checks/run.sh
@@ -7,5 +7,6 @@ node .github/checks/documentation-comments/check.mjs
node .github/checks/documentation-comments/test.mjs
ruby .github/checks/workflow-paths/check.rb
ruby .github/checks/workflow-paths/test.rb
-ruby .github/checks/wasm-ci-paths/check.rb
-ruby .github/checks/wasm-ci-paths/test.rb
+node .github/checks/wasm-ci-paths/check.mjs
+node --test .github/checks/wasm-ci-paths/test.mjs
+node --test .github/scripts/ci/test.mjs
diff --git a/.github/checks/wasm-ci-paths/check.mjs b/.github/checks/wasm-ci-paths/check.mjs
new file mode 100644
index 0000000000..1f09f3ed42
--- /dev/null
+++ b/.github/checks/wasm-ci-paths/check.mjs
@@ -0,0 +1,52 @@
+import { execFileSync } from "node:child_process";
+import { existsSync, readFileSync, readdirSync } from "node:fs";
+import { dirname, join, relative } from "node:path";
+
+const abort = (message) => {
+ console.error(message);
+ process.exit(1);
+};
+const readJSON = (path) => JSON.parse(readFileSync(path, "utf8"));
+
+process.chdir(process.argv[2] ?? ".");
+const root = process.cwd();
+const pathsFile = ".github/scripts/ci/paths.json";
+const patterns = readJSON(pathsFile)["web-lint"];
+if (patterns === null) process.exit(0);
+if (patterns.some((pattern) => pattern.startsWith("!"))) abort(`${pathsFile}: WASM coverage does not support negated paths`);
+
+const { packages } = JSON.parse(execFileSync("cargo", [
+ "metadata", "--no-deps", "--format-version", "1", "--locked", "--offline",
+], { cwd: "rust", encoding: "utf8" }));
+const byName = new Map(packages.map((pkg) => [pkg.name, pkg]));
+const byDirectory = new Map(packages.map((pkg) => [dirname(pkg.manifest_path), pkg]));
+const pending = [];
+for (const entry of readdirSync("web/packages/wasm")) {
+ const path = join("web/packages/wasm", entry, "package.json");
+ if (entry.startsWith(".") || !existsSync(path)) continue;
+ const { name } = readJSON(path);
+ const pkg = byName.get(name);
+ if (!pkg) abort(`${path}: no matching Cargo package for ${name}`);
+ pending.push(dirname(pkg.manifest_path));
+}
+if (!pending.length) abort("No Web WASM packages found");
+
+const directories = new Set();
+while (pending.length) {
+ const directory = pending.pop();
+ if (directories.has(directory)) continue;
+ directories.add(directory);
+ const pkg = byDirectory.get(directory);
+ if (!pkg) abort(`Local dependency ${directory} is outside the Rust workspace`);
+ // Include optional and target-specific edges without fetching Cargo's resolved graph.
+ for (const dependency of pkg.dependencies) {
+ if (dependency.kind !== "dev" && dependency.path) pending.push(dependency.path);
+ }
+}
+
+const required = ["rust/Cargo.lock", "rust/Cargo.toml", ...[...directories].map((dir) => `${relative(root, dir)}/**`)];
+// Literal directory prefixes prove coverage of future files too.
+const prefixes = patterns.filter((pattern) => /^[\w./-]+\/\*\*$/.test(pattern)).map((pattern) => pattern.slice(0, -2));
+const missing = required.filter((path) => !patterns.includes(path) && !prefixes.some((prefix) => path.startsWith(prefix)));
+for (const path of missing.sort()) console.error(`${pathsFile}: missing WASM dependency path ${JSON.stringify(path)}`);
+process.exit(missing.length ? 1 : 0);
diff --git a/.github/checks/wasm-ci-paths/check.rb b/.github/checks/wasm-ci-paths/check.rb
deleted file mode 100644
index 37281fa8f7..0000000000
--- a/.github/checks/wasm-ci-paths/check.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-require "json"
-require "open3"
-require "pathname"
-require "set"
-require "yaml"
-
-Dir.chdir(ARGV.fetch(0, "."))
-root = Pathname.pwd
-workflow_path = ".github/workflows/web-lint.yml"
-workflow = YAML.safe_load(File.read(workflow_path), aliases: true)
-events = workflow["on"] || workflow[true]
-config = events.fetch("pull_request") || {}
-abort "#{workflow_path}: WASM coverage does not support paths-ignore" if config.key?("paths-ignore")
-patterns = config["paths"]
-exit 0 unless patterns
-abort "#{workflow_path}: WASM coverage does not support negated paths" if patterns.any? { |p| p.start_with?("!") }
-
-output, status = Open3.capture2(
- "cargo", "metadata", "--no-deps", "--format-version", "1", "--locked", "--offline",
- chdir: "rust",
-)
-exit status.exitstatus unless status.success?
-packages = JSON.parse(output).fetch("packages")
-by_name = packages.to_h { |package| [package.fetch("name"), package] }
-by_directory = packages.to_h { |package| [Pathname.new(package.fetch("manifest_path")).dirname, package] }
-pending = Dir["web/packages/wasm/*/package.json"].map do |path|
- name = JSON.parse(File.read(path)).fetch("name")
- package = by_name.fetch(name) { abort "#{path}: no matching Cargo package for #{name}" }
- Pathname.new(package.fetch("manifest_path")).dirname
-end
-abort "No Web WASM packages found" if pending.empty?
-
-directories = Set.new
-until pending.empty?
- directory = pending.pop
- next unless directories.add?(directory)
-
- package = by_directory.fetch(directory) { abort "Local dependency #{directory} is outside the Rust workspace" }
- # Include optional and target-specific edges to avoid fetching Cargo's resolved graph.
- package.fetch("dependencies").each do |dependency|
- next if dependency["kind"] == "dev" || !dependency["path"]
-
- pending << Pathname.new(dependency.fetch("path"))
- end
-end
-
-required = %w[rust/Cargo.lock rust/Cargo.toml] + directories.map { |dir| "#{dir.relative_path_from(root)}/**" }
-# Literal directory prefixes prove coverage of the entire crate, including future files.
-prefixes = patterns.grep(%r{\A[\w./-]+/\*\*\z}).map { |pattern| pattern.delete_suffix("**") }
-missing = required.reject { |path| patterns.include?(path) || prefixes.any? { |prefix| path.start_with?(prefix) } }
-missing.sort.each { |path| warn "#{workflow_path}: missing WASM dependency path #{path.inspect}" }
-exit(missing.empty? ? 0 : 1)
diff --git a/.github/checks/wasm-ci-paths/test.mjs b/.github/checks/wasm-ci-paths/test.mjs
new file mode 100644
index 0000000000..435abf94a7
--- /dev/null
+++ b/.github/checks/wasm-ci-paths/test.mjs
@@ -0,0 +1,69 @@
+import assert from "node:assert/strict";
+import { spawnSync } from "node:child_process";
+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { dirname, join } from "node:path";
+import test from "node:test";
+
+const script = join(import.meta.dirname, "check.mjs");
+const pathsFile = ".github/scripts/ci/paths.json";
+
+test("Web CI covers transitive local WASM dependencies", (t) => {
+ const root = mkdtempSync(join(tmpdir(), "ente-wasm-ci-paths-"));
+ t.after(() => rmSync(root, { recursive: true }));
+ const write = (path, content) => {
+ mkdirSync(dirname(join(root, path)), { recursive: true });
+ writeFileSync(join(root, path), content);
+ };
+ const crate = (path, name, dependencies = "") => {
+ write(`rust/${path}/src/lib.rs`, "");
+ write(`rust/${path}/Cargo.toml`, `
+[package]
+name = "${name}"
+version = "0.1.0"
+edition = "2024"
+${dependencies}`);
+ };
+ const check = (patterns, errors = []) => {
+ write(pathsFile, JSON.stringify({ "web-lint": patterns }));
+ const result = spawnSync(process.execPath, [script, root], { encoding: "utf8" });
+ assert.equal(result.stdout, "");
+ assert.equal(result.stderr, errors.map((error) => `${pathsFile}: ${error}\n`).join(""));
+ assert.equal(result.status, errors.length ? 1 : 0);
+ };
+
+ write("rust/Cargo.toml", `
+[workspace]
+resolver = "2"
+members = ["bindings/wasm/*", "crates/*"]
+[workspace.dependencies]
+shared-alias = { package = "shared", path = "crates/shared" }
+`);
+ write("web/packages/wasm/app/package.json", JSON.stringify({ name: "app-wasm" }));
+ crate("bindings/wasm/app", "app-wasm", `
+[dependencies]
+shared-alias.workspace = true
+[build-dependencies]
+builder = { path = "../../../crates/builder" }
+[dev-dependencies]
+test-only = { path = "../../../crates/test-only" }
+`);
+ crate("crates/shared", "shared", `
+[target.'cfg(windows)'.dependencies]
+leaf = { path = "../leaf", optional = true }
+`);
+ for (const name of ["builder", "leaf", "test-only", "native-only"]) crate(`crates/${name}`, name);
+ crate("bindings/wasm/unused", "unused-wasm", `
+[dependencies]
+native-only = { path = "../../../crates/native-only" }
+`);
+
+ const base = ["rust/Cargo.lock", "rust/Cargo.toml", "rust/bindings/wasm/**"];
+ const needed = ["builder", "leaf", "shared"].map((name) => `rust/crates/${name}/**`);
+ const incomplete = [...base, "rust/crates/shared-other/**", "rust/crates/leaf/Cargo.toml"];
+ check(incomplete, needed.map((path) => `missing WASM dependency path ${JSON.stringify(path)}`));
+ check([...base, ...needed]);
+ check(["rust/**"]);
+ check(null);
+ check([...base, ...needed, "!rust/crates/leaf/private/**"], ["WASM coverage does not support negated paths"]);
+});
diff --git a/.github/checks/wasm-ci-paths/test.rb b/.github/checks/wasm-ci-paths/test.rb
deleted file mode 100644
index 970cfd103b..0000000000
--- a/.github/checks/wasm-ci-paths/test.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-require "fileutils"
-require "json"
-require "open3"
-require "rbconfig"
-require "tmpdir"
-require "yaml"
-
-CHECK = File.expand_path("check.rb", __dir__)
-WORKFLOW = ".github/workflows/web-lint.yml"
-
-def write(root, path, content)
- FileUtils.mkdir_p(File.dirname("#{root}/#{path}"))
- File.write("#{root}/#{path}", content)
-end
-
-def crate(root, path, name, dependencies = "")
- write(root, "rust/#{path}/src/lib.rs", "")
- write(root, "rust/#{path}/Cargo.toml", <<~TOML)
- [package]
- name = "#{name}"
- version = "0.1.0"
- edition = "2024"
- #{dependencies}
- TOML
-end
-
-def check(root, patterns, errors = [])
- config = patterns ? { "paths" => patterns } : nil
- write(root, WORKFLOW, { "on" => { "pull_request" => config } }.to_yaml)
- stdout, stderr, status = Open3.capture3(RbConfig.ruby, CHECK, root)
- expected = errors.map { |error| "#{WORKFLOW}: #{error}\n" }.join
- raise "#{stdout}#{stderr}" unless stdout.empty? && stderr == expected && status.exitstatus == (errors.empty? ? 0 : 1)
-end
-
-Dir.mktmpdir("ente-wasm-ci-paths-") do |root|
- write(root, "rust/Cargo.toml", <<~TOML)
- [workspace]
- resolver = "2"
- members = ["bindings/wasm/*", "crates/*"]
- [workspace.dependencies]
- shared-alias = { package = "shared", path = "crates/shared" }
- TOML
- write(root, "web/packages/wasm/app/package.json", { name: "app-wasm" }.to_json)
- crate(root, "bindings/wasm/app", "app-wasm", <<~TOML)
- [dependencies]
- shared-alias.workspace = true
- [build-dependencies]
- builder = { path = "../../../crates/builder" }
- [dev-dependencies]
- test-only = { path = "../../../crates/test-only" }
- TOML
- crate(root, "crates/shared", "shared", <<~TOML)
- [target.'cfg(windows)'.dependencies]
- leaf = { path = "../leaf", optional = true }
- TOML
- %w[builder leaf test-only native-only].each { |name| crate(root, "crates/#{name}", name) }
- crate(root, "bindings/wasm/unused", "unused-wasm", <<~TOML)
- [dependencies]
- native-only = { path = "../../../crates/native-only" }
- TOML
-
- base = %w[rust/Cargo.lock rust/Cargo.toml rust/bindings/wasm/**]
- needed = %w[builder leaf shared].map { |name| "rust/crates/#{name}/**" }
- incomplete = base + %w[rust/crates/shared-other/** rust/crates/leaf/Cargo.toml]
- check(root, incomplete, needed.map { |path| "missing WASM dependency path #{path.inspect}" })
- check(root, base + needed)
- check(root, %w[rust/**])
- check(root, nil)
- check(root, base + needed + ["!rust/crates/leaf/private/**"], ["WASM coverage does not support negated paths"])
-end
diff --git a/.github/scripts/ci/check.mjs b/.github/scripts/ci/check.mjs
new file mode 100644
index 0000000000..9dbcb1a4ca
--- /dev/null
+++ b/.github/scripts/ci/check.mjs
@@ -0,0 +1,48 @@
+import { execFileSync } from "node:child_process";
+import { appendFileSync, readFileSync } from "node:fs";
+import { fileURLToPath } from "node:url";
+
+export const paths = JSON.parse(readFileSync(new URL("paths.json", import.meta.url), "utf8"));
+const jobs = Object.keys(paths);
+
+export function select(base, head, cwd) {
+ const changed = (patterns) => execFileSync("git", [
+ "diff", "--name-only", "--no-renames", "-z", base, head, "--",
+ ...patterns.map((pattern) => `:(top,glob)${pattern}`),
+ ], { cwd }).length > 0;
+ if (changed([".github/scripts/ci/**", ".github/workflows/ci.yml"])) return jobs;
+ return Object.entries(paths)
+ .filter(([, patterns]) => patterns === null || (patterns.length > 0 && changed(patterns)))
+ .map(([job]) => job);
+}
+
+export function failures(needs) {
+ if (needs.select?.result !== "success") return ["CI selection did not succeed"];
+ const selected = JSON.parse(needs.select.outputs.jobs);
+ if (!Array.isArray(selected) || selected.some((job) => !jobs.includes(job)) || !selected.includes("repo-lint")) {
+ throw new Error("Invalid CI selection");
+ }
+ return jobs.flatMap((job) => {
+ const result = needs[job]?.result;
+ const expected = selected.includes(job) ? "success" : "skipped";
+ return result === expected ? [] : [`${job}: expected ${expected}, got ${result ?? "no result"}`];
+ });
+}
+
+if (process.argv[1] === fileURLToPath(import.meta.url)) {
+ const [command, ...args] = process.argv.slice(2);
+ if (command === "select" && args.length === 2) {
+ const selected = select(...args);
+ console.log(`Selected CI: ${selected.join(", ")}`);
+ appendFileSync(process.env.GITHUB_OUTPUT, `jobs=${JSON.stringify(selected)}\n`);
+ } else if (command === "result" && args.length === 0) {
+ const failed = failures(JSON.parse(process.env.NEEDS));
+ if (failed.length) {
+ console.error(failed.join("\n"));
+ process.exit(1);
+ }
+ console.log("All selected CI workflows passed.");
+ } else {
+ throw new Error("Usage: check.mjs select BASE HEAD | result");
+ }
+}
diff --git a/.github/scripts/ci/paths.json b/.github/scripts/ci/paths.json
new file mode 100644
index 0000000000..ce3567757f
--- /dev/null
+++ b/.github/scripts/ci/paths.json
@@ -0,0 +1,111 @@
+{
+ "dependency-review": [
+ "**/Cargo.lock",
+ "**/Cargo.toml",
+ "**/go.mod",
+ "**/go.sum",
+ "**/package-lock.json",
+ "**/package.json",
+ "**/pubspec.lock",
+ "**/pubspec.yaml",
+ "**/uv.lock",
+ ".github/workflows/dependency-review.yml"
+ ],
+ "desktop-lint": [
+ ".github/workflows/desktop-lint.yml",
+ "desktop/**",
+ "rust/Cargo.lock",
+ "rust/Cargo.toml",
+ "rust/bindings/napi/**",
+ "rust/crates/image/**",
+ "rust/crates/ml/**",
+ "rust/tools/codegen/**"
+ ],
+ "docs-verify-build": [
+ ".github/workflows/docs-verify-build.yml",
+ "docs/**"
+ ],
+ "ensu-android-build": [
+ ".github/workflows/ensu-android-build.yml",
+ "android/apps/ensu/**",
+ "android/apps/ensu/rust/**",
+ "rust/.cargo/config.toml",
+ "rust/Cargo.lock",
+ "rust/Cargo.toml",
+ "rust/bindings/uniffi/**",
+ "rust/crates/core/**",
+ "rust/crates/ensu/**",
+ "rust/tools/codegen/**"
+ ],
+ "ensu-ios-build": [
+ ".github/workflows/ensu-ios-build.yml",
+ "apple/apps/ensu/**",
+ "apple/packages/EnteOnnxRuntime/**",
+ "rust/.cargo/config.toml",
+ "rust/Cargo.lock",
+ "rust/Cargo.toml",
+ "rust/bindings/uniffi/**",
+ "rust/crates/core/**",
+ "rust/crates/ensu/**",
+ "rust/tools/codegen/**"
+ ],
+ "infra-lint-staff": [
+ ".github/workflows/infra-lint-staff.yml",
+ "infra/staff/**"
+ ],
+ "mobile-lint": [
+ ".github/workflows/mobile-lint.yml",
+ "mobile/**",
+ "rust/Cargo.lock",
+ "rust/Cargo.toml",
+ "rust/bindings/frb/**",
+ "rust/crates/cast/**",
+ "rust/crates/contacts/**",
+ "rust/crates/core/**",
+ "rust/crates/image/**",
+ "rust/crates/locker/**",
+ "rust/crates/ml/**",
+ "rust/crates/photos/**",
+ "rust/tools/codegen/**"
+ ],
+ "mobile-podfile-lock": [
+ ".github/workflows/mobile-podfile-lock.yml",
+ "apple/packages/EnteOnnxRuntime/EnteOnnxRuntime.podspec",
+ "mobile/**/*.podspec",
+ "mobile/**/Podfile",
+ "mobile/**/Podfile.lock",
+ "mobile/**/pubspec.lock",
+ "mobile/**/pubspec.yaml"
+ ],
+ "repo-lint": null,
+ "rust-lint": [
+ ".github/workflows/rust-lint.yml",
+ "rust/**"
+ ],
+ "rust-test": [
+ ".github/workflows/rust-test.yml",
+ "rust/**",
+ "server/**"
+ ],
+ "server-lint": [
+ ".github/workflows/server-lint.yml",
+ "server/**"
+ ],
+ "web-lint": [
+ ".github/workflows/web-lint.yml",
+ "rust/Cargo.lock",
+ "rust/Cargo.toml",
+ "rust/bindings/wasm/**",
+ "rust/crates/accounts/**",
+ "rust/crates/cast/**",
+ "rust/crates/collections/**",
+ "rust/crates/contacts/**",
+ "rust/crates/core/**",
+ "rust/crates/ensu-crypto/**",
+ "rust/crates/legacy/**",
+ "rust/crates/locker/**",
+ "rust/crates/paste/**",
+ "rust/crates/space/**",
+ "web/**"
+ ]
+}
diff --git a/.github/scripts/ci/test.mjs b/.github/scripts/ci/test.mjs
new file mode 100644
index 0000000000..f3fb84e414
--- /dev/null
+++ b/.github/scripts/ci/test.mjs
@@ -0,0 +1,96 @@
+import assert from "node:assert/strict";
+import { execFileSync } from "node:child_process";
+import { mkdtempSync, rmSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import test from "node:test";
+import { failures, paths, select } from "./check.mjs";
+
+const repository = (t) => {
+ const cwd = mkdtempSync(join(tmpdir(), "ente-ci-"));
+ t.after(() => rmSync(cwd, { recursive: true }));
+ const git = (...args) => execFileSync("git", args, { cwd, encoding: "utf8", input: "fixture\n" }).trim();
+ git("init", "-q");
+ const blob = git("hash-object", "-w", "--stdin");
+ const tree = (files) => {
+ git("read-tree", "--empty");
+ for (const file of files) git("update-index", "--add", "--cacheinfo", `100644,${blob},${file}`);
+ return git("write-tree");
+ };
+ const empty = tree([]);
+ return { cwd, empty, tree, select: (files) => select(empty, tree(files), cwd) };
+};
+
+const results = (selected) => ({
+ ...Object.fromEntries(Object.keys(paths).map((job) => [job, { result: selected.includes(job) ? "success" : "skipped" }])),
+ select: { result: "success", outputs: { jobs: JSON.stringify(selected) } },
+});
+
+test("docs changes do not wait for unrelated workflows", (t) => {
+ const selected = repository(t).select(["docs/docs/photos/faq.md"]);
+ assert.deepEqual(selected, ["docs-verify-build", "repo-lint"]);
+ assert.deepEqual(failures(results(selected)), []);
+});
+
+test("shared Rust changes select their consumers", (t) => {
+ const repo = repository(t);
+ assert.deepEqual(repo.select(["rust/crates/core/src/lib.rs"]), [
+ "ensu-android-build", "ensu-ios-build", "mobile-lint", "repo-lint", "rust-lint", "rust-test", "web-lint",
+ ]);
+ assert.ok(repo.select(["server/pkg/api.go"]).includes("rust-test"));
+ assert.ok(repo.select(["rust/bindings/napi/src/lib.rs"]).includes("desktop-lint"));
+});
+
+test("path filters cover root files, nested files, and dotfiles", (t) => {
+ const repo = repository(t);
+ for (const file of ["Cargo.lock", "rust/Cargo.lock", "rust/.config/Cargo.lock"]) {
+ assert.ok(repo.select([file]).includes("dependency-review"), file);
+ }
+ for (const file of ["mobile/Podfile", "mobile/apps/photos/Podfile", "mobile/apps/photos/test.podspec"]) {
+ assert.ok(repo.select([file]).includes("mobile-podfile-lock"), file);
+ }
+ for (const file of ["web/.prettierrc.json", "web/.config/deep/file.js", "web/apps/file\nname.js"]) {
+ assert.ok(repo.select([file]).includes("web-lint"), file);
+ }
+ assert.deepEqual(repo.select(["README.md", "website/page.js", "CargoXlock"]), ["repo-lint"]);
+ assert.deepEqual(repo.select([]), ["repo-lint"]);
+ assert.ok(repo.select([".github/workflows/mobile-lint.yml"]).includes("mobile-lint"));
+});
+
+test("deletions and moves select every affected area", (t) => {
+ const { cwd, empty, tree } = repository(t);
+ const before = tree(["web/shared.txt"]);
+ assert.deepEqual(select(before, empty, cwd), ["repo-lint", "web-lint"]);
+ assert.deepEqual(select(before, tree(["desktop/shared.txt"]), cwd), ["desktop-lint", "repo-lint", "web-lint"]);
+});
+
+test("changes to CI selection or wiring run every workflow", (t) => {
+ const repo = repository(t);
+ for (const file of [".github/scripts/ci/paths.json", ".github/scripts/ci/check.mjs", ".github/workflows/ci.yml"]) {
+ assert.deepEqual(repo.select([file]), Object.keys(paths));
+ }
+});
+
+test("selected failures, cancellations, and skips block merging", () => {
+ for (const result of ["failure", "cancelled", "skipped"]) {
+ const needs = results(["repo-lint", "web-lint"]);
+ needs["web-lint"].result = result;
+ assert.notDeepEqual(failures(needs), []);
+ }
+});
+
+test("failed selection and missing results cannot report success", () => {
+ const needs = results(["repo-lint"]);
+ needs.select.result = "failure";
+ assert.notDeepEqual(failures(needs), []);
+ needs.select.result = "success";
+ delete needs["repo-lint"];
+ assert.notDeepEqual(failures(needs), []);
+ needs.select.outputs.jobs = "[]";
+ assert.throws(() => failures(needs), /Invalid CI selection/);
+});
+
+test("Git errors stop selection", (t) => {
+ const { cwd, empty } = repository(t);
+ assert.throws(() => select("not-a-revision", empty, cwd));
+});
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000000..ff7640da32
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,117 @@
+name: CI
+
+on:
+ pull_request:
+
+permissions:
+ contents: read
+
+concurrency:
+ group: ci-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ select:
+ name: Select CI
+ runs-on: ubuntu-latest
+ outputs:
+ jobs: ${{ steps.select.outputs.jobs }}
+ steps:
+ - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
+ with:
+ fetch-depth: 2
+ persist-credentials: false
+ - id: select
+ run: node .github/scripts/ci/check.mjs select HEAD^1 HEAD
+
+ dependency-review:
+ needs: select
+ if: ${{ contains(fromJSON(needs.select.outputs.jobs), 'dependency-review') }}
+ uses: ./.github/workflows/dependency-review.yml
+
+ desktop-lint:
+ needs: select
+ if: ${{ contains(fromJSON(needs.select.outputs.jobs), 'desktop-lint') }}
+ uses: ./.github/workflows/desktop-lint.yml
+
+ docs-verify-build:
+ needs: select
+ if: ${{ contains(fromJSON(needs.select.outputs.jobs), 'docs-verify-build') }}
+ uses: ./.github/workflows/docs-verify-build.yml
+
+ ensu-android-build:
+ needs: select
+ if: ${{ contains(fromJSON(needs.select.outputs.jobs), 'ensu-android-build') }}
+ uses: ./.github/workflows/ensu-android-build.yml
+
+ ensu-ios-build:
+ needs: select
+ if: ${{ contains(fromJSON(needs.select.outputs.jobs), 'ensu-ios-build') }}
+ uses: ./.github/workflows/ensu-ios-build.yml
+
+ infra-lint-staff:
+ needs: select
+ if: ${{ contains(fromJSON(needs.select.outputs.jobs), 'infra-lint-staff') }}
+ uses: ./.github/workflows/infra-lint-staff.yml
+
+ mobile-lint:
+ needs: select
+ if: ${{ contains(fromJSON(needs.select.outputs.jobs), 'mobile-lint') }}
+ uses: ./.github/workflows/mobile-lint.yml
+
+ mobile-podfile-lock:
+ needs: select
+ if: ${{ contains(fromJSON(needs.select.outputs.jobs), 'mobile-podfile-lock') }}
+ uses: ./.github/workflows/mobile-podfile-lock.yml
+
+ repo-lint:
+ needs: select
+ if: ${{ contains(fromJSON(needs.select.outputs.jobs), 'repo-lint') }}
+ uses: ./.github/workflows/repo-lint.yml
+
+ rust-lint:
+ needs: select
+ if: ${{ contains(fromJSON(needs.select.outputs.jobs), 'rust-lint') }}
+ uses: ./.github/workflows/rust-lint.yml
+
+ rust-test:
+ needs: select
+ if: ${{ contains(fromJSON(needs.select.outputs.jobs), 'rust-test') }}
+ uses: ./.github/workflows/rust-test.yml
+
+ server-lint:
+ needs: select
+ if: ${{ contains(fromJSON(needs.select.outputs.jobs), 'server-lint') }}
+ uses: ./.github/workflows/server-lint.yml
+
+ web-lint:
+ needs: select
+ if: ${{ contains(fromJSON(needs.select.outputs.jobs), 'web-lint') }}
+ uses: ./.github/workflows/web-lint.yml
+
+ required:
+ name: CI required
+ if: ${{ always() }}
+ needs:
+ - select
+ - dependency-review
+ - desktop-lint
+ - docs-verify-build
+ - ensu-android-build
+ - ensu-ios-build
+ - infra-lint-staff
+ - mobile-lint
+ - mobile-podfile-lock
+ - repo-lint
+ - rust-lint
+ - rust-test
+ - server-lint
+ - web-lint
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
+ with:
+ persist-credentials: false
+ - run: node .github/scripts/ci/check.mjs result
+ env:
+ NEEDS: ${{ toJSON(needs) }}
diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml
index b80456b951..751a2e2960 100644
--- a/.github/workflows/dependency-review.yml
+++ b/.github/workflows/dependency-review.yml
@@ -1,18 +1,7 @@
name: "Dependency review"
on:
- pull_request:
- paths:
- - "**/Cargo.lock"
- - "**/Cargo.toml"
- - "**/go.mod"
- - "**/go.sum"
- - "**/package-lock.json"
- - "**/package.json"
- - "**/pubspec.lock"
- - "**/pubspec.yaml"
- - "**/uv.lock"
- - ".github/workflows/dependency-review.yml"
+ workflow_call:
permissions:
contents: read
diff --git a/.github/workflows/desktop-lint.yml b/.github/workflows/desktop-lint.yml
index 274b654331..15a20ecaaf 100644
--- a/.github/workflows/desktop-lint.yml
+++ b/.github/workflows/desktop-lint.yml
@@ -1,16 +1,7 @@
name: "Lint (Photos desktop)"
on:
- pull_request:
- paths:
- - ".github/workflows/desktop-lint.yml"
- - "desktop/**"
- - "rust/Cargo.lock"
- - "rust/Cargo.toml"
- - "rust/bindings/napi/**"
- - "rust/crates/image/**"
- - "rust/crates/ml/**"
- - "rust/tools/codegen/**"
+ workflow_call:
permissions:
contents: read
diff --git a/.github/workflows/docs-verify-build.yml b/.github/workflows/docs-verify-build.yml
index 23fdfb149e..96c6f5c070 100644
--- a/.github/workflows/docs-verify-build.yml
+++ b/.github/workflows/docs-verify-build.yml
@@ -1,10 +1,7 @@
name: "Verify build (Docs)"
on:
- pull_request:
- paths:
- - ".github/workflows/docs-verify-build.yml"
- - "docs/**"
+ workflow_call:
permissions:
contents: read
diff --git a/.github/workflows/ensu-android-build.yml b/.github/workflows/ensu-android-build.yml
index e154478a52..30b3f887ad 100644
--- a/.github/workflows/ensu-android-build.yml
+++ b/.github/workflows/ensu-android-build.yml
@@ -1,26 +1,11 @@
name: "Build (Ensu Android)"
on:
- pull_request:
- paths:
- - ".github/workflows/ensu-android-build.yml"
- - "android/apps/ensu/**"
- - "android/apps/ensu/rust/**"
- - "rust/.cargo/config.toml"
- - "rust/Cargo.lock"
- - "rust/Cargo.toml"
- - "rust/bindings/uniffi/**"
- - "rust/crates/core/**"
- - "rust/crates/ensu/**"
- - "rust/tools/codegen/**"
+ workflow_call:
permissions:
contents: read
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
-
jobs:
build:
runs-on: ubuntu-latest
diff --git a/.github/workflows/ensu-ios-build.yml b/.github/workflows/ensu-ios-build.yml
index 8b7b33341f..ea93bafeb6 100644
--- a/.github/workflows/ensu-ios-build.yml
+++ b/.github/workflows/ensu-ios-build.yml
@@ -1,26 +1,11 @@
name: "Build (Ensu iOS)"
on:
- pull_request:
- paths:
- - ".github/workflows/ensu-ios-build.yml"
- - "apple/apps/ensu/**"
- - "apple/packages/EnteOnnxRuntime/**"
- - "rust/.cargo/config.toml"
- - "rust/Cargo.lock"
- - "rust/Cargo.toml"
- - "rust/bindings/uniffi/**"
- - "rust/crates/core/**"
- - "rust/crates/ensu/**"
- - "rust/tools/codegen/**"
+ workflow_call:
permissions:
contents: read
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
-
jobs:
build-and-test:
runs-on: macos-26
diff --git a/.github/workflows/infra-lint-staff.yml b/.github/workflows/infra-lint-staff.yml
index 4835d7a9dd..1c8686780b 100644
--- a/.github/workflows/infra-lint-staff.yml
+++ b/.github/workflows/infra-lint-staff.yml
@@ -1,10 +1,7 @@
name: "Lint (Staff)"
on:
- pull_request:
- paths:
- - ".github/workflows/infra-lint-staff.yml"
- - "infra/staff/**"
+ workflow_call:
permissions:
contents: read
diff --git a/.github/workflows/mobile-lint.yml b/.github/workflows/mobile-lint.yml
index a1ef77123a..e5eba80479 100644
--- a/.github/workflows/mobile-lint.yml
+++ b/.github/workflows/mobile-lint.yml
@@ -1,21 +1,7 @@
name: "Lint (Mobile)"
on:
- pull_request:
- paths:
- - ".github/workflows/mobile-lint.yml"
- - "mobile/**"
- - "rust/Cargo.lock"
- - "rust/Cargo.toml"
- - "rust/bindings/frb/**"
- - "rust/crates/cast/**"
- - "rust/crates/contacts/**"
- - "rust/crates/core/**"
- - "rust/crates/image/**"
- - "rust/crates/locker/**"
- - "rust/crates/ml/**"
- - "rust/crates/photos/**"
- - "rust/tools/codegen/**"
+ workflow_call:
workflow_dispatch:
permissions:
diff --git a/.github/workflows/mobile-podfile-lock.yml b/.github/workflows/mobile-podfile-lock.yml
index 5b2b8b2010..4eab34312e 100644
--- a/.github/workflows/mobile-podfile-lock.yml
+++ b/.github/workflows/mobile-podfile-lock.yml
@@ -1,24 +1,12 @@
name: "Verify Podfile.lock (Mobile)"
on:
- pull_request:
- paths:
- - ".github/workflows/mobile-podfile-lock.yml"
- - "apple/packages/EnteOnnxRuntime/EnteOnnxRuntime.podspec"
- - "mobile/**/*.podspec"
- - "mobile/**/Podfile"
- - "mobile/**/Podfile.lock"
- - "mobile/**/pubspec.lock"
- - "mobile/**/pubspec.yaml"
+ workflow_call:
workflow_dispatch:
permissions:
contents: read
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
-
jobs:
pod-check:
runs-on: macos-26
diff --git a/.github/workflows/repo-lint.yml b/.github/workflows/repo-lint.yml
index 21dcdec289..f4232e4a22 100644
--- a/.github/workflows/repo-lint.yml
+++ b/.github/workflows/repo-lint.yml
@@ -1,15 +1,11 @@
name: "Lint (Repo)"
on:
- pull_request:
+ workflow_call:
permissions:
contents: read
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
-
jobs:
lint:
runs-on: ubuntu-latest
diff --git a/.github/workflows/rust-lint.yml b/.github/workflows/rust-lint.yml
index 57105bcc31..df812789c3 100644
--- a/.github/workflows/rust-lint.yml
+++ b/.github/workflows/rust-lint.yml
@@ -1,18 +1,11 @@
name: "Lint (Rust)"
on:
- pull_request:
- paths:
- - ".github/workflows/rust-lint.yml"
- - "rust/**"
+ workflow_call:
permissions:
contents: read
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
-
env:
RUSTFLAGS: -D warnings
diff --git a/.github/workflows/rust-test.yml b/.github/workflows/rust-test.yml
index 00652016e2..0fcf78e3f2 100644
--- a/.github/workflows/rust-test.yml
+++ b/.github/workflows/rust-test.yml
@@ -1,19 +1,11 @@
name: "Test (Rust)"
on:
- pull_request:
- paths:
- - ".github/workflows/rust-test.yml"
- - "rust/**"
- - "server/**"
+ workflow_call:
permissions:
contents: read
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
-
env:
RUSTFLAGS: -D warnings
diff --git a/.github/workflows/server-lint.yml b/.github/workflows/server-lint.yml
index f60aea5307..a9df9d7ce7 100644
--- a/.github/workflows/server-lint.yml
+++ b/.github/workflows/server-lint.yml
@@ -1,18 +1,11 @@
name: "Lint (Server)"
on:
- pull_request:
- paths:
- - ".github/workflows/server-lint.yml"
- - "server/**"
+ workflow_call:
permissions:
contents: read
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
-
jobs:
lint:
runs-on: ubuntu-latest
diff --git a/.github/workflows/web-lint.yml b/.github/workflows/web-lint.yml
index f39623888b..142a773d69 100644
--- a/.github/workflows/web-lint.yml
+++ b/.github/workflows/web-lint.yml
@@ -1,31 +1,11 @@
name: "Lint (Web)"
on:
- pull_request:
- paths:
- - ".github/workflows/web-lint.yml"
- - "rust/Cargo.lock"
- - "rust/Cargo.toml"
- - "rust/bindings/wasm/**"
- - "rust/crates/accounts/**"
- - "rust/crates/cast/**"
- - "rust/crates/collections/**"
- - "rust/crates/contacts/**"
- - "rust/crates/core/**"
- - "rust/crates/ensu-crypto/**"
- - "rust/crates/legacy/**"
- - "rust/crates/locker/**"
- - "rust/crates/paste/**"
- - "rust/crates/space/**"
- - "web/**"
+ workflow_call:
permissions:
contents: read
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
-
jobs:
lint:
runs-on: ubuntu-latest