Skip to content

Commit

Permalink
chore: unify Rust toolchain version (#429)
Browse files Browse the repository at this point in the history
* override toolchain in CI

* comments

* execute rustup override set

* remove MSRV of candid-extractor

* set MSRV to 1.66.0 and use it everywhere

* unify cache key hashFiles

* concise Cargo.toml members

* candidi-extractor MSRV

* fix CI test job

* clippy

* comment
  • Loading branch information
lwshang authored Sep 21, 2023
1 parent a2623bc commit 0ef0353
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 82 deletions.
38 changes: 5 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
rust-version: 1.65.0

jobs:
build:
name: cargo build
Expand All @@ -29,15 +26,10 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-build-${{ hashFiles('**/Cargo.toml', 'rust-toolchain.toml') }}
key: ${{ runner.os }}-build-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}
restore-keys: |
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ env.rust-version }}
target: wasm32-unknown-unknown
- name: Run builds
run: |
cargo build --workspace --exclude ic-cdk-e2e-tests --exclude candid-extractor --target wasm32-unknown-unknown
Expand All @@ -59,23 +51,16 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-test-${{ hashFiles('**/Cargo.toml', 'rust-toolchain.toml') }}
key: ${{ runner.os }}-test-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}
restore-keys: |
${{ runner.os }}-test-
${{ runner.os }}-
- name: Install Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ env.rust-version }}
- name: Install protoc
run: |
sudo apt-get install -y protobuf-compiler
- name: Download ic-test-state-machine
run: |
bash scripts/download_state_machine_binary.sh
- name: Run tests
run: |
cargo test --all-targets
cargo test --workspace --exclude candid-extractor --all-targets
fmt:
name: cargo fmt
Expand All @@ -92,15 +77,10 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-fmt-${{ hashFiles('**/Cargo.toml', 'rust-toolchain.toml') }}
key: ${{ runner.os }}-fmt-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}
restore-keys: |
${{ runner.os }}-fmt-
${{ runner.os }}-
- name: Install Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ env.rust-version }}
components: rustfmt
- name: Check formatting
run: |
cargo fmt --all -- --check
Expand All @@ -120,18 +100,10 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-clippy-${{ hashFiles('**/Cargo.toml', 'rust-toolchain.toml') }}
key: ${{ runner.os }}-clippy-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}
restore-keys: |
${{ runner.os }}-clippy-
${{ runner.os }}-
- name: Install Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ env.rust-version }}
components: clippy
- name: Install protoc
run: |
sudo apt-get install -y protobuf-compiler
- name: Run clippy
run: |
cargo clippy --tests --benches -- -D warnings
Expand Down
19 changes: 3 additions & 16 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ concurrency:
cancel-in-progress: true

env:
rust-version: 1.65.0
dfx-version: 0.14.1
ic-wasm-version: 0.4.0

Expand All @@ -31,16 +30,11 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-candid-extractor-${{ hashFiles('**/Cargo.toml', 'rust-toolchain.toml') }}
key: ${{ runner.os }}-candid-extractor-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}
restore-keys: |
${{ runner.os }}-candid-extractor-
${{ runner.os }}-
- name: Install Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ env.rust-version }}

- name: Build candid-extractor
run: cargo build -p candid-extractor --release

Expand Down Expand Up @@ -71,18 +65,11 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
examples/${{ matrix.project-name }}/target/
key: ${{ runner.os }}-${{ matrix.project-name }}-${{ hashFiles('**/Cargo.toml', 'rust-toolchain.toml') }}
key: ${{ runner.os }}-${{ matrix.project-name }}-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.project-name }}-
${{ runner.os }}-
- name: Install Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ env.rust-version }}
target: wasm32-unknown-unknown
components: rustfmt

- name: Install ic-wasm
# might already in cache
run: |
Expand Down Expand Up @@ -133,7 +120,7 @@ jobs:
env:
RUST_BACKTRACE: 1

- name: cargo fmt # no clippy because #[import] makes it fail
- name: cargo fmt # no clippy because build.rs using ic-cdk-bindgen would fail
run: |
pushd examples/${{ matrix.project-name }}
cargo fmt --check
Expand Down
17 changes: 4 additions & 13 deletions .github/workflows/release-candid-extractor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@ on:
tags:
- "candid-extractor-*"

env:
rust-version: 1.65.0

jobs:
release:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# The indirect dependency `zstd-safe` (introduced by `wasmtime`) needs higher version of GLIBC.
# using ubuntu-20.04 will fail to compile
# The indirect dependency `zstd-safe` (introduced by `wasmtime`) needs higher version of GLIBC.
# using ubuntu-20.04 will fail to compile
- os: ubuntu-22.04
binstall_pkg: candid-extractor-x86_64-unknown-linux-gnu.tar.gz
- os: macos-12
Expand All @@ -34,16 +31,10 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-release-${{ hashFiles('**/Cargo.toml', 'rust-toolchain.toml') }}
key: ${{ runner.os }}-candid-extractor-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}
restore-keys: |
${{ runner.os }}-release-
${{ runner.os }}-candid-extractor-
${{ runner.os }}-
- name: Install Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ env.rust-version }}

- name: Build
run: |
cargo build -p candid-extractor --release --locked
Expand Down
3 changes: 2 additions & 1 deletion Cargo.lock

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

16 changes: 4 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
[workspace]
members = [
"src/ic0",
"src/ic-cdk",
"src/ic-cdk-bindgen",
"src/ic-cdk-macros",
"src/ic-cdk-timers",
"src/candid-extractor",
"library/ic-certified-map",
"library/ic-ledger-types",
"src/*",
"library/*",
"e2e-tests",
]

Expand All @@ -17,10 +11,8 @@ edition = "2021"
repository = "https://github.com/dfinity/cdk-rs"
# MSRV
# Avoid updating this field unless we use new Rust features
# Sync rust-version in following CI files:
# .github/workflows/ci.yml
# .github/workflows/examples.yml
rust-version = "1.65.0"
# Sync with rust-toolchain.toml
rust-version = "1.66.0"
license = "Apache-2.0"

[profile.canister-release]
Expand Down
3 changes: 1 addition & 2 deletions e2e-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@ path = "canisters/canister_info.rs"

[dev-dependencies]
hex.workspace = true
# TODO: Use the public crate when this [PR](https://github.com/dfinity/test-state-machine-client/pull/19) merge.
ic-test-state-machine-client = { git = "https://github.com/lwshang/test-state-machine-client", branch = "lwshang/candid_0.9" }
ic-test-state-machine-client = "3"
5 changes: 1 addition & 4 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
[toolchain]
channel = "1.71.1"
channel = "1.66.0" # sync with rust-version in root Cargo.toml
targets = ["wasm32-unknown-unknown"]
components = ["rustfmt", "clippy"]

# The version only influences the local develop environment.
# No need to sync with Cargo.toml and CI.
2 changes: 1 addition & 1 deletion src/candid-extractor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ where

let memory = canister
.get_memory(&mut store, "memory")
.ok_or(anyhow::format_err!("failed to find `memory` export"))?;
.ok_or_else(|| anyhow::format_err!("failed to find `memory` export"))?;
let memory_buffer = memory.data(&store);

let mut i = candid_pointer as usize;
Expand Down

0 comments on commit 0ef0353

Please sign in to comment.