From d3b967ce1cd6d7e1cabe7ba51ca1efd0fe408f4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Thu, 24 Mar 2022 16:44:02 +0100 Subject: [PATCH] chore: make codegen message cleaner --- scripts/ci/codegen/__tests__/codegen.test.ts | 15 ++++++++++----- scripts/ci/codegen/text.ts | 17 +++++++++++------ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/scripts/ci/codegen/__tests__/codegen.test.ts b/scripts/ci/codegen/__tests__/codegen.test.ts index 0471c03441..4bcf4680c4 100644 --- a/scripts/ci/codegen/__tests__/codegen.test.ts +++ b/scripts/ci/codegen/__tests__/codegen.test.ts @@ -48,7 +48,7 @@ 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._" `); @@ -56,7 +56,7 @@ describe('codegen', () => { 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)._" `); @@ -64,7 +64,7 @@ describe('codegen', () => { 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)." `); @@ -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) | + " `); }); }); diff --git a/scripts/ci/codegen/text.ts b/scripts/ci/codegen/text.ts index 50611be8fe..14e942c004 100644 --- a/scripts/ci/codegen/text.ts +++ b/scripts/ci/codegen/text.ts @@ -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}) | +`; }, }, };