-
Notifications
You must be signed in to change notification settings - Fork 1.2k
179 lines (154 loc) · 6.32 KB
/
conbench_upload.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# Copyright (c) Facebook, Inc. and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Upload Benchmark Results
on:
workflow_dispatch:
inputs:
run_id:
description: 'workflow run id to use the artifacts from'
required: true
workflow_run:
workflows: ["Ubuntu Benchmark"]
types:
- completed
permissions:
contents: read
actions: read
statuses: write
jobs:
upload:
runs-on: ubuntu-latest
if: ${{ (github.event.workflow_run.conclusion == 'success' ||
github.event_name == 'workflow_dispatch') &&
github.repository == 'facebookincubator/velox' }}
steps:
- name: 'Download artifacts'
id: 'download'
uses: actions/github-script@v6
with:
script: |
const run_id = "${{ github.event.workflow_run.id || inputs.run_id }}";
let benchmark_run = await github.rest.actions.getWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run_id,
});
let artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run_id,
});
let result_artifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "benchmark-results"
})[0];
let pr_artifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr_number"
})[0];
let result_download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: result_artifact.id,
archive_format: 'zip',
});
let pr_download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: pr_artifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/benchmark-results.zip', Buffer.from(result_download.data));
fs.writeFileSync('${{github.workspace}}/pr_number.zip', Buffer.from(pr_download.data));
core.setOutput('contender_sha', benchmark_run.data.head_sha);
if (benchmark_run.data.event == 'push') {
core.setOutput('merge_commit_message', benchmark_run.data.head_commit.message);
} else {
core.setOutput('merge_commit_message', '');
}
- name: Extract artifact
id: extract
run: |
unzip benchmark-results.zip -d benchmark-results
unzip pr_number.zip
pr_number=$(grep -ox '[[:digit:]]*' pr_number.txt | head -1)
if [ "$pr_number" -ge 0 ]; then
echo "Found PR number: $pr_number"
else
echo '::error :: Malformed input, aborting!'
exit 1
fi
echo "pr_number=$pr_number" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
with:
path: velox
- uses: actions/setup-python@v4
with:
python-version: '3.8'
cache: 'pip'
cache-dependency-path: "velox/scripts/*"
- name: "Install dependencies"
run: python -m pip install -r velox/scripts/benchmark-requirements.txt
- name: "Upload results"
env:
CONBENCH_URL: "https://velox-conbench.voltrondata.run/"
CONBENCH_MACHINE_INFO_NAME: "GitHub-runner-8-core"
CONBENCH_EMAIL: "${{ secrets.CONBENCH_EMAIL }}"
CONBENCH_PASSWORD: "${{ secrets.CONBENCH_PASSWORD }}"
CONBENCH_PROJECT_REPOSITORY: "${{ github.repository }}"
CONBENCH_PROJECT_COMMIT: "${{ steps.download.outputs.contender_sha }}"
run: |
if [ "${{ steps.extract.outputs.pr_number }}" -gt 0]; then
export CONBENCH_PROJECT_PR_NUMBER="${{ steps.extract.outputs.pr_number }}"
fi
./velox/scripts/benchmark-runner.py upload \
--run_id "GHA-${{ github.run_id }}-${{ github.run_attempt }}" \
--pr_number "${{ steps.extract.outputs.pr_number }}" \
--sha "${{ steps.download.outputs.contender_sha }}" \
--output_dir "${{ github.workspace }}/benchmark-results/contender/"
- name: "Check the status of the upload"
# Status functions like failure() only work in `if:`
if: failure()
id: status
run: echo "failed=true" >> $GITHUB_OUTPUT
- name: "Create a GitHub Status on the contender commit (whether the upload was successful)"
uses: actions/github-script@v6
if: ${{ !cancelled() && steps.extract.conclusion != 'failure' }}
with:
script: |
let url = 'https://github.com/${{github.repository}}/actions/runs/${{ github.run_id }}'
let state = 'success'
let description = 'Result upload succeeded!'
if(${{ steps.status.outputs.failed || false }}) {
state = 'failure'
description = 'Result upload failed!'
}
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: '${{ steps.download.outputs.contender_sha }}',
state: state,
target_url: url,
description: description,
context: 'Benchmark Result Upload'
})
- name: Create a GitHub Check benchmark report on the contender comment, and if merge-commit, a comment on the merged PR
env:
CONBENCH_URL: "https://velox-conbench.voltrondata.run/"
GITHUB_APP_ID: "${{ secrets.GH_APP_ID }}"
GITHUB_APP_PRIVATE_KEY: "${{ secrets.GH_APP_PRIVATE_KEY }}"
run: |
./velox/scripts/benchmark-alert.py \
--contender-sha "${{ steps.download.outputs.contender_sha }}" \
--merge-commit-message "${{ steps.download.outputs.merge_commit_message }}" \
--z-score-threshold 50