Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ jobs:
- name: Checkout baseline branch
uses: actions/checkout@v4
with:
ref: main
# TODO switch back to main once this is merged
#ref: main
path: _canbench_baseline_branch

- uses: actions/cache@v3
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Publish canbench crates to crates.io

on:
push:
tags:
- "v*"

jobs:
publish-canbench:
runs-on: ubuntu-latest

permissions:
id-token: write # Required for OIDC token exchange

steps:
- uses: actions/checkout@v5

- uses: rust-lang/crates-io-auth-action@v1
id: auth

- name: Set Cargo.toml version
shell: bash
env:
RELEASE_TAG: ${{ github.ref }}
run: |
sed -i -e "s/0\\.0\\.0-git/${RELEASE_TAG##*\/v}/" canbench-rs-macros/Cargo.toml
sed -i -e "s/\(^canbench-rs-macros.*\"\).* }/\1, version=\"${RELEASE_TAG##*\/v}\" }/" canbench-rs/Cargo.toml
sed -i -e "s/0\\.0\\.0-git/${RELEASE_TAG##*\/v}/" canbench-rs/Cargo.toml
sed -i -e "s/\(^canbench-rs.*\"\).* }/\1, version=\"${RELEASE_TAG##*\/v}\" }/" canbench-bin/Cargo.toml
sed -i -e "s/0\\.0\\.0-git/${RELEASE_TAG##*\/v}/" canbench-bin/Cargo.toml

- run: cargo publish -p canbench-rs-macros --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

- run: cargo publish -p canbench-rs --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

- run: cargo publish -p canbench --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

- name: Post to a Slack channel
uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0
with:
channel-id: eng-dsm-alerts
slack-message: "New `canbench` crates (version `${{ github.ref_name }}`) has been published to crates.io"
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_API_TOKEN }}
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions canbench-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ license = "Apache-2.0"
name = "canbench"
readme = "../README.md"
repository = "https://github.com/dfinity/canbench"
# NOTE: Update `canbench-rs` version below when this changes.
version = "0.4.0"
# Version is set by a Github workflow from the git tag
version = "0.0.0-git"

[[bin]]
name = "canbench"
path = "src/main.rs"

[dependencies]
canbench-rs = { path = "../canbench-rs", version = "0.4.0" }
# canbench-rs version tag is set by a Github workflow from the git tag
canbench-rs = { path = "../canbench-rs" }
candid.workspace = true
clap.workspace = true
colored.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion canbench-bin/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ fn newer_version() {
.run(|output| {
assert_err!(
output,
"canbench is at version 0.4.0 while the results were generated with version 99.0.0. Please upgrade canbench.
"canbench is at version 0.0.0-git while the results were generated with version 99.0.0. Please upgrade canbench.
"
);
});
Expand Down
2 changes: 1 addition & 1 deletion canbench-rs-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = "2021"
license = "Apache-2.0"
name = "canbench-rs-macros"
repository = "https://github.com/dfinity/canbench"
version = "0.4.0"
version = "0.0.0-git"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
7 changes: 4 additions & 3 deletions canbench-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ license = "Apache-2.0"
name = "canbench-rs"
readme = "../README.md"
repository = "https://github.com/dfinity/canbench"
# NOTE: Update `canbench-rs-macros` version below when this changes.
version = "0.4.0"
# Version is set by a Github workflow from the git tag
version = "0.0.0-git"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
path = "src/lib.rs"

[dependencies]
canbench-rs-macros = { path = "../canbench-rs-macros", version = "0.4.0" }
# canbench-rs-macros version tag is set by a Github workflow from the git tag
canbench-rs-macros = { path = "../canbench-rs-macros" }
candid.workspace = true
ic-cdk.workspace = true
serde.workspace = true
Expand Down
13 changes: 1 addition & 12 deletions development-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,4 @@ Here's an example PR bumping the versions: https://github.com/dfinity/canbench/p
- Set the title to `vX.X.X`.
- Choose the previous tag as the last release.
- Add release notes. GitHub can generate them by clicking **Generate release notes**, modify as needed.
3. Click **Publish release** when ready.

## Steps to Publish the Packages to crates.io

1. Generate an API token to use with crates.io:
Log in to crates.io with your GitHub account, go to **Account Settings**, and generate a new token under **API Tokens**.
2. Run `cargo login` in the terminal and enter your API key when prompted.
3. Check out the repo at the tag created for the release, e.g. `git checkout vX.X.X`.
4. Publish the crates in the following order:
- `cargo publish -p canbench-rs-macros`
- `cargo publish -p canbench-rs`
- `cargo publish -p canbench`
3. Click **Publish release** when ready, which will trigger the workflows to publish to crates.io.
2 changes: 1 addition & 1 deletion examples/btreemap_vs_hashmap/canbench_results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ benches:
heap_increase: 0
stable_memory_increase: 0
scopes: {}
version: 0.2.1
version: 0.0.0-git
2 changes: 1 addition & 1 deletion examples/fibonacci/canbench_results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ benches:
heap_increase: 0
stable_memory_increase: 0
scopes: {}
version: 0.2.1
version: 0.0.0-git
2 changes: 1 addition & 1 deletion tests/init_arg/canbench_results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ benches:
heap_increase: 0
stable_memory_increase: 0
scopes: {}
version: 0.1.10
version: 0.0.0-git
2 changes: 1 addition & 1 deletion tests/measurements_output/canbench_results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ benches:
calls: 20
heap_increase: 0
instructions: 20000000
version: 0.1.15
version: 0.0.0-git