feat: add frontier evm #27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original source: https://github.com/AcalaNetwork/Acala/blob/master/.github/workflows/benchmark.yml | |
name: Benchmark | |
on: | |
issue_comment: | |
types: [created] | |
permissions: | |
pull-requests: write | |
contents: write | |
jobs: | |
benchmark: | |
name: Benchmark | |
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '/run_benchmarks') }} | |
runs-on: [self-hosted, linux] | |
steps: | |
- uses: actions/github-script@v6 | |
name: Get PR branch | |
id: issue | |
with: | |
script: | | |
const pr = context.payload.issue.number | |
const data = await github.rest.pulls.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: pr | |
}) | |
return { | |
ref: data.data.head.ref, | |
sha: data.data.head.sha, | |
} | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
ref: ${{ fromJson(steps.issue.outputs.result).sha }} | |
- uses: actions/github-script@v6 | |
name: Prepare command | |
id: command | |
with: | |
result-encoding: string | |
script: | | |
const [, , cmd, ...args] = context.payload.comment.body.split(/\W+/) | |
const [runtime, pallet] = args | |
return `bash ./scripts/benchmark.sh -r ${runtime ?? "*"} -p ${pallet ?? "*"}` | |
- uses: actions/github-script@v6 | |
name: Post comment | |
id: comment | |
with: | |
script: | | |
const data = await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: ` | |
**Request**: \`${context.payload.comment.body}\` | |
**Command**: \`${{steps.command.outputs.result}}\` | |
Running... | |
` | |
}) | |
return data.data.id | |
- name: Set variables | |
run: | | |
echo "TOOLCHAIN=$(rustup show active-toolchain | cut -d " " -f1)" >> $GITHUB_ENV | |
- name: Install toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.TOOLCHAIN }} | |
components: rustfmt | |
target: wasm32-unknown-unknown | |
- name: Run benchmarks | |
run: ${{steps.command.outputs.result}} > ${{runner.temp}}/out.txt | |
- name: Commit new weights | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: Automated weights | |
- uses: actions/github-script@v6 | |
name: Update comment | |
with: | |
script: | | |
const fs = require('fs') | |
const id = `${{steps.comment.outputs.result}}` | |
const body = fs.readFileSync('${{runner.temp}}/out.txt').toString() | |
github.rest.issues.updateComment({ | |
comment_id: id, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: ` | |
**Request**: \`${context.payload.comment.body}\` | |
**Command**: \`${{steps.command.outputs.result}}\` | |
<details> | |
<summary>Results</summary> | |
\`\`\` | |
${body.trim()} | |
\`\`\` | |
</details> | |
` | |
}) |