-
Notifications
You must be signed in to change notification settings - Fork 9
175 lines (146 loc) · 5.47 KB
/
benchmark.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
name: Benchmark Tests
on:
pull_request_review:
defaults:
run:
shell: bash -l {0}
jobs:
test:
name: Execute benchmark tests
if: github.event_name == 'pull_request_review' && (github.event.review.state == 'approved' || contains(github.event.review.body, 'please run benchmark'))
runs-on: ubuntu-20.04
env:
BENCHMARK_NUMBER_SAMPLES: 100
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Need to fetch enough nodes to get the common ancestor - but don't want to fetch everything
fetch-depth: 100
- name: Get hashes for PR review event
uses: actions/github-script@v4
with:
script: |
const child_process = require("child_process");
const pull_request = context.payload.pull_request;
child_process.exec(`git merge-base ${pull_request.head.sha} ${pull_request.base.sha}`, (error, stdout, stderr) => {
if (error) {
console.log(error);
process.exit(1);
return;
}
if (stderr) {
console.log(stderr);
process.exit(1);
return;
}
core.exportVariable('OLD_REF_SHA', stdout.trim());
core.exportVariable('NEW_REF_SHA', pull_request.head.sha);
core.exportVariable('PULL_REQUEST_ID', pull_request.number);
});
- uses: iterative/setup-cml@v1
- name: Cache Conda
uses: actions/cache@v1
with:
path: ~/.conda
key: ${{ runner.os }}-mconda-${{ hashFiles('**/configuration.yml') }}
restore-keys: |
${{ runner.os }}-conda-
- name: Install Conda environment with Micromamba
uses: mamba-org/provision-with-micromamba@main
with:
environment-name: beakerx_tabledisplay
environment-file: configuration.yml
channels: conda-forge
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache yarn
uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# First run the benchmark on the old reference
- name: Checkout old reference
run: |
echo Checking out ${OLD_REF_SHA}...
git checkout ${OLD_REF_SHA}
- name: Install dependencies
run: |
set -eux
pip install beakerx_tabledisplay
beakerx_tabledisplay install
- name: Install browser
working-directory: ui-tests
run: |
jlpm install
# Install only Chromium browser
jlpm playwright install chromium
- name: Execute benchmark tests on reference
continue-on-error: true
working-directory: ui-tests
run: |
jlpm run test -u
# Second run the benchmark on the new reference
- name: Checkout latest version
run: |
echo Checking out ${NEW_REF_SHA}...
git checkout ${NEW_REF_SHA}
- name: Install dependencies
run: |
set -eux
# Reset installation
beakerx_tabledisplay uninstall
pip uninstall -y beakerx-tabledisplay
conda env update -f configuration.yml
pip install beakerx_tabledisplay
beakerx_tabledisplay install
- name: Install browser
working-directory: ui-tests
run: |
jlpm install
# Install only Chromium browser
jlpm playwright install chromium
- name: Execute benchmark tests on PR
continue-on-error: true
working-directory: ui-tests
run: |
jlpm run test
- name: Generate the report
env:
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPORT: ./benchmark-results/beakerx-benchmark.md
working-directory: ui-tests
run: |
set -eux
# Publish image to cml.dev
echo "" >> ${REPORT}
cml-publish ./benchmark-results/beakerx-benchmark.png --md >> ${REPORT}
echo "" >> ${REPORT}
# Test if metadata have changed
export METADATA_DIFF="/tmp/metadata.diff"
diff -u <(jq --sort-keys .metadata benchmark-results/beakerx-benchmark.json) <(jq --sort-keys .metadata beakerx-benchmark-expected.json) > ${METADATA_DIFF} || true
if [[ -s ${METADATA_DIFF} ]]; then
echo "<details><summary>:exclamation: Test metadata have changed</summary>" >> ${REPORT}
echo "" >> ${REPORT}
echo "\`\`\`diff" >> ${REPORT}
cat ${METADATA_DIFF} >> ${REPORT}
echo "\`\`\`" >> ${REPORT}
echo "" >> ${REPORT}
echo "</details>" >> ${REPORT}
fi
# Copy the reference data to upload it as artifact
cp beakerx-benchmark-expected.json ./benchmark-results/
# Save PR number for comment publication
echo "${PULL_REQUEST_ID}" > ./benchmark-results/NR
- name: Upload Benchmark Assets
if: always()
uses: actions/upload-artifact@v2
with:
name: benchmark-assets
path: |
ui-tests/benchmark-results
ui-tests/test-results