From 4ff91193aef68756c613c7c3a753229af27bf8e8 Mon Sep 17 00:00:00 2001 From: droak Date: Tue, 10 Sep 2024 15:30:32 +0900 Subject: [PATCH 01/30] add ci benchmark --- .github/workflows/benchmark.yml | 40 +++++++++++++++++++ .../{tests => bench}/causallyrelated.bench.ts | 0 2 files changed, 40 insertions(+) create mode 100644 .github/workflows/benchmark.yml rename packages/object/{tests => bench}/causallyrelated.bench.ts (100%) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 00000000..ddaf2fdb --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,40 @@ +name: Benchmark +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + benchmark: + name: Performance regression check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + with: + version: 9 + - name: Run benchmark + run: pnpm run bench --outputJson benchmark.json + - name: Download previous benchmark data + uses: actions/cache@v4 + with: + path: ./cache + key: benchmark + - name: Store benchmark result + uses: benchmark-action/github-action-benchmark@v1 + with: + tool: 'customSmallerIsBetter' + output-file-path: benchmark.json + external-data-json-path: ./cache/benchmark-main.json + fail-on-alert: true + - shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: branch + - name: Store benchmark data + if: steps.branch.outputs.branch == 'main' + run: cp benchmark.json ./cache/benchmark-main.json + + # Push gh-pages branch by yourself + # - name: Push benchmark result + # run: git push 'https://you:${{ secrets.GITHUB_TOKEN }}@github.com/you/repo-name.git' gh-pages:gh-pages diff --git a/packages/object/tests/causallyrelated.bench.ts b/packages/object/bench/causallyrelated.bench.ts similarity index 100% rename from packages/object/tests/causallyrelated.bench.ts rename to packages/object/bench/causallyrelated.bench.ts From 629da6de5466c1148ceb0ac87618f3a1f3b57488 Mon Sep 17 00:00:00 2001 From: droak Date: Tue, 10 Sep 2024 15:31:57 +0900 Subject: [PATCH 02/30] install deps --- .github/workflows/benchmark.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index ddaf2fdb..85f59ae5 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -15,7 +15,9 @@ jobs: with: version: 9 - name: Run benchmark - run: pnpm run bench --outputJson benchmark.json + run: | + pnpm install + pnpm run bench --outputJson benchmark.json - name: Download previous benchmark data uses: actions/cache@v4 with: From 9c35a16fd6459325a75532e64dec45156a39a1b8 Mon Sep 17 00:00:00 2001 From: droak Date: Tue, 10 Sep 2024 15:36:01 +0900 Subject: [PATCH 03/30] build node --- .github/workflows/benchmark.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 85f59ae5..59eebc1b 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -17,6 +17,9 @@ jobs: - name: Run benchmark run: | pnpm install + cd packages/node + pnpm build + cd ../.. pnpm run bench --outputJson benchmark.json - name: Download previous benchmark data uses: actions/cache@v4 From fee7a91c4ae905a0c413c0c50271329d71fb049c Mon Sep 17 00:00:00 2001 From: droak Date: Tue, 10 Sep 2024 16:04:10 +0900 Subject: [PATCH 04/30] run everything with vitest --- .github/workflows/benchmark.yml | 32 ++++++++++++-------------------- package.json | 2 +- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 59eebc1b..a4734d25 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -14,32 +14,24 @@ jobs: - uses: pnpm/action-setup@v4 with: version: 9 + - name: Download previous benchmark data + uses: actions/cache@v4 + with: + path: ./cache + key: benchmark - name: Run benchmark run: | pnpm install cd packages/node pnpm build cd ../.. - pnpm run bench --outputJson benchmark.json - - name: Download previous benchmark data - uses: actions/cache@v4 - with: - path: ./cache - key: benchmark - - name: Store benchmark result - uses: benchmark-action/github-action-benchmark@v1 - with: - tool: 'customSmallerIsBetter' - output-file-path: benchmark.json - external-data-json-path: ./cache/benchmark-main.json - fail-on-alert: true - - shell: bash - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + pnpm run bench --outputJson benchmark.json --compare + - name: Benchmark result + run: | + pnpm run bench --compare ./cache/benchmark-main.json > output.txt + cat output.txt + - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT id: branch - - name: Store benchmark data + - name: Store benchmark dataq if: steps.branch.outputs.branch == 'main' run: cp benchmark.json ./cache/benchmark-main.json - - # Push gh-pages branch by yourself - # - name: Push benchmark result - # run: git push 'https://you:${{ secrets.GITHUB_TOKEN }}@github.com/you/repo-name.git' gh-pages:gh-pages diff --git a/package.json b/package.json index 0348bbb6..f992f922 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "docs": "typedoc", "proto-gen": "buf generate", "release": "release-it", - "test": "vitest", + "test": "vitest run", "bench": "vitest bench" }, "devDependencies": { From c8aed7a8b403b41aa21bfb931735fea7bf8729b2 Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 02:26:36 +0900 Subject: [PATCH 05/30] check for prev benchmarks --- .github/workflows/benchmark.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index a4734d25..d3a5cf89 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -25,7 +25,11 @@ jobs: cd packages/node pnpm build cd ../.. - pnpm run bench --outputJson benchmark.json --compare + if [ -f ./cache/benchmark-main.json ]; then + pnpm run bench --outputJson benchmark.json --compare ./cache/benchmark-main.json + else + pnpm run bench --outputJson benchmark.json + fi - name: Benchmark result run: | pnpm run bench --compare ./cache/benchmark-main.json > output.txt From c48b6cb16c30dc80bb7551981c3d13c639f08e35 Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 02:30:12 +0900 Subject: [PATCH 06/30] add comment in the pr --- .github/workflows/benchmark.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index d3a5cf89..99a5f51c 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -19,21 +19,28 @@ jobs: with: path: ./cache key: benchmark - - name: Run benchmark + - name: Build run: | pnpm install cd packages/node pnpm build - cd ../.. + - name: Benchmark result + run: | if [ -f ./cache/benchmark-main.json ]; then - pnpm run bench --outputJson benchmark.json --compare ./cache/benchmark-main.json + pnpm run bench --outputJson benchmark.json --compare ./cache/benchmark-main.json > output.txt else - pnpm run bench --outputJson benchmark.json + pnpm run bench --outputJson benchmark.json > output.txt fi - - name: Benchmark result - run: | - pnpm run bench --compare ./cache/benchmark-main.json > output.txt cat output.txt + - uses: actions/github-script@v6 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: fs.readFileSync('output.txt', 'utf-8') + }) - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT id: branch - name: Store benchmark dataq From d62762e1aa722d030e835d670a7e3f00c8508169 Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 02:35:02 +0900 Subject: [PATCH 07/30] fix outputting --- .github/workflows/benchmark.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 99a5f51c..7a6e48c1 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -25,21 +25,23 @@ jobs: cd packages/node pnpm build - name: Benchmark result + id: benchmark-result run: | if [ -f ./cache/benchmark-main.json ]; then - pnpm run bench --outputJson benchmark.json --compare ./cache/benchmark-main.json > output.txt + pnpm run bench --outputJson benchmark.json --compare ./cache/benchmark-main.json else - pnpm run bench --outputJson benchmark.json > output.txt + pnpm run bench --outputJson benchmark.json fi - cat output.txt + cat benchmark.json >> $GITHUB_OUTPUT - uses: actions/github-script@v6 with: + github-token: ${{ github.token }} script: | github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: fs.readFileSync('output.txt', 'utf-8') + body: {{ steps.benchmark-result.outputs.stdout | toJSON }}} }) - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT id: branch From 792cba123090c1f7dcf0e0f792d6e86276fe3098 Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 02:37:45 +0900 Subject: [PATCH 08/30] quotes fixing --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 7a6e48c1..d96d5de3 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -41,7 +41,7 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: {{ steps.benchmark-result.outputs.stdout | toJSON }}} + body: '${{ steps.benchmark-result.outputs.stdout }}' }) - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT id: branch From 78b8f3106dfd335d6943fb2866bad792a20cad89 Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 02:39:40 +0900 Subject: [PATCH 09/30] handle multiline --- .github/workflows/benchmark.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index d96d5de3..5a36a905 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -32,7 +32,10 @@ jobs: else pnpm run bench --outputJson benchmark.json fi + EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) + echo "text<<$EOF" >> $GITHUB_OUTPUT cat benchmark.json >> $GITHUB_OUTPUT + echo "$EOF" >> $GITHUB_OUTPUT - uses: actions/github-script@v6 with: github-token: ${{ github.token }} From e6a062179ec10507153a4f3bf9ba927a1342b41a Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 02:41:13 +0900 Subject: [PATCH 10/30] use simple eof --- .github/workflows/benchmark.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 5a36a905..402e9cc8 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -32,10 +32,9 @@ jobs: else pnpm run bench --outputJson benchmark.json fi - EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) - echo "text<<$EOF" >> $GITHUB_OUTPUT + echo "var<> $GITHUB_OUTPUT cat benchmark.json >> $GITHUB_OUTPUT - echo "$EOF" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT - uses: actions/github-script@v6 with: github-token: ${{ github.token }} From 47bf2e9e289a30d296dc58c7a2980c5ce2274b68 Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 02:46:05 +0900 Subject: [PATCH 11/30] pass as a env --- .github/workflows/benchmark.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 402e9cc8..6d138a41 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -32,18 +32,20 @@ jobs: else pnpm run bench --outputJson benchmark.json fi - echo "var<> $GITHUB_OUTPUT + echo 'BENCHMARK_RESULT<> $GITHUB_OUTPUT cat benchmark.json >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT - uses: actions/github-script@v6 with: github-token: ${{ github.token }} + env: + BENCHMARK_RESULT: ${{ steps.benchmark-result.outputs.BENCHMARK_RESULT }} script: | github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: '${{ steps.benchmark-result.outputs.stdout }}' + body: process.env.BENCHMARK_RESULT }) - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT id: branch From 48afdbd1596fa0e8c6ff8d596bfe1ab35d7355ef Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 02:48:50 +0900 Subject: [PATCH 12/30] add breaking line --- .github/workflows/benchmark.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 6d138a41..401e754f 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -34,18 +34,16 @@ jobs: fi echo 'BENCHMARK_RESULT<> $GITHUB_OUTPUT cat benchmark.json >> $GITHUB_OUTPUT - echo 'EOF' >> $GITHUB_OUTPUT + echo '\nEOF' >> $GITHUB_OUTPUT - uses: actions/github-script@v6 with: github-token: ${{ github.token }} - env: - BENCHMARK_RESULT: ${{ steps.benchmark-result.outputs.BENCHMARK_RESULT }} script: | github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: process.env.BENCHMARK_RESULT + body: '${{ steps.benchmark-result.outputs.BENCHMARK_RESULT }}' }) - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT id: branch From 4dacfcb8f44876cb704ca8c253026c128e21f567 Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 02:50:55 +0900 Subject: [PATCH 13/30] add new line with sed --- .github/workflows/benchmark.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 401e754f..1f2c3dd8 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -33,8 +33,9 @@ jobs: pnpm run bench --outputJson benchmark.json fi echo 'BENCHMARK_RESULT<> $GITHUB_OUTPUT + sed -i -e '$a\' benchmark.json cat benchmark.json >> $GITHUB_OUTPUT - echo '\nEOF' >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT - uses: actions/github-script@v6 with: github-token: ${{ github.token }} From a20e857f57a7efc64f6b715afe3c19ce721d0aca Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 02:53:01 +0900 Subject: [PATCH 14/30] rm token --- .github/workflows/benchmark.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 1f2c3dd8..ed2bc6bf 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -28,17 +28,16 @@ jobs: id: benchmark-result run: | if [ -f ./cache/benchmark-main.json ]; then - pnpm run bench --outputJson benchmark.json --compare ./cache/benchmark-main.json + pnpm run bench --outputJson benchmark.json --compare ./cache/benchmark-main.json > benchmark.txt else - pnpm run bench --outputJson benchmark.json + pnpm run bench --outputJson benchmark.json > benchmark.txt fi echo 'BENCHMARK_RESULT<> $GITHUB_OUTPUT - sed -i -e '$a\' benchmark.json - cat benchmark.json >> $GITHUB_OUTPUT + sed -i -e '$a\' benchmark.txt + cat benchmark.txt >> $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT - uses: actions/github-script@v6 with: - github-token: ${{ github.token }} script: | github.rest.issues.createComment({ issue_number: context.issue.number, From 8da8be4063a206fca2bb71b529eb6ffea305ed2e Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 02:56:18 +0900 Subject: [PATCH 15/30] escape quotes --- .github/workflows/benchmark.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index ed2bc6bf..fd4ec7a8 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -37,13 +37,15 @@ jobs: cat benchmark.txt >> $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT - uses: actions/github-script@v6 + env: + BENCHMARK_RESULT: ${{ steps.benchmark-result.outputs.BENCHMARK_RESULT }} with: script: | github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: '${{ steps.benchmark-result.outputs.BENCHMARK_RESULT }}' + body: process.env.BENCHMARK_RESULT }) - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT id: branch From 7c95e9fc2036f8eac903b09e46b5d7c34f0625b5 Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 02:58:39 +0900 Subject: [PATCH 16/30] add gh token --- .github/workflows/benchmark.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index fd4ec7a8..cf392693 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -40,6 +40,7 @@ jobs: env: BENCHMARK_RESULT: ${{ steps.benchmark-result.outputs.BENCHMARK_RESULT }} with: + github-token: ${{secrets.GITHUB_TOKEN}} script: | github.rest.issues.createComment({ issue_number: context.issue.number, From a0574da95b215af8f99d1bfcc78f43db4223adbc Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 03:01:46 +0900 Subject: [PATCH 17/30] permissions --- .github/workflows/benchmark.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index cf392693..31e59fac 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -9,6 +9,8 @@ jobs: benchmark: name: Performance regression check runs-on: ubuntu-latest + permissions: + id-token: write steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 From 5a0c1548e5e8974499d3084f466952394b2b311e Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 03:05:11 +0900 Subject: [PATCH 18/30] write pr perm --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 31e59fac..4952dc65 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -10,7 +10,7 @@ jobs: name: Performance regression check runs-on: ubuntu-latest permissions: - id-token: write + pull-requests: write steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 From 23d15dfd3250f67cc69fe462689de057a57ad5e1 Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 03:10:32 +0900 Subject: [PATCH 19/30] try to decode to utf8 --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 4952dc65..61c0d689 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -40,7 +40,7 @@ jobs: echo 'EOF' >> $GITHUB_OUTPUT - uses: actions/github-script@v6 env: - BENCHMARK_RESULT: ${{ steps.benchmark-result.outputs.BENCHMARK_RESULT }} + BENCHMARK_RESULT: ${{ steps.benchmark-result.outputs.BENCHMARK_RESULT | utf8 }} with: github-token: ${{secrets.GITHUB_TOKEN}} script: | From d8da3d7c13c15485452604ae8b99cb0e8bb4dc6a Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 03:14:05 +0900 Subject: [PATCH 20/30] go again with the prev output --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 61c0d689..51ccaddd 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -48,7 +48,7 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: process.env.BENCHMARK_RESULT + body: `${{ steps.benchmark-result.outputs.BENCHMARK_RESULT }}` }) - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT id: branch From 67c080672fd6d55525ef11d9c929d16a8d03b00c Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 03:15:01 +0900 Subject: [PATCH 21/30] put it in a code block --- .github/workflows/benchmark.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 51ccaddd..bcf02d78 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -39,8 +39,6 @@ jobs: cat benchmark.txt >> $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT - uses: actions/github-script@v6 - env: - BENCHMARK_RESULT: ${{ steps.benchmark-result.outputs.BENCHMARK_RESULT | utf8 }} with: github-token: ${{secrets.GITHUB_TOKEN}} script: | @@ -48,7 +46,7 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: `${{ steps.benchmark-result.outputs.BENCHMARK_RESULT }}` + body: "```${{ steps.benchmark-result.outputs.BENCHMARK_RESULT }}```" }) - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT id: branch From 482f2553af995fa2a29625690faefd351bcbc814 Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 03:17:14 +0900 Subject: [PATCH 22/30] code block with env var --- .github/workflows/benchmark.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index bcf02d78..71af3eb7 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -39,6 +39,8 @@ jobs: cat benchmark.txt >> $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT - uses: actions/github-script@v6 + env: + BENCHMARK_RESULT: ${{ steps.benchmark-result.outputs.BENCHMARK_RESULT | utf8 }} with: github-token: ${{secrets.GITHUB_TOKEN}} script: | @@ -46,7 +48,7 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: "```${{ steps.benchmark-result.outputs.BENCHMARK_RESULT }}```" + body: "\n\`\`\`\n${process.env.BENCHMARK_RESULT}\n\`\`\`" }) - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT id: branch From 2dc4adee11c85f327cc1bf10c07ebee4df3c1256 Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 03:18:27 +0900 Subject: [PATCH 23/30] remove invalid syntax --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 71af3eb7..7096a8bf 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -40,7 +40,7 @@ jobs: echo 'EOF' >> $GITHUB_OUTPUT - uses: actions/github-script@v6 env: - BENCHMARK_RESULT: ${{ steps.benchmark-result.outputs.BENCHMARK_RESULT | utf8 }} + BENCHMARK_RESULT: ${{ steps.benchmark-result.outputs.BENCHMARK_RESULT }} with: github-token: ${{secrets.GITHUB_TOKEN}} script: | From be87cc6770daf39dc44309dce7bd8dbbf23bf392 Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 03:21:06 +0900 Subject: [PATCH 24/30] double { --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 7096a8bf..bc2835c7 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -48,7 +48,7 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: "\n\`\`\`\n${process.env.BENCHMARK_RESULT}\n\`\`\`" + body: "\n\`\`\`\n${{process.env.BENCHMARK_RESULT}}\n\`\`\`" }) - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT id: branch From bd124e32e88f4513a76e05b6625d219c40b0a544 Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 03:22:55 +0900 Subject: [PATCH 25/30] outputs instead env --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index bc2835c7..f472f10d 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -48,7 +48,7 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: "\n\`\`\`\n${{process.env.BENCHMARK_RESULT}}\n\`\`\`" + body: "\`\`\`\n${{steps.benchmark-result.outputs.BENCHMARK_RESULT}}\n\`\`\`" }) - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT id: branch From 45e8f9a56985aa5b34c436861bddbf8700239eda Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 03:34:49 +0900 Subject: [PATCH 26/30] remove process --- .github/workflows/benchmark.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index f472f10d..37d16b6c 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -30,9 +30,9 @@ jobs: id: benchmark-result run: | if [ -f ./cache/benchmark-main.json ]; then - pnpm run bench --outputJson benchmark.json --compare ./cache/benchmark-main.json > benchmark.txt + pnpm run bench --run --outputJson benchmark.json --compare ./cache/benchmark-main.json > benchmark.txt else - pnpm run bench --outputJson benchmark.json > benchmark.txt + pnpm run bench --run --outputJson benchmark.json > benchmark.txt fi echo 'BENCHMARK_RESULT<> $GITHUB_OUTPUT sed -i -e '$a\' benchmark.txt @@ -48,7 +48,7 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: "\`\`\`\n${{steps.benchmark-result.outputs.BENCHMARK_RESULT}}\n\`\`\`" + body: "\n\`\`\`\n${{ env.BENCHMARK_RESULT }}\n\`\`\`" }) - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT id: branch From 287dc1672d469f6bcb509b53b733bc5cadb61bae Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 03:37:49 +0900 Subject: [PATCH 27/30] output it as a step summary instead --- .github/workflows/benchmark.yml | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 37d16b6c..b44d298d 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -34,22 +34,7 @@ jobs: else pnpm run bench --run --outputJson benchmark.json > benchmark.txt fi - echo 'BENCHMARK_RESULT<> $GITHUB_OUTPUT - sed -i -e '$a\' benchmark.txt - cat benchmark.txt >> $GITHUB_OUTPUT - echo 'EOF' >> $GITHUB_OUTPUT - - uses: actions/github-script@v6 - env: - BENCHMARK_RESULT: ${{ steps.benchmark-result.outputs.BENCHMARK_RESULT }} - with: - github-token: ${{secrets.GITHUB_TOKEN}} - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: "\n\`\`\`\n${{ env.BENCHMARK_RESULT }}\n\`\`\`" - }) + cat benchmark.txt >> $GITHUB_STEP_SUMMARY - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT id: branch - name: Store benchmark dataq From c0fff522f230eec2ebf5af66644093f53b8acb13 Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 03:40:06 +0900 Subject: [PATCH 28/30] rm color symbols --- .github/workflows/benchmark.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index b44d298d..cbb7acf2 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -34,7 +34,24 @@ jobs: else pnpm run bench --run --outputJson benchmark.json > benchmark.txt fi + echo 'BENCHMARK_RESULT<> $GITHUB_OUTPUT + sed -i -e '$a\' benchmark.txt + sed -e 's/\x1b\[[0-9;]*m//g' + cat benchmark.txt >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT cat benchmark.txt >> $GITHUB_STEP_SUMMARY + - uses: actions/github-script@v6 + env: + BENCHMARK_RESULT: ${{ steps.benchmark-result.outputs.BENCHMARK_RESULT }} + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: process.env.BENCHMARK_RESULT + }) - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT id: branch - name: Store benchmark dataq From 388e18fbfbeb0b55ab8249f1071b923fb25f77f0 Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 03:42:04 +0900 Subject: [PATCH 29/30] pass file --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index cbb7acf2..84fbb975 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -36,7 +36,7 @@ jobs: fi echo 'BENCHMARK_RESULT<> $GITHUB_OUTPUT sed -i -e '$a\' benchmark.txt - sed -e 's/\x1b\[[0-9;]*m//g' + sed -i -e 's/\x1b\[[0-9;]*m//g' benchmark.txt cat benchmark.txt >> $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT cat benchmark.txt >> $GITHUB_STEP_SUMMARY From 8bacb16c2a96891295264bb3666c7488882d9657 Mon Sep 17 00:00:00 2001 From: droak Date: Wed, 11 Sep 2024 03:44:59 +0900 Subject: [PATCH 30/30] use iconv to go from ansi to utf --- .github/workflows/benchmark.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 84fbb975..f7caf89d 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -32,11 +32,11 @@ jobs: if [ -f ./cache/benchmark-main.json ]; then pnpm run bench --run --outputJson benchmark.json --compare ./cache/benchmark-main.json > benchmark.txt else - pnpm run bench --run --outputJson benchmark.json > benchmark.txt + pnpm run bench --run --outputJson benchmark.json > benchmark-tmp.txt fi + iconv -f "windows-1252" -t "UTF-8" benchmark-tmp.txt -o benchmark.txt echo 'BENCHMARK_RESULT<> $GITHUB_OUTPUT sed -i -e '$a\' benchmark.txt - sed -i -e 's/\x1b\[[0-9;]*m//g' benchmark.txt cat benchmark.txt >> $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT cat benchmark.txt >> $GITHUB_STEP_SUMMARY