-
Notifications
You must be signed in to change notification settings - Fork 20
162 lines (134 loc) · 4.5 KB
/
watch_bench.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: 'Watch Benchmarks'
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'bench/**'
permissions:
issues: write
jobs:
changes:
runs-on: ubuntu-latest
outputs:
files: ${{ steps.changes.outputs.benchmarks_files }}
changes: ${{ steps.changes.outputs.benchmarks }}
steps:
- uses: actions/checkout@v3
- name: 'Detect File Changes'
uses: dorny/paths-filter@v2
id: changes
with:
list-files: json
base: ${{ github.ref }}
working-directory: bench
filters: |
benchmarks:
- added|modified: 'bench/*.js'
benchmark:
needs: changes
if: needs.changes.outputs.files != '[]'
strategy:
fail-fast: true
matrix:
# Parse JSON array containing names of all filters matching any of changed files
# e.g. ['add-property.js', 'array-append.js'] if both bench files contains changes
bench-file: ${{ fromJSON(needs.changes.outputs.files) }}
node-version: [18.0.0, 18.18.0, 18.19.0, 20.0.0, 20.10.0, 20.11.1, 21.0.0, 21.6.0, 21.7.1]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js v${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: NPM Install
run: npm install
- name: Correct Bench file
run: |-
export SAFE_BENCH_FILE=$(basename ${{ matrix.bench-file }})
echo "BENCH_FILE=$SAFE_BENCH_FILE" >> "$GITHUB_ENV"
- name: Report Filename
run: echo "BENCH_REPORT_FILE=report-${{github.run_id}}-${{ matrix.node-version }}-${{ env.BENCH_FILE }}.md" >> $GITHUB_ENV
- name: Run Benchmark
run: node bench/${{ env.BENCH_FILE }} > ./${{ env.BENCH_REPORT_FILE }}
env:
CI: true
- name: Notify on Error
if: ${{ failure() }}
uses: dacbd/create-issue-action@main
with:
token: ${{ github.token }}
title: Benchmark ${{ env.BENCH_FILE }} failed on v${{ matrix.node-version }}
body: |
### Context
[Failed Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
[Codebase](https://github.com/${{ github.repository }}/tree/${{ github.sha }})
Workflow name - `${{ github.workflow }}`
Job - `${{ github.job }}`
status - `${{ job.status }}`
assignees: RafaelGSS
labels: bug
- name: Add Job Summary
run: |
result=$(cat ./${{ env.BENCH_REPORT_FILE }})
echo "$result" >> $GITHUB_STEP_SUMMARY
- name: Upload Bench Result
uses: actions/upload-artifact@v3
with:
name: benchmark-artifacts-${{github.run_id}}
retention-days: 1
if-no-files-found: error
path: ./${{ env.BENCH_REPORT_FILE }}
## Write for matrix outputs workaround
- uses: cloudposse/github-action-matrix-outputs-write@main
id: out
with:
matrix-step-name: benchmark
matrix-key: ${{ env.BENCH_FILE }}:${{ matrix.node-version }}
outputs: |-
result: ${{ env.BENCH_REPORT_FILE }}
## Read matrix outputs
read:
runs-on: ubuntu-latest
needs: [benchmark]
steps:
- uses: cloudposse/github-action-matrix-outputs-read@main
id: read
with:
matrix-step-name: benchmark
outputs:
result: '${{ steps.read.outputs.result }}'
commit:
runs-on: ubuntu-latest
needs: [read]
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
ref: main
- name: Use Node.js v20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Create temporary report folder
run: mkdir ./temp-reports
- uses: actions/download-artifact@v3
with:
name: benchmark-artifacts-${{github.run_id}}
path: ./temp-reports
- name: Write Benchmark Results
run: |
node scripts/write-bench-results.mjs
node scripts/generate-reports.mjs
env:
BENCH_ARTIFACTS: ${{ needs.read.outputs.result }}
- name: Clean temporary report folder
run: rm -r ./temp-reports
- name: Commit and Push Updated Results
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: 'main'
commit_message: 'chore(bench): update benchmark results'