forked from umijs/mako-ecosystem-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (78 loc) · 2.61 KB
/
bench_mako_pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Bench Mako PR
on:
workflow_dispatch:
inputs:
prNumber:
description: "PR number"
required: true
type: string
jobs:
create-comment:
runs-on: ubuntu-latest
outputs:
comment-id: ${{ steps.create-comment.outputs.result }}
steps:
- id: create-comment
uses: actions/github-script@v6
with:
github-token: ${{ secrets.MAKO_BOT_ACCESS_TOKEN }}
result-encoding: string
script: |
const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
const urlLink = `[Open](${url})`
const { data: comment } = await github.rest.issues.createComment({
issue_number: context.payload.inputs.prNumber,
owner: context.repo.owner,
repo: 'mako',
body: `⏳ Triggered benchmark: ${urlLink}`
})
return comment.id
bench:
runs-on: ubuntu-latest
needs: [create-comment]
strategy:
matrix:
shardIndex: [1]
shardTotal: [1]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Init env
uses: ./.github/actions/env
- uses: ./.github/actions/build-mako
with:
path: ${{ env.MAKO_DIR }}
- name: Install hyperfine
run: sudo apt-get update && sudo apt-get install -y hyperfine
- name: Run benchmark
run: node bin/cli.js bench
comment-results:
runs-on: ubuntu-latest
needs: [create-comment, bench]
if: always()
steps:
- name: Read benchmark results
id: read_results
run: |
const fs = require('fs');
const path = '.mako/benchmark-results.md';
const result = fs.readFileSync(path, 'utf8');
echo "::set-output name=benchmark_results::${result}"
- name: Update comment
uses: actions/github-script@v6
with:
github-token: ${{ secrets.MAKO_BOT_ACCESS_TOKEN }}
script: |
const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
const urlLink = `[Open](${url})`
const result = `${{ steps.read_results.outputs.benchmark_results }}`
const body = `
📝 Benchmark detail: ${urlLink}
${result}
`
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: 'mako',
comment_id: `${{ needs.create-comment.outputs.comment-id }}`,
body
})