π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[ci] Limit documentation approval to README files
laurenspriem3bda8416eaca
diff --git a/.github/checks/change-approval/files.mjs b/.github/checks/change-approval/files.mjsindex e30721f507..4652894e30 100644--- a/.github/checks/change-approval/files.mjs+++ b/.github/checks/change-approval/files.mjs@@ -73,11 +73,10 @@ export function checkFiles({ files }) {const configs = files.filter(({ path }) => configFile.test(path)).map(({ path }) => path);- const markdown = files+ const readmes = files.filter(- ({ path, deleted }) =>- !deleted && /\.(md|markdown|mdx)$/i.test(path),+ ({ path, deleted }) => !deleted && /^readme/i.test(basename(path)),).map(({ path }) => path);- return { binaries, large, guardrails, configs, markdown };+ return { binaries, large, guardrails, configs, readmes };}diff --git a/.github/checks/change-approval/report.mjs b/.github/checks/change-approval/report.mjsindex 81f6e8a447..d297183922 100644--- a/.github/checks/change-approval/report.mjs+++ b/.github/checks/change-approval/report.mjs@@ -1,7 +1,7 @@import { appendFileSync } from "node:fs";export function writeReport({- files: { binaries, large, guardrails, configs, markdown },+ files: { binaries, large, guardrails, configs, readmes },dependencies,rust,swift,@@ -42,9 +42,9 @@ export function writeReport({count: configs.length,},{- singular: "Markdown file",- plural: "Markdown files",- count: markdown.length,+ singular: "README file",+ plural: "README files",+ count: readmes.length,},{singular: "Rust lint policy file",@@ -97,8 +97,8 @@ export function writeReport({sections.push(`## Toolchain and registry config\n\n${list(configs.map(code))}`,);- if (markdown.length)- sections.push(`## Markdown files\n\n${list(markdown.map(code))}`);+ if (readmes.length)+ sections.push(`## README files\n\n${list(readmes.map(code))}`);if (rust.length)sections.push(`## Rust lint declarations and files containing unsafe\n\n${list(rust.map(({ path, reasons }) => `${code(path)}: ${reasons.map(code).join("; ")}`))}`,diff --git a/.github/checks/change-approval/test.mjs b/.github/checks/change-approval/test.mjsindex 42348909ae..794037497f 100644--- a/.github/checks/change-approval/test.mjs+++ b/.github/checks/change-approval/test.mjs@@ -216,63 +216,64 @@ test("binary deleted is ignored", (t) => {assert.equal(scan(t, { "a.bin": Buffer.alloc(16) }, { "a.bin": null }), "");});-test("Markdown additions and edits need approval in CI", (t) => {+test("README additions and edits need approval in CI", (t) => {const changed = {+ README: "# New\n","README.md": "# Updated\n",- "docs/empty.md": "",- "docs/guide.MARKDOWN": "# Guide\n",- "web/page.MDX": "# Page\n",+ "docs/README.fr.md": "# Guide\n",+ "mobile/readme-notes.txt": "# Notes\n",+ "rust/crates/example/ReadMe": "",};const { stdout, output, summary } = scan(t,{ "README.md": "# Original\n" },- { ...changed, "notes.md.txt": "Not Markdown\n" },+ changed,{ ci: true },);- assert.equal(output, 'categories=["Markdown files"]\n');+ assert.equal(output, 'categories=["README files"]\n');assert.equal(stdout,- "::warning title=Change approval needed::4 Markdown files\n",+ "::warning title=Change approval needed::5 README files\n",);assert.equal(summary,- `4 Markdown files\n\n## Markdown files\n\n${Object.keys(changed)+ `5 README files\n\n## README files\n\n${Object.keys(changed).map((path) => `- \`${path}\``).join("\n")}\n`,);});-test("Markdown edits and untracked files are scanned locally", (t) => {+test("README edits and untracked files are scanned locally", (t) => {const output = scan(t,- { "docs/guide.md": "# Original\n" },- { "docs/guide.md": "# Updated\n", "README.MD": "# New\n" },+ { "docs/readme.md": "# Original\n" },+ { "docs/readme.md": "# Updated\n", README: "# New\n" },{ commit: false },);- assert.match(output, /^2 Markdown files\n/);- assert.match(output, /- `docs\/guide.md`/);- assert.match(output, /- `README.MD`/);+ assert.match(output, /^2 README files\n/);+ assert.match(output, /- `docs\/readme.md`/);+ assert.match(output, /- `README`/);});-test("renaming a text file to Markdown needs approval", (t) => {+test("renaming a file to README needs approval", (t) => {const { output, summary } = scan(t,{ "guide.txt": "# Guide\n" },- { "guide.txt": null, "guide.md": "# Guide\n" },+ { "guide.txt": null, "README.txt": "# Guide\n" },{ ci: true },);- assert.equal(output, 'categories=["Markdown files"]\n');+ assert.equal(output, 'categories=["README files"]\n');assert.equal(summary,- "1 Markdown file\n\n## Markdown files\n\n- `guide.md`\n",+ "1 README file\n\n## README files\n\n- `README.txt`\n",);});-test("unchanged Markdown and deletions need no approval", (t) => {+test("unchanged READMEs and deletions need no approval", (t) => {const { stdout, output, summary } = scan(t,- { "README.md": "# Keep\n", "docs/old.md": "# Remove\n" },- { "docs/old.md": null, "notes.txt": "Ordinary change\n" },+ { "README.md": "# Keep\n", "docs/README.old": "# Remove\n" },+ { "docs/README.old": null, "notes.txt": "Ordinary change\n" },{ ci: true },);assert.equal(stdout, "");@@ -280,6 +281,42 @@ test("unchanged Markdown and deletions need no approval", (t) => {assert.equal(summary, "No approval needed.\n");});+test("ordinary Markdown additions and edits need no approval", (t) => {+ for (const ci of [false, true]) {+ const result = scan(+ t,+ { "random.md": "# Original\n" },+ {+ "random.md": "# Updated\n",+ "docs/guide.markdown": "# Guide\n",+ "web/page.MDX": "# Page\n",+ "README-assets/notes.md": "# Notes\n",+ "docs/not-README.md": "# Other\n",+ },+ { ci, commit: ci },+ );+ if (ci) {+ assert.deepEqual(result, {+ stdout: "",+ output: "categories=[]\n",+ summary: "No approval needed.\n",+ });+ } else {+ assert.equal(result, "");+ }+ }+});++test("Markdown changes in GitHub guardrails still need approval", (t) => {+ const { output } = scan(+ t,+ {},+ { ".github/PULL_REQUEST_TEMPLATE.md": "# Template\n" },+ { ci: true },+ );+ assert.equal(output, 'categories=["guardrail files"]\n');+});+test("CI preserves tabs and newlines in binary and large filenames", (t) => {const binary = "image.png\tpayload.jar";const large = "large\nfile.txt";@@ -1332,7 +1369,7 @@ test("workflow scans PR changes with the complete checker from main", (t) => {'throw new Error("loaded an untrusted rule");',[`${checkerDir}/files.mjs`]:'throw new Error("loaded an untrusted file rule");',- "docs/guide.md": "# Guide\n",+ "docs/README.md": "# Guide\n","src/lib.rs": "pub unsafe fn call() {}","web/example.ts":"// eslint-disable-next-line no-console\nfirst();\n",@@ -1341,10 +1378,10 @@ test("workflow scans PR changes with the complete checker from main", (t) => {);assert.equal(output,- 'categories=["guardrail files","Markdown files","Rust lint policy files","Web lint policy files"]\n',+ 'categories=["guardrail files","README files","Rust lint policy files","Web lint policy files"]\n',);assert.match(summary, /- `src\/lib.rs`/);assert.match(summary, /- `web\/example.ts`/);assert.match(summary, /- `rust\/Cargo.toml`/);- assert.match(summary, /- `docs\/guide.md`/);+ assert.match(summary, /- `docs\/README.md`/);});