From 25f52d77cceca2f1ba5a4a150bc11b88e18716e7 Mon Sep 17 00:00:00 2001 From: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com> Date: Thu, 16 Jun 2022 13:16:45 +1000 Subject: [PATCH 1/7] Add comment-key input --- action.yml | 3 +++ src/index.js | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 25e0b6f..5e513f7 100644 --- a/action.yml +++ b/action.yml @@ -39,6 +39,9 @@ inputs: default: '{**/*.map,**/node_modules/**}' cwd: description: 'A custom working directory to execute the action in relative to repo root (defaults to .)' + comment-key: + description: 'Optional key to include in the bot comment to allow for mutliple bundle calculations to be posted in separate comments.' + runs: using: 'node12' main: 'index.js' diff --git a/src/index.js b/src/index.js index db19514..e773ba1 100644 --- a/src/index.js +++ b/src/index.js @@ -169,11 +169,13 @@ async function run(octokit, context, token) { issue_number: pull_number }; + const commentKey = getInput('comment-key') + const comment = { ...commentInfo, body: markdownDiff + - '\n\ncompressed-size-action' + `\n\ncompressed-size-action${commentKey ? `::${commentKey}` : ''}` }; if (context.eventName !== 'pull_request' && context.eventName !== 'pull_request_target') { @@ -197,9 +199,10 @@ async function run(octokit, context, token) { let commentId; try { const comments = (await octokit.issues.listComments(commentInfo)).data; + const commentRegExp = new RegExp(`[\s\n]*(compressed|gzip)-size-action${commentKey ? `::${commentKey}` : ''}`) for (let i = comments.length; i--; ) { const c = comments[i]; - if (c.user.type === 'Bot' && /[\s\n]*(compressed|gzip)-size-action/.test(c.body)) { + if (c.user.type === 'Bot' && commentRegExp.test(c.body)) { commentId = c.id; break; } From 3ef50203b54ae6932f62cfa758b1d762c3f58aae Mon Sep 17 00:00:00 2001 From: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com> Date: Wed, 12 Jul 2023 16:40:10 +1000 Subject: [PATCH 2/7] Fix typo Co-authored-by: Bruno Bodian --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 5e513f7..e5848b9 100644 --- a/action.yml +++ b/action.yml @@ -40,7 +40,7 @@ inputs: cwd: description: 'A custom working directory to execute the action in relative to repo root (defaults to .)' comment-key: - description: 'Optional key to include in the bot comment to allow for mutliple bundle calculations to be posted in separate comments.' + description: 'Optional key to include in the bot comment to allow for multiple bundle calculations to be posted in separate comments.' runs: using: 'node12' From d292e11408a70e7f4ae40f652c493c8a6699fef4 Mon Sep 17 00:00:00 2001 From: sarayourfriend Date: Thu, 26 Sep 2024 09:30:43 -0600 Subject: [PATCH 3/7] Prevent mixing up comments with and without keys --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index e773ba1..93d3cdc 100644 --- a/src/index.js +++ b/src/index.js @@ -199,7 +199,7 @@ async function run(octokit, context, token) { let commentId; try { const comments = (await octokit.issues.listComments(commentInfo)).data; - const commentRegExp = new RegExp(`[\s\n]*(compressed|gzip)-size-action${commentKey ? `::${commentKey}` : ''}`) + const commentRegExp = new RegExp(`[\s\n]*(compressed|gzip)-size-action${commentKey ? `::${commentKey}` : ''}`) for (let i = comments.length; i--; ) { const c = comments[i]; if (c.user.type === 'Bot' && commentRegExp.test(c.body)) { From a10cad4e3fc862263ad89b30ef394edcfb066886 Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Thu, 26 Sep 2024 19:06:01 -0500 Subject: [PATCH 4/7] ci: Test `comment-key` option --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 163727d..eb92e43 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,4 +16,11 @@ jobs: uses: ./ with: repo-token: "${{ secrets.GITHUB_TOKEN }}" + comment-key: "key-1" + pattern: index.js + - name: Report Compressed Size 2: Electric Boogaloo + uses: ./ + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" + comment-key: "key-2" pattern: index.js \ No newline at end of file From ac599085f55c1b3f5c8f35f57e6fee3a3a0b1736 Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Thu, 26 Sep 2024 19:10:17 -0500 Subject: [PATCH 5/7] ci: Yaml is cursed --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb92e43..7007650 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: repo-token: "${{ secrets.GITHUB_TOKEN }}" comment-key: "key-1" pattern: index.js - - name: Report Compressed Size 2: Electric Boogaloo + - name: Report Compressed Size 2 uses: ./ with: repo-token: "${{ secrets.GITHUB_TOKEN }}" From fa37dc2afe32d003042b552c01cfdccb3cbb75e0 Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Thu, 26 Sep 2024 19:14:38 -0500 Subject: [PATCH 6/7] ci: Try comparing src size --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7007650..d145951 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,4 +23,4 @@ jobs: with: repo-token: "${{ secrets.GITHUB_TOKEN }}" comment-key: "key-2" - pattern: index.js \ No newline at end of file + pattern: src/index.js \ No newline at end of file From 3268018b05879714209092023b4a6c019d583174 Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Thu, 26 Sep 2024 19:18:18 -0500 Subject: [PATCH 7/7] ci: Hopefully increase reported sizes --- src/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/index.js b/src/index.js index b72a157..2d651eb 100644 --- a/src/index.js +++ b/src/index.js @@ -5,6 +5,8 @@ import { exec } from '@actions/exec'; import SizePlugin from 'size-plugin-core'; import { fileExists, diffTable, toBool, stripHash } from './utils.js'; +// Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + /** * @typedef {ReturnType} Octokit * @typedef {typeof import("@actions/github").context} ActionContext