-
Notifications
You must be signed in to change notification settings - Fork 109
134 lines (114 loc) · 4.18 KB
/
benchmarks.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
on:
push:
branches:
- master
- drogus/benchmarks-improvements
workflow_dispatch:
inputs:
pr_number:
description: 'Pull Request Number'
required: false
default: ''
name: Benchmarks
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
benchmark:
name: run benchmarks
runs-on: benchmarks-runner
steps:
- name: Enable CPU boost
run: echo "1" | sudo tee /sys/devices/system/cpu/cpufreq/boost
- name: Checkout sources for a PR
if: ${{ github.event.inputs.ref }}
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.ref }}
fetch-depth: 0
- name: Checkout sources
if: github.event.inputs.ref == ''
uses: actions/checkout@v3
with:
fetch-depth: 10
- name: Set up for PR context
if: github.event.inputs.pr_number
run: |
echo "PR_NUMBER=${{ github.event.inputs.pr_number }}" >> $GITHUB_ENV
PR_DATA=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.inputs.pr_number }} --jq '{ baseRefName: .base.ref, headRefName: .head.ref }')
echo "PR_BASE_REF=$(echo $PR_DATA | jq -r '.baseRefName')" >> $GITHUB_ENV
echo "PR_HEAD_REF=$(echo $PR_DATA | jq -r '.headRefName')" >> $GITHUB_ENV
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: wasm32-unknown-unknown
override: true
- name: Extract branch name
shell: bash
run: echo "BRANCH_NAME=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV
- name: Install clippy and critcmp
run: |
rustup component add clippy
cargo install critcmp
- name: Disable CPU boost
run: echo "0" | sudo tee /sys/devices/system/cpu/cpufreq/boost
- name: Run criterion
id: run-criterion
shell: bash
run: |
git fetch
CHANGES_ID=""
if [[ -n "$PR_NUMBER" ]]; then
CHANGES_ID="pr-$PR_NUMBER"
else
CHANGES_ID=$GITHUB_SHA
fi
pushd crates/bench
cargo bench -- --save-baseline $CHANGES_ID
popd
mkdir criterion-results
if [[ -z "$PR_NUMBER" ]]; then
# if we're not in a PR also export with the branch name
critcmp --export $CHANGES_ID > criterion-results/${BRANCH_NAME//\//-}.json
fi
critcmp --export $CHANGES_ID > criterion-results/$CHANGES_ID.json
echo "CHANGES_ID=$CHANGES_ID" >> $GITHUB_ENV
echo "BASE_ID=$BASE_ID" >> $GITHUB_ENV
- uses: actions/github-script@v5
if: github.event.inputs.pr_number
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const {CHANGES_ID, BASE_ID} = process.env
github.rest.issues.createComment({
issue_number: github.event.inputs.pr_number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `[Benchmarks compare](https://benchmarks.spacetimedb.com/compare/${CHANGES_ID},${BASE_ID})`
})
- uses: actions/github-script@v5
if: "! github.event.inputs.pr_number"
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const {CHANGES_ID, BASE_ID} = process.env
github.rest.repos.createCommitComment({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
body: `[Benchmarks compare](https://benchmarks.spacetimedb.com/compare/${CHANGES_ID},${BASE_ID})`
})
- name: Upload criterion results to DO spaces
uses: shallwefootball/s3-upload-action@master
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
aws_bucket: "spacetimedb-ci-benchmarks"
source_dir: criterion-results
endpoint: https://nyc3.digitaloceanspaces.com
destination_dir: benchmarks
- name: Clean up
if: always()
run: |
rm -fr /stdb/*