Skip to content

armgit / ente

Public Imported from GitHub
0

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

Require approval for newly added lint configurations

Manav Rathi21697cf9ef2a
diff --git a/.github/checks/change-approval/files.mjs b/.github/checks/change-approval/files.mjs
index 0b41e304e1..dbf1c5ea50 100644
--- a/.github/checks/change-approval/files.mjs
+++ b/.github/checks/change-approval/files.mjs
@@ -4,7 +4,6 @@ const routineBinary = (file) =>
/\.(png|jpe?g|webp|gif|ico|icns|ttf|otf|woff2?|riv|mp3)$/i.test(file) ||
file.includes("Assets.xcassets/");
const guardrailDirs = [
- ".github/",
"apple/scripts/",
"mobile/checks/",
"mobile/scripts/",
@@ -19,6 +18,8 @@ const guardrailFiles = new Set([
"apple/Package.swift",
".swift-format",
".swiftlint.yml",
+ "rustfmt.toml",
+ ".rustfmt.toml",
"eslint.config.mjs",
".prettierrc.json",
"analysis_options.yaml",
@@ -36,18 +37,15 @@ export function checkFiles({ files }) {
const large = files
.filter(({ added, size }) => added && size > 1024 * 1024)
.map(({ path, size }) => ({ path, size }));
- const guardrails = [
- ...files.filter(
+ const guardrails = files
+ .filter(
({ path, added }) =>
- !added &&
- (guardrailDirs.some((dir) => path.startsWith(dir)) ||
- guardrailFiles.has(path) ||
- guardrailFiles.has(basename(path))),
- ),
- ...files.filter(
- ({ path, added }) => added && path.startsWith(".github/"),
- ),
- ].map(({ path }) => path);
+ path.startsWith(".github/") ||
+ (!added && guardrailDirs.some((dir) => path.startsWith(dir))) ||
+ guardrailFiles.has(path) ||
+ guardrailFiles.has(basename(path)),
+ )
+ .map(({ path }) => path);
const configs = files
.filter(({ path }) => configFile.test(path))
.map(({ path }) => path);
diff --git a/.github/checks/change-approval/test.mjs b/.github/checks/change-approval/test.mjs
index fa61965387..7250631bae 100644
--- a/.github/checks/change-approval/test.mjs
+++ b/.github/checks/change-approval/test.mjs
@@ -638,6 +638,24 @@ test("new GitHub workflows, actions and policies need approval", (t) => {
assert.match(scan(t, {}, files, { commit: false }), /^3 guardrail files\n/);
});
+test("new lint and formatter configs need approval, including untracked files", (t) => {
+ const files = {
+ ".github/checks/new/.prettierrc.json": "{}\n",
+ "apple/apps/cast/.swift-format": "{}\n",
+ "apple/apps/cast/.swiftlint.yml": "only_rules: []\n",
+ "rust/crates/example/.rustfmt.toml": "max_width = 120\n",
+ "rust/rustfmt.toml": "max_width = 120\n",
+ "web/apps/photos/nested/.prettierrc.json": "{}\n",
+ "web/apps/photos/nested/eslint.config.mjs": "export default [];\n",
+ };
+ const { output, summary } = scan(t, {}, files, { ci: true });
+ assert.equal(output, 'categories=["guardrail files"]\n');
+ assert.match(summary, /^7 guardrail files\n/);
+ for (const file of Object.keys(files))
+ assert.ok(summary.includes(`\`${file}\``));
+ assert.match(scan(t, {}, files, { commit: false }), /^7 guardrail files\n/);
+});
+
test("toolchain and registry config added, modified, or deleted", (t) => {
const output = scan(
t,