diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index a6438df..67acb51 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -46,25 +46,53 @@ 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: | + 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 + 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 + # })