Skip to content

Commit

Permalink
build: stop pinning a toolchain version (#131)
Browse files Browse the repository at this point in the history
* Remove `channel` from `rust-toolchain`

* Update Cargo.toml and GitHub workflow

* ci: purge Rust cache

* ci: install wasm target

* Make clippy happy

* ci: set toolchain override

* Add MSRV guidelines to README
  • Loading branch information
mooori authored Jan 23, 2024
1 parent 542601c commit a852ce8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ jobs:
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.69.0 # MSRV
override: true
target: wasm32-unknown-unknown

- uses: Swatinem/rust-cache@v1
with:
key: rust-version-1.69.0-msrv
key: rust-version-1.69.0-msrv-2

- name: downgrade some dev-dependencies for msrv, see https://github.com/near/near-workspaces-rs/issues/336
run: ./scripts/fix_dependencies.sh
Expand All @@ -42,12 +44,13 @@ jobs:
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.69.0 # MSRV
override: true
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v1
with:
key: rust-version-1.69.0-msrv
key: rust-version-1.69.0-msrv-2

- name: downgrade some dev-dependencies for msrv, see https://github.com/near/near-workspaces-rs/issues/336
run: ./scripts/fix_dependencies.sh
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ version = "0.15.0"
version = "0.2.0"
edition = "2021"
authors = ["Aurora Labs <[email protected]>"]
# An update of the MSRV requires updating:
# - `rust-toolchain` files in `near-plugins-derive/tests/contracts/**`
# - the toolchain installed in CI via the `toolchain` parameter of `actions-rs/toolchain@v1`
rust-version = "1.69.0"
description = "Ergonomic plugin system to extend NEAR contracts."
license = "CC0-1.0"
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ automatically from macros. They can be changed if the trait is manually implemen

## Contributor Notes

[Contracts used in tests](/near-plugins-derive/tests/contracts/) set `channel = <MSRV>` in their `rust-toolchain` to make tests ensure that plugins are compatible with the MSRV. Developers working on this repo might want to locally set `channel = <MSRV>` in the root `./rust-toolchain` to surface incompabilities with the MSRV early on.

Why not commit `channel = <MSRV>` to `./rust-toolchain`? As a library crate we should leave the choice of the channel to users. Moreover, users should rather use a recent channel instead of the MSRV.

When compiling tests for the first time on a machine using the MSRV 1.69.0, an error might occur due to some dependencies of `near-workspaces` requiring a higher version of Rust. You can execute [./script/fix-dependencies.sh](./scripts/fix_dependencies.sh) to install a compatible version of these dependencies. The comments in that script provide additional information.


Expand Down
2 changes: 1 addition & 1 deletion near-plugins-derive/src/access_control_role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn derive_access_control_role(input: TokenStream) -> TokenStream {

let variant_idents = variants.into_iter().map(|v| v.ident).collect::<Vec<_>>();
assert!(
variant_idents.len() <= usize::try_from(MAX_ROLE_VARIANTS).unwrap(),
variant_idents.len() <= usize::from(MAX_ROLE_VARIANTS),
"The number of enum variants should not exceed MAX_ROLE_VARIANTS",
);
let variant_idxs: Vec<_> =
Expand Down
1 change: 0 additions & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[toolchain]
channel = "1.69.0"
components = ["clippy", "rustfmt"]
targets = [ "wasm32-unknown-unknown" ]

0 comments on commit a852ce8

Please sign in to comment.