-
Notifications
You must be signed in to change notification settings - Fork 20
201 lines (175 loc) · 6.05 KB
/
bench.yml
File metadata and controls
201 lines (175 loc) · 6.05 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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: 'Run Benchmark'
on:
workflow_dispatch:
inputs:
bench-file:
required: true
type: string
node-versions:
required: true
type: string
default: '["18.0.0","18.20.7","18.20.8","20.0.0","20.19.0","20.19.1","21.0.0","21.7.2","21.7.3","22.0.0","22.14.0","22.15.0","23.0.0","23.10.0","23.11.0"]'
description: 'The Node.js Versions (should be a JSON array)'
node-opts:
required: false
type: string
description: 'Flags to be used in the Node.js binary'
run-start-stop:
required: false
type: boolean
default: true
description: 'When false, starting and stopping the runner machine is skipped'
workflow_call:
inputs:
bench-file:
required: true
type: string
node-versions:
required: true
type: string
default: '["18.0.0","18.20.0","18.20.4","20.0.0","20.17.0","20.18.0","21.0.0","21.7.3","22.0.0","22.9.0","22.11.0", "23.0.0"]'
description: 'The Node.js Versions (should be a JSON array)'
node-opts:
required: false
type: string
description: 'Flags to be used in the Node.js binary'
run-start-stop:
required: false
type: boolean
default: true
description: 'When false, starting and stopping the runner machine is skipped'
permissions:
issues: write
contents: read
id-token: write
jobs:
runner-start:
if: ${{ inputs.run-start-stop == true }}
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-west-2
role-to-assume: arn:aws:iam::800406105498:role/RafaelGSS-nodejs-bench-operations
- name: Checkout
uses: actions/checkout@v4
- name: Start Runner
uses: nodesource/aws-eco-runner@v1.0.0-beta.3
with:
instances_id: '["i-065f0f848eb1615ae"]'
action: 'start'
aws_default_region: 'us-west-2'
benchmark:
continue-on-error: true
runs-on: self-hosted
# needs: runner-start
if: always()
strategy:
matrix:
node-version: ${{ fromJson(inputs.node-versions) }}
fail-fast: true
steps:
- uses: actions/checkout@v4
- name: Use Node.js v${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: NPM Install
run: npm install
- name: Report Filename
run: echo "BENCH_REPORT_FILE=report-${{github.run_id}}-${{ matrix.node-version }}-${{ inputs.bench-file }}.md" >> $GITHUB_ENV
- name: Run Benchmark
run: node --allow-natives-syntax ${{ inputs.node-opts }} bench/${{ inputs.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 ${{ inputs.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: Output Failure
if: ${{ failure() }}
uses: cloudposse/github-action-matrix-outputs-write@main
with:
matrix-step-name: benchmark-${{ inputs.bench-file }}
matrix-key: ${{ matrix.node-version }}
outputs: |-
failure: 'true'
result: ''
- name: Add Job Summary
run: |
result=$(cat ./${{ env.BENCH_REPORT_FILE }})
echo "$result" >> $GITHUB_STEP_SUMMARY
- name: Upload Bench Result
uses: actions/upload-artifact@v4
with:
name: benchmark-artifacts-${{github.run_id}}-${{ matrix.node-version }}-${{ inputs.bench-file }}
retention-days: 1
if-no-files-found: error
path: ./${{ env.BENCH_REPORT_FILE }}
commit:
runs-on: ubuntu-latest
continue-on-error: true
needs: [benchmark]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Use Node.js v22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
- name: Create temporary report folder
run: mkdir ./temp-reports
- uses: actions/download-artifact@v4
with:
pattern: benchmark-artifacts-*
merge-multiple: true
path: ./temp-reports
- name: Write Benchmark Reports
run: |
node scripts/write-bench-results.mjs
node scripts/generate-reports.mjs
env:
BENCH_FILE: ${{ inputs.bench-file }}
- 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: ${{ github.ref }}
commit_message: 'chore(${{ inputs.bench-file }}): update benchmark results'
commit_author: Github Actions <actions@github.com>
## Stop Runner
runner-stop:
if: ${{ inputs.run-start-stop == true }}
runs-on: ubuntu-latest
needs: [benchmark]
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Checkout
uses: actions/checkout@v4
- name: Stop Runner
uses: nodesource/aws-eco-runner@v1.0.0-beta.3
with:
instances_id: '["i-065f0f848eb1615ae"]'
action: 'stop'
aws_default_region: 'us-west-2'