Skip to content

chore: make codegen message cleaner #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions scripts/ci/codegen/__tests__/codegen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,23 @@ describe('codegen', () => {
describe('getCommentBody', () => {
it('returns the right comment for a `notification` trigger', async () => {
expect(await getCommentBody('notification')).toMatchInlineSnapshot(`
"🔨 The codegen job will run at the end of the CI.
"### 🔨 The codegen job will run at the end of the CI.

_Make sure your last commit does not contains generated code, it will be automatically pushed by our CI._"
`);
});

it('returns the right comment for a `noGen` trigger', async () => {
expect(await getCommentBody('noGen')).toMatchInlineSnapshot(`
"✗ No code generated.
"### ✗ No code generated.

_If you believe this is an issue on our side, please [open an issue](https://github.com/algolia/api-clients-automation/issues/new?template=Bug_report.md)._"
`);
});

it('returns the right comment for a `cleanup` trigger', async () => {
expect(await getCommentBody('cleanup')).toMatchInlineSnapshot(`
"✗ The generated branch has been deleted.
"### ✗ The generated branch has been deleted.

If the PR has been merged, you can check the generated code on the [\`generated/main\` branch](https://github.com/algolia/api-clients-automation/tree/generated/main)."
`);
Expand All @@ -80,8 +80,13 @@ describe('codegen', () => {
'theGeneratedCommit'
)
).toMatchInlineSnapshot(`
"🔨 Triggered by commit [myCommit](https://github.com/algolia/api-clients-automation/pull/42/commits/myCommit).
🔍 Browse the generated code on branch [myBranch](https://github.com/algolia/api-clients-automation/tree/myBranch): [theGeneratedCommit](https://github.com/algolia/api-clients-automation/commit/theGeneratedCommit)."
"
| Name | Link |
|---------------------------------|------------------------|
| 🔨 Triggered by | [\`myCommit\`](https://github.com/algolia/api-clients-automation/pull/42/commits/myCommit) |
| 🔍 Generated code | [\`theGeneratedCommit\`](https://github.com/algolia/api-clients-automation/commit/theGeneratedCommit) |
| 🌲 Generated branch | [\`myBranch\`](https://github.com/algolia/api-clients-automation/tree/myBranch) |
"
`);
});
});
Expand Down
17 changes: 11 additions & 6 deletions scripts/ci/codegen/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,32 @@ const REPO_URL = `https://github.com/${OWNER}/${REPO}`;

export default {
notification: {
header: '🔨 The codegen job will run at the end of the CI.',
header: '### 🔨 The codegen job will run at the end of the CI.',
body: '_Make sure your last commit does not contains generated code, it will be automatically pushed by our CI._',
},
noGen: {
header: '✗ No code generated.',
header: '### ✗ No code generated.',
body: `_If you believe this is an issue on our side, please [open an issue](${REPO_URL}/issues/new?template=Bug_report.md)._`,
},
cleanup: {
header: '✗ The generated branch has been deleted.',
header: '### ✗ The generated branch has been deleted.',
body: `If the PR has been merged, you can check the generated code on the [\`generated/main\` branch](${REPO_URL}/tree/generated/main).`,
},
codegen: {
header: '✔️ Code generated!',
header: '### ✔️ Code generated!',
body(
branch: string,
commit: string,
eventNumber: number,
generatedCommit: string
): string {
return `🔨 Triggered by commit [${commit}](${REPO_URL}/pull/${eventNumber}/commits/${commit}).
🔍 Browse the generated code on branch [${branch}](${REPO_URL}/tree/${branch}): [${generatedCommit}](${REPO_URL}/commit/${generatedCommit}).`;
return `
| Name | Link |
|---------------------------------|------------------------|
| 🔨 Triggered by | [\`${commit}\`](${REPO_URL}/pull/${eventNumber}/commits/${commit}) |
| 🔍 Generated code | [\`${generatedCommit}\`](${REPO_URL}/commit/${generatedCommit}) |
| 🌲 Generated branch | [\`${branch}\`](${REPO_URL}/tree/${branch}) |
`;
},
},
};