From 4f2e06fecfe42a4d38d4fd8cfa3522783a7f0b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Thu, 6 Jul 2023 17:03:33 +0200 Subject: [PATCH 1/2] Switch to `pull_request_target` event This should hopefully resolve the permission issue. --- .github/workflows/check-binary-size.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-binary-size.yml b/.github/workflows/check-binary-size.yml index c43f117ca..7660905b3 100644 --- a/.github/workflows/check-binary-size.yml +++ b/.github/workflows/check-binary-size.yml @@ -5,7 +5,7 @@ name: Check binary size on: - pull_request: + pull_request_target: branches: - master From a16c5730ac001284177ec3ecb83da32708ff2f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Thu, 6 Jul 2023 17:04:23 +0200 Subject: [PATCH 2/2] Add percent calculation --- .github/workflows/check-binary-size.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check-binary-size.yml b/.github/workflows/check-binary-size.yml index 7660905b3..5104b6d88 100644 --- a/.github/workflows/check-binary-size.yml +++ b/.github/workflows/check-binary-size.yml @@ -69,13 +69,14 @@ jobs: const diff_str = `${plus}${diff}B`; if (diff !== 0) { + const percent = (((updated / reference) - 1) * 100).toFixed(2); // The body is created here and wrapped so "weirdly" to avoid whitespace at the start of the lines, // which is interpreted as a code block by Markdown. const body = `Below is the size of a hello-world Rust program linked with libstd with backtrace. Original binary size: **${reference}B** Updated binary size: **${updated}B** - Difference: **${diff_str}**`; + Difference: **${diff_str}** (${percent}%)`; github.rest.issues.createComment({ issue_number: context.issue.number,