-
-
Notifications
You must be signed in to change notification settings - Fork 8
85 lines (82 loc) · 2.8 KB
/
pull-request-from-pr.yml
File metadata and controls
85 lines (82 loc) · 2.8 KB
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
name: Pull Request Triggered by Comment
on:
workflow_dispatch:
inputs:
pull_number:
description: Pull Request number to run benchmark (e.g. 12512)
required: true
type: string
repeats:
description: number of benchmark repeats
required: true
type: string
default: '50'
jobs:
init:
runs-on: ubuntu-latest
outputs:
comment-id: ${{ steps.create-comment.outputs.result }}
steps:
- id: generate-token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.PR_GITHUB_APP_ID }}
private_key: ${{ secrets.PR_GITHUB_APP_PRIVATE_KEY }}
repository: '${{ github.repository_owner }}/vite'
- id: create-comment
uses: actions/github-script@v6
with:
github-token: ${{ steps.generate-token.outputs.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: Number(context.payload.inputs.pull_number),
owner: context.repo.owner,
repo: 'vite',
body: `⏳ Triggered benchmark: ${urlLink}`
})
return comment.id
run-benchmark:
name: Run benchmark
outputs:
summary: ${{ steps.run_benchmark.outputs.summary }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Install dependencies
run: cd runner && pnpm install
- name: Run benchmark
id: run_benchmark
run: cd runner && pnpm tsx src/cli.ts bench --pull-number="${{ inputs.pull_number }}" --repeats="${{ inputs.repeats }}"
update-comment:
runs-on: ubuntu-latest
needs: [init, run-benchmark]
if: always()
steps:
- id: generate-token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.PR_GITHUB_APP_ID }}
private_key: ${{ secrets.PR_GITHUB_APP_PRIVATE_KEY }}
repository: '${{ github.repository_owner }}/vite'
- uses: actions/github-script@v6
with:
github-token: ${{ steps.generate-token.outputs.token }}
script: |
const summary = `${{ needs.run-benchmark.outputs.summary }}`
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: 'vite',
comment_id: ${{ needs.init.outputs.comment-id }},
body: summary
})