Skip to content

Commit

Permalink
[affected][documentation]: README.md updates to show
Browse files Browse the repository at this point in the history
  • Loading branch information
leblancmeneses committed Dec 19, 2024
1 parent b027708 commit e9b4ad7
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 12 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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>: '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;
<project-ui>: ui-libs 'project-ui/**' EXCEPT (markdown '**/*.spec.ts');
<project-api>: 'project-api/**' EXCEPT ('**/README.md');
<project-dbmigrations>: './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
Expand Down Expand Up @@ -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",
Expand Down
41 changes: 33 additions & 8 deletions apps/e2e/src/affected/affected.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,23 @@ describe("affected.spec", () => {

jest.spyOn(core, "getInput").mockImplementation((inputName: string) => {
if (inputName === "rules") return `
<project-ui>: 'project-ui/**' EXCEPT('**/*.md');
<project-api>: 'project-api/**' EXCEPT('**/*.md');
<project-dbmigrations>: '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;
<project-ui>: ui-libs 'project-ui/**' EXCEPT (markdown '**/*.spec.ts');
<project-api>: 'project-api/**' EXCEPT ('**/README.md');
<project-dbmigrations>: './databases/project/**';
project-e2e: ('e2e/**' project-ui project-api project-dbmigrations) EXCEPT (markdown);
project-ui-run-lint: 'milagro-api/**/*.ts';
`;
return "";
});
Expand All @@ -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'),
};

Expand Down Expand Up @@ -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/'),
Expand Down

0 comments on commit e9b4ad7

Please sign in to comment.