Files
discordeno/.github/workflows/commentBenchResult.yml
Jonathan Ho 7a1a41fac8 CI: Run benchmark (#2563)
* fix(bench): try to fix benchmark

* style: deno fmt

* fix: remove check formating

* fix: add fake token

* fix: tranform

* deno fmt

* add parseFloat

* fix unit

* refactor: change fetch target to benchrepo

* fix: oldBot

* refactor: use custom input

* ci: add tee

* style: deno fmt

* ci: cache deps

* chore: remove

* ci: add memory benchmark

* fix: fix url for main repo

* deno fmt

* ci: add comment-always

* fix: link

* just trying trigger

* ci: only push on main

* fix: type

* fix: range

* fixed

* style: deno fmt

* fix: path

* Add upload output

* style: deno fmt

* ci: add create branch on pr owner's repo

* fix: github.repository

* ci: fix remove id benchmark-action

* fix

* fix: type

* reverse change

* ci: add cache

* feat: add using cache

* bench: update name and ignore previous when ci

* style: name

* feat: fix pr message style

* add more benchmark

* deno fmt

* fix

* fix: wording

* chore: only run on success

* fix: used last head as current commit
2022-10-29 14:22:23 -05:00

96 lines
3.4 KiB
YAML

name: Comment Benchmark Result
on:
workflow_run:
workflows: [Benchmark]
types:
- completed
jobs:
comment-benchmark-result:
name: Comment Benchmark Result
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v3
- uses: denoland/setup-deno@main
with:
deno-version: v1.x
- name: Download Commit Data Artifact
uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "commitData"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/commitData.zip`, Buffer.from(download.data));
- name: Unzip Commit Data Artifact
run: unzip commitData.zip
- name: Download Result Artifact
uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "benchmarkResults"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/benchmarkResults.zip`, Buffer.from(download.data));
- name: Unzip Result Artifact
run: unzip benchmarkResults.zip
- name: Generate Message
id: genMessage
run: |
MESSAGE=$(deno run -A performance/generateMessage.ts)
echo "MESSAGE<<EOF" >> $GITHUB_ENV
echo "$MESSAGE" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: "Comment on PR"
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const commit_sha = fs.readFileSync('./sha', 'utf-8');
const repo = fs.readFileSync('./repo', 'utf-8');
const pr = await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: commit_sha.slice(0,-1),
owner: repo.split('/')[0],
repo: repo.split('/')[1].slice(0,-1),
});
if (pr.data[0]) {
github.rest.issues.createComment({
issue_number: pr.data[0].number,
owner: repo.split('/')[0],
repo: repo.split('/')[1].slice(0,-1),
body: `${{ env.MESSAGE }}`
})
}