From e9b4ad713362ef8302f26fac17e931a6f493bec0 Mon Sep 17 00:00:00 2001 From: Leblanc Meneses Date: Wed, 18 Dec 2024 23:47:52 -0600 Subject: [PATCH] [affected][documentation]: README.md updates to show --- README.md | 20 ++++++++++--- apps/e2e/src/affected/affected.spec.ts | 41 +++++++++++++++++++++----- 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 555b800..480a94a 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,9 @@ ## Affected Action -This task generates a JSON object to streamline your pipeline by skipping unnecessary steps and running only those affected by `changes`. It also aligns git commits with images via `recommended_imagetags` and `shas`, simplifying GitOps strategies. +This task generates a JSON object to optimize your pipeline by skipping unnecessary steps and executing only those impacted by `changes`. It also aligns Git commits with images using `recommended_imagetags` and `shas`, which represent hashes of the dependency graph defined by specified rules. + +We recommend using `changes` for pull requests and `shas` for core branches like `main`, `develop`, and `prod`, serving as a dependency graph key for caching purposes. ```yaml @@ -62,11 +64,18 @@ jobs: peggy-parser: 'apps/affected/src/parser.peggy'; peggy-parser-checkIf-incomplete: peggy-parser AND (!'apps/affected/src/parser.ts' OR !'apps/e2e/src/affected/parser.spec.ts'); # peggy was updated but not the generated parser file or its tests. + markdown: '**/*.md'; - : 'project-ui/**' EXCEPT (markdown '**/*.spec.ts'); + + ui-core: 'libs/ui-core/**'; + third-party-deprecated: 'libs/third-party-deprecated/**'; + ui-libs: ui-core third-party-deprecated; + + : ui-libs 'project-ui/**' EXCEPT (markdown '**/*.spec.ts'); : 'project-api/**' EXCEPT ('**/README.md'); : './databases/project/**'; - project-e2e: (project-ui project-api project-dbmigrations) EXCEPT (markdown); + + project-e2e: ('e2e/**' project-ui project-api project-dbmigrations) EXCEPT (markdown); ``` ### Rule DSL @@ -163,7 +172,10 @@ The `affected` action will generate the following JSON objects: "project-api": false, "project-ui": true, "project-dbmigrations": false, - "project-e2e": true + "project-e2e": true, + "third-party-deprecated": false, + "ui-core": false, + "ui-libs": false }, "shas": { "project-ui": "38aabc2d6ae9866f3c1d601cba956bb935c02cf5", diff --git a/apps/e2e/src/affected/affected.spec.ts b/apps/e2e/src/affected/affected.spec.ts index 1b2963d..9e06c48 100644 --- a/apps/e2e/src/affected/affected.spec.ts +++ b/apps/e2e/src/affected/affected.spec.ts @@ -30,10 +30,23 @@ describe("affected.spec", () => { jest.spyOn(core, "getInput").mockImplementation((inputName: string) => { if (inputName === "rules") return ` - : 'project-ui/**' EXCEPT('**/*.md'); - : 'project-api/**' EXCEPT('**/*.md'); - : 'databases/project/**' EXCEPT('**/*.md'); - project-e2e: ('e2e/**' project-ui project-api project-dbmigrations) EXCEPT('**/*.md'); + peggy-parser: 'apps/affected/src/parser.peggy'; + peggy-parser-checkIf-incomplete: peggy-parser AND (!'apps/affected/src/parser.ts' OR !'apps/e2e/src/affected/parser.spec.ts'); + # peggy was updated but not the generated parser file or its tests. + + markdown: '**/*.md'; + + ui-core: 'libs/ui-core/**'; + third-party-deprecated: 'libs/third-party-deprecated/**'; + ui-libs: ui-core third-party-deprecated; + + : ui-libs 'project-ui/**' EXCEPT (markdown '**/*.spec.ts'); + : 'project-api/**' EXCEPT ('**/README.md'); + : './databases/project/**'; + + project-e2e: ('e2e/**' project-ui project-api project-dbmigrations) EXCEPT (markdown); + + project-ui-run-lint: 'milagro-api/**/*.ts'; `; return ""; }); @@ -50,9 +63,9 @@ describe("affected.spec", () => { const execSyncResponses = { 'git diff --name-status HEAD~1 HEAD': () => [ - "project-ui/file1.ts", - "project-api/README.md", - ].map(f => `M\t${f}`).join('\n'), + "project-ui/file1.ts", + "project-api/README.md", + ].map(f => `M\t${f}`).join('\n'), 'git ls-files': () => files.join('\n'), }; @@ -97,7 +110,19 @@ describe("affected.spec", () => { .digest('hex'); } - expect(core.setOutput).toHaveBeenCalledWith("affected_changes", { "project-api": false, "project-dbmigrations": false, "project-e2e": true, "project-ui": true }); + expect(core.setOutput).toHaveBeenCalledWith("affected_changes", { + "markdown": true, + "peggy-parser": false, + "peggy-parser-checkIf-incomplete": false, + "project-api": false, + "project-dbmigrations": false, + "project-e2e": true, + "project-ui": true, + "project-ui-run-lint": false, + "third-party-deprecated": false, + "ui-core": false, + "ui-libs": false + }); expect(core.setOutput).toHaveBeenCalledWith("affected_shas", { 'project-api': getHash('project-api/'), 'project-dbmigrations': getHash('databases/project/'),