-
Notifications
You must be signed in to change notification settings - Fork 105
99 lines (87 loc) · 3.5 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
name: Benchmarks
on:
workflow_dispatch:
inputs:
change-type:
description: How should changes be made after the benchmarks are completed?
required: true
default: ignore
type: choice
options:
- ignore
- commit
- pull_request
env:
CARGO_TERM_COLOR: always
TERM: xterm-256color
jobs:
benchmarks:
runs-on: bench
permissions:
contents: write
pull-requests: write
env:
RUSTUP_HOME: /tmp/rustup_home
steps:
- name: "ACTIONS: Checkout"
uses: actions/checkout@v4
- name: "Install: Rust toolchain"
uses: dsherret/rust-toolchain-file@v1
- name: "Install: Build deps"
run: |
sudo apt update
sudo apt install -y git clang curl libssl-dev llvm libudev-dev cmake wabt protobuf-compiler wget bzip2
- name: Run all benchmarks
run: |
./scripts/benchmarking/run_all_benchmarks.sh -c gear-dev -m
cp ./scripts/benchmarking/weights-output/* runtime/gear/src/weights
./scripts/benchmarking/run_all_benchmarks.sh -b -c vara-dev -m # -b to skip build
cp ./scripts/benchmarking/weights-output/* runtime/vara/src/weights
# apply some patches for `pallets/gear/src/weights.rs`
cp runtime/gear/src/weights/pallet_gear.rs pallets/gear/src/weights.rs
sed -i -E 's/\w+::WeightInfo for SubstrateWeight/WeightInfo for SubstrateWeight/' pallets/gear/src/weights.rs
# clear the target directory because our benchmarking machine is not ephemeral
cargo clean
- name: "ACTIONS: Upload artifact with benchmarking errors (if exist)"
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: benchmarking-errors
path: scripts/benchmarking/benchmarking_errors.txt
if-no-files-found: ignore
- name: "ACTIONS: Upload artifact with updated weights (gear)"
uses: actions/upload-artifact@v3
with:
name: weights-gear
path: runtime/gear/src/weights/
- name: "ACTIONS: Upload artifact with updated weights (vara)"
uses: actions/upload-artifact@v3
with:
name: weights-vara
path: runtime/vara/src/weights/
- name: "TIP: download the artifacts and use `./scripts/unpack-weights.sh`"
run: |
echo "::notice::You can download the artifacts and use script \`./scripts/unpack-weights.sh\` to apply the changes to your branch"
- name: Create commit
if: ${{ inputs.change-type == 'commit' }}
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: >-
chore(runtime): update weights
file_pattern: "pallets/gear/src/ runtime/gear/src/weights/ runtime/vara/src/weights/"
- name: Create pull Request
if: ${{ inputs.change-type == 'pull_request' }}
uses: peter-evans/create-pull-request@v5
with:
add-paths: |
pallets/gear/src/
runtime/gear/src/weights/
runtime/vara/src/weights/
commit-message: update weights
branch: weights/patch
branch-suffix: short-commit-hash
title: >-
chore(runtime): update weights
body: |
`run_all_benchmarks.sh` script is applied to update weights (branch: `${{ github.ref_name }}`, commit ${{ github.sha }})
**Note:** If CI fails, try manually updating the heuristic tests: `runtime/{gear, vara}/src/tests.rs`