Skip to content

Commit 788682f

Browse files
authored
ci: upload persisted canbench_results.yml file (#376)
This PR uploads persisted `canbench_results.yml` files as CI artifacts and centralizes Rust toolchain version management across all CI jobs. This avoids the need to have the exact local environment for calculating `canbench_results.yml` file. It also centralizes the Rust toolchain version across all CI jobs by introducing a single `RUST_VERSION` variable and updating existing steps to use it.
1 parent a479340 commit 788682f

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@ name: CI
22
on: [pull_request]
33

44
env:
5+
RUST_VERSION: 1.84.0 # Use the same version as in `rust-toolchain.toml`
56
CARGO_TERM_COLOR: always # Force Cargo to use colors
67
TERM: xterm-256color
78

89
jobs:
910
build:
1011
runs-on: ubuntu-latest
11-
strategy:
12-
matrix:
13-
rust: [1.84.0]
14-
1512
steps:
1613
- uses: actions/checkout@v4
1714

@@ -28,8 +25,8 @@ jobs:
2825
2926
- name: Install Rust
3027
run: |
31-
rustup update ${{ matrix.rust }} --no-self-update
32-
rustup default ${{ matrix.rust }}
28+
rustup update ${RUST_VERSION} --no-self-update
29+
rustup default ${RUST_VERSION}
3330
rustup component add rustfmt
3431
rustup component add clippy
3532
rustup toolchain install nightly
@@ -68,8 +65,8 @@ jobs:
6865

6966
- name: Install Rust
7067
run: |
71-
rustup update ${{ matrix.rust }} --no-self-update
72-
rustup default ${{ matrix.rust }}
68+
rustup update ${RUST_VERSION} --no-self-update
69+
rustup default ${RUST_VERSION}
7370
rustup target add wasm32-unknown-unknown
7471
7572
- name: Install DFX
@@ -135,8 +132,8 @@ jobs:
135132

136133
- name: Install Rust
137134
run: |
138-
rustup update ${{ matrix.rust || 'stable' }} --no-self-update
139-
rustup default ${{ matrix.rust || 'stable' }}
135+
rustup update ${RUST_VERSION} --no-self-update
136+
rustup default ${RUST_VERSION}
140137
rustup target add wasm32-unknown-unknown
141138
142139
- name: Benchmark
@@ -148,6 +145,11 @@ jobs:
148145
name: canbench_result_${{ matrix.name }}
149146
path: /tmp/canbench_result_${{ matrix.name }}
150147

148+
- uses: actions/upload-artifact@v4
149+
with:
150+
name: canbench_results_persisted_${{ matrix.name }}_yml
151+
path: /tmp/canbench_results_persisted_${{ matrix.name }}.yml
152+
151153
- uses: actions/upload-artifact@v4
152154
with:
153155
name: canbench_results_${{ matrix.name }}_csv

.github/workflows/pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
MDBOOK_VERSION: 0.4.48
2424
MDBOOK_ADMONISH_VERSION: 1.19.0
2525
MDBOOK_LINKCHECK_VERSION: 0.7.7
26-
RUST_VERSION: 1.84.0
26+
RUST_VERSION: 1.84.0 # Use the same version as in `rust-toolchain.toml`
2727
steps:
2828
- uses: actions/checkout@v4
2929

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "1.84.0"
2+
channel = "1.84.0" # Use the same version as in `.github/workflows/*.yml`
33
targets = ["wasm32-unknown-unknown"]

scripts/ci_run_benchmark.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ BASELINE_BRANCH_DIR=_canbench_baseline_branch
1919
CANBENCH_OUTPUT=/tmp/canbench_output.txt
2020

2121
CANBENCH_RESULTS_FILE="$CANISTER_PATH/canbench_results.yml"
22+
CANBENCH_RESULTS_PERSISTED_FILE="/tmp/canbench_results_persisted_${CANBENCH_JOB_NAME}.yml"
2223
BASELINE_BRANCH_RESULTS_FILE="$BASELINE_BRANCH_DIR/$CANBENCH_RESULTS_FILE"
2324

2425
CANBENCH_RESULTS_CSV_FILE="/tmp/canbench_results_${CANBENCH_JOB_NAME}.csv"
@@ -57,7 +58,8 @@ has_updates() {
5758

5859
# Check if the canbench results file is up to date.
5960
pushd "$CANISTER_PATH"
60-
canbench --less-verbose --hide-results --show-summary --csv > "$CANBENCH_OUTPUT"
61+
canbench --less-verbose --hide-results --show-summary --csv --persist > "$CANBENCH_OUTPUT"
62+
cp "./canbench_results.yml" "$CANBENCH_RESULTS_PERSISTED_FILE"
6163
cp "./canbench_results.csv" "$CANBENCH_RESULTS_CSV_FILE"
6264
if has_updates; then
6365
UPDATED_MSG="**❌ \`$CANBENCH_RESULTS_FILE\` is not up to date**

0 commit comments

Comments
 (0)