From ce92aea65105cc8175de71a29f4daaa016e851f0 Mon Sep 17 00:00:00 2001 From: Mathieu Lala Date: Sat, 27 Aug 2022 00:40:34 +0200 Subject: [PATCH 01/15] fix: set create or update comment --- .github/workflows/benchmark.yaml | 59 ++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index a6438df..9001b7b 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -46,25 +46,48 @@ jobs: - name: Run bench against baseline run: cargo bench --bench "*iai*" > iai_feature - - name: Write result in PR - uses: actions/github-script@v5 + - name: Find Comment + uses: peter-evans/find-comment@v2 + id: fc with: - script: | - const fs = require('fs'); + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: Benchmark Result - // read the output file - // const criterion_result = fs.readFileSync("bench_result", {encoding:'utf8', flag:'r'}); - // const iai_baseline = fs.readFileSync("iai_baseline", {encoding:'utf8', flag:'r'}); - const iai_feature = fs.readFileSync("iai_feature", {encoding:'utf8', flag:'r'}); + - id: get-comment-body + run: | + body="Benchmark Result:" + body="```txt\n$(cat iai_feature)\n```" + echo "::set-output name=body::$body" + + - name: Create or update comment + uses: peter-evans/create-or-update-comment@v2 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: ${{ steps.get-comment-body.outputs.body }} + edit-mode: replace - // form message - const quote = "```"; - const message = `👋\n\niai changes:\n ${quote}txt\n${iai_feature}${quote}`; - // post comment - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: message - }) + #- name: Write result in PR + # uses: actions/github-script@v5 + # with: + # script: | + # const fs = require('fs'); +# + # // read the output file + # // const criterion_result = fs.readFileSync("bench_result", {encoding:'utf8', flag:'r'}); + # // const iai_baseline = fs.readFileSync("iai_baseline", {encoding:'utf8', flag:'r'}); + # const iai_feature = fs.readFileSync("iai_feature", {encoding:'utf8', flag:'r'}); +# + # // form message + # const quote = "```"; + # const message = `👋\n\niai changes:\n ${quote}txt\n${iai_feature}${quote}`; +# + # // post comment + # github.rest.issues.createComment({ + # issue_number: context.issue.number, + # owner: context.repo.owner, + # repo: context.repo.repo, + # body: message + # }) From ff69554bec9c5859140e59ea76f43c4385508eb6 Mon Sep 17 00:00:00 2001 From: Mathieu Lala Date: Tue, 30 Aug 2022 18:00:46 +0200 Subject: [PATCH 02/15] fix: bench --- .github/workflows/benchmark.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index 9001b7b..fbad0ba 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -56,8 +56,8 @@ jobs: - id: get-comment-body run: | - body="Benchmark Result:" - body="```txt\n$(cat iai_feature)\n```" + body="$(cat iai_feature)" + body="Benchmark Result:\n```txt\n${body}\n```" echo "::set-output name=body::$body" - name: Create or update comment From c1113d042b144b3af9e5f2aafe737b2ec5a8879d Mon Sep 17 00:00:00 2001 From: Mathieu Lala Date: Tue, 30 Aug 2022 18:13:39 +0200 Subject: [PATCH 03/15] fix: bench --- .github/workflows/benchmark.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index fbad0ba..fd0e9d7 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -56,9 +56,7 @@ jobs: - id: get-comment-body run: | - body="$(cat iai_feature)" - body="Benchmark Result:\n```txt\n${body}\n```" - echo "::set-output name=body::$body" + echo "::set-output name=body::Benchmark Result:\n```txt\n${cat iai_feature}\n``` - name: Create or update comment uses: peter-evans/create-or-update-comment@v2 From 871c8e5ddea8ad3e40dacda19adce11a0f1baab4 Mon Sep 17 00:00:00 2001 From: Mathieu Lala Date: Tue, 30 Aug 2022 18:28:11 +0200 Subject: [PATCH 04/15] fix: bench --- .github/workflows/benchmark.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index fd0e9d7..eeceef7 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -56,7 +56,7 @@ jobs: - id: get-comment-body run: | - echo "::set-output name=body::Benchmark Result:\n```txt\n${cat iai_feature}\n``` + echo "::set-output name=body::Benchmark Result:\n```txt\n${cat iai_feature}\n```" - name: Create or update comment uses: peter-evans/create-or-update-comment@v2 From 1b414565a3865fcebecac333a1996587772b92c4 Mon Sep 17 00:00:00 2001 From: Mathieu Lala Date: Tue, 30 Aug 2022 18:47:34 +0200 Subject: [PATCH 05/15] fix: bench --- .github/workflows/benchmark.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index eeceef7..4e62bcf 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -56,7 +56,7 @@ jobs: - id: get-comment-body run: | - echo "::set-output name=body::Benchmark Result:\n```txt\n${cat iai_feature}\n```" + echo "::set-output name=body::\"Benchmark Result:\n```txt\n${cat iai_feature}\n```\"" - name: Create or update comment uses: peter-evans/create-or-update-comment@v2 From 47e3a41fbc71b41167acafa825994c9d6bd24bc6 Mon Sep 17 00:00:00 2001 From: Mathieu Lala Date: Tue, 30 Aug 2022 19:28:03 +0200 Subject: [PATCH 06/15] fix: bench --- .github/workflows/benchmark.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index 4e62bcf..8c8719b 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -56,7 +56,7 @@ jobs: - id: get-comment-body run: | - echo "::set-output name=body::\"Benchmark Result:\n```txt\n${cat iai_feature}\n```\"" + echo "::set-output name=body::\"Benchmark Result:\n```txt\n$(cat iai_feature)\n```\"" - name: Create or update comment uses: peter-evans/create-or-update-comment@v2 From 9373f851f79da12d54aaab48b1da6479b5deb055 Mon Sep 17 00:00:00 2001 From: Mathieu Lala Date: Tue, 30 Aug 2022 19:54:00 +0200 Subject: [PATCH 07/15] fix: bench --- .github/workflows/benchmark.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index 8c8719b..bbee24d 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -56,7 +56,11 @@ jobs: - id: get-comment-body run: | - echo "::set-output name=body::\"Benchmark Result:\n```txt\n$(cat iai_feature)\n```\"" + body=$(cat iai_feature) + body="Benchmark Result:\n```txt\n${body}\n```" + body="${body//$'\n'/'%0A'}" + body="${body//'%'/'%25'}" + echo "::set-output name=body::$body" - name: Create or update comment uses: peter-evans/create-or-update-comment@v2 From 75a9f7b58edfc3c48d1ba0ff47a591cc65142ba8 Mon Sep 17 00:00:00 2001 From: Mathieu Lala Date: Tue, 30 Aug 2022 20:08:37 +0200 Subject: [PATCH 08/15] fix: bench --- .github/workflows/benchmark.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index bbee24d..e0c26eb 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -57,7 +57,7 @@ jobs: - id: get-comment-body run: | body=$(cat iai_feature) - body="Benchmark Result:\n```txt\n${body}\n```" + body="Benchmark Result:```txt\n/${body}/```" body="${body//$'\n'/'%0A'}" body="${body//'%'/'%25'}" echo "::set-output name=body::$body" From 512497d8637d6fdfffa22e37c3175a519b9b5bcd Mon Sep 17 00:00:00 2001 From: Mathieu Lala Date: Tue, 30 Aug 2022 20:43:37 +0200 Subject: [PATCH 09/15] fix: bench --- .github/workflows/benchmark.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index e0c26eb..987b3fb 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -57,7 +57,7 @@ jobs: - id: get-comment-body run: | body=$(cat iai_feature) - body="Benchmark Result:```txt\n/${body}/```" + body = ${{ format('{0}/{1}.{2}', "Benchmark Result:```txt\n", $body, "\n```") }} body="${body//$'\n'/'%0A'}" body="${body//'%'/'%25'}" echo "::set-output name=body::$body" From 7fc5faaa7ae280f8e040d19c6cc2a683cfbb0271 Mon Sep 17 00:00:00 2001 From: Mathieu Lala Date: Tue, 30 Aug 2022 20:46:34 +0200 Subject: [PATCH 10/15] fix: bench --- .github/workflows/benchmark.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index 987b3fb..411f979 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -57,7 +57,7 @@ jobs: - id: get-comment-body run: | body=$(cat iai_feature) - body = ${{ format('{0}/{1}.{2}', "Benchmark Result:```txt\n", $body, "\n```") }} + body = ${{ format('{0}/{1}.{2}', 'Benchmark Result:```txt\n', $body, '\n```'') }} body="${body//$'\n'/'%0A'}" body="${body//'%'/'%25'}" echo "::set-output name=body::$body" From 3d15eae806abf33ad8f6c08b93221fe34fc46b17 Mon Sep 17 00:00:00 2001 From: Mathieu Lala Date: Tue, 30 Aug 2022 20:48:05 +0200 Subject: [PATCH 11/15] fix: bench --- .github/workflows/benchmark.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index 411f979..0d95e12 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -57,7 +57,7 @@ jobs: - id: get-comment-body run: | body=$(cat iai_feature) - body = ${{ format('{0}/{1}.{2}', 'Benchmark Result:```txt\n', $body, '\n```'') }} + body = ${{ format('Benchmark Result:```txt\n{0}```\n', $body) }} body="${body//$'\n'/'%0A'}" body="${body//'%'/'%25'}" echo "::set-output name=body::$body" From 150f57c66c064c68a0f92cd3806c493dfd2c6fac Mon Sep 17 00:00:00 2001 From: Mathieu Lala Date: Tue, 30 Aug 2022 20:48:53 +0200 Subject: [PATCH 12/15] fix: bench --- .github/workflows/benchmark.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index 0d95e12..0979f44 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -57,7 +57,7 @@ jobs: - id: get-comment-body run: | body=$(cat iai_feature) - body = ${{ format('Benchmark Result:```txt\n{0}```\n', $body) }} + body = ${{ format('Benchmark Result:\`\`\`txt\n{0}\`\`\`\n', $body) }} body="${body//$'\n'/'%0A'}" body="${body//'%'/'%25'}" echo "::set-output name=body::$body" From 90d7f0a11c86190b606648af287b569f62b77c9a Mon Sep 17 00:00:00 2001 From: Mathieu Lala Date: Tue, 30 Aug 2022 20:49:28 +0200 Subject: [PATCH 13/15] fix: bench --- .github/workflows/benchmark.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index 0979f44..b8cc5be 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -56,8 +56,7 @@ jobs: - id: get-comment-body run: | - body=$(cat iai_feature) - body = ${{ format('Benchmark Result:\`\`\`txt\n{0}\`\`\`\n', $body) }} + body = ${{ format('Benchmark Result:\`\`\`txt\n{0}\`\`\`\n', $(cat iai_feature)) }} body="${body//$'\n'/'%0A'}" body="${body//'%'/'%25'}" echo "::set-output name=body::$body" From 7efeabc2d16b1464d290a618fc3ee12cae28efb5 Mon Sep 17 00:00:00 2001 From: Mathieu Lala Date: Tue, 30 Aug 2022 20:52:25 +0200 Subject: [PATCH 14/15] fix: bench --- .github/workflows/benchmark.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index b8cc5be..fa4e677 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -56,7 +56,7 @@ jobs: - id: get-comment-body run: | - body = ${{ format('Benchmark Result:\`\`\`txt\n{0}\`\`\`\n', $(cat iai_feature)) }} + body = "Benchmark Result:```txt\n${$(cat iai_feature)}```\n" body="${body//$'\n'/'%0A'}" body="${body//'%'/'%25'}" echo "::set-output name=body::$body" From 2f0be85eb5a5aa35fa7f1e5c306bda8bbcba7650 Mon Sep 17 00:00:00 2001 From: Mathieu Lala Date: Tue, 30 Aug 2022 21:14:45 +0200 Subject: [PATCH 15/15] fix: bench --- .github/workflows/benchmark.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index fa4e677..67acb51 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -56,9 +56,13 @@ jobs: - id: get-comment-body run: | - body = "Benchmark Result:```txt\n${$(cat iai_feature)}```\n" + content=$(cat iai_feature) + echo $content + body="Benchmark Result:```txt\n${content}```\n" + echo $body body="${body//$'\n'/'%0A'}" body="${body//'%'/'%25'}" + echo $body echo "::set-output name=body::$body" - name: Create or update comment