From 19706661c776a8c29c3fc62919b9a0b8084ff595 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Wed, 10 Jan 2024 11:57:56 +1000 Subject: [PATCH 1/4] Build and test the MSRV and latest --- .github/workflows/rust.yml | 16 +++++++++++++--- Cargo.toml | 3 +++ contracts/abundance/Cargo.toml | 1 + contracts/crowdfund/Cargo.toml | 1 + 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 19de711..9e95335 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -5,9 +5,6 @@ on: branches: [main] pull_request: -env: - RUSTFLAGS: -Wclippy::all -Wclippy::pedantic - jobs: # complete: @@ -28,6 +25,7 @@ jobs: build-and-test: strategy: matrix: + rust: [msrv, latest] sys: - os: ubuntu-latest target: wasm32-unknown-unknown @@ -39,7 +37,19 @@ jobs: steps: - uses: actions/checkout@v3 - uses: stellar/actions/rust-cache@main + - name: Use the minimum supported Rust version + if: matrix.rust == 'msrv' + run: | + msrv="$(cargo metadata --format-version 1 --no-deps | jq -r '.packages | map(.rust_version) | map(values) | min')" + rustup override set $msrv + rustup component add clippy --toolchain $msrv + - name: Error on warnings and clippy checks + # Only error on warnings and checks for the msrv, because new versions of + # Rust will frequently add new warnings and checks. + if: matrix.rust == 'msrv' + run: echo RUSTFLAGS='-Dwarnings -Wclippy::all -Wclippy::pedantic' >> $GITHUB_ENV - run: rustup update + - run: cargo version - run: rustup target add ${{ matrix.sys.target }} - run: cargo clippy --target ${{ matrix.sys.target }} --lib - if: matrix.sys.target != 'wasm32-unknown-unknown' diff --git a/Cargo.toml b/Cargo.toml index 2579de3..0ccfa12 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,9 @@ members = [ "contracts/*", ] +[workspace.package] +rust-version = "1.74.0" + [profile.release] opt-level = "z" overflow-checks = true diff --git a/contracts/abundance/Cargo.toml b/contracts/abundance/Cargo.toml index ba34e52..f99e05f 100644 --- a/contracts/abundance/Cargo.toml +++ b/contracts/abundance/Cargo.toml @@ -3,6 +3,7 @@ name = "abundance-token" description = "Soroban standard token contract, but anyone can mint to themselves." version = "0.0.6" edition = "2021" +rust-version.workspace = true [lib] crate-type = ["cdylib"] diff --git a/contracts/crowdfund/Cargo.toml b/contracts/crowdfund/Cargo.toml index 34764ab..4594f45 100644 --- a/contracts/crowdfund/Cargo.toml +++ b/contracts/crowdfund/Cargo.toml @@ -2,6 +2,7 @@ name = "soroban-crowdfund-contract" version = "0.0.0" edition = "2021" +rust-version.workspace = true publish = false autobins = false From d978a66e48bf5ec47363c4397f8fed9bd44a64a3 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Wed, 10 Jan 2024 12:09:48 +1000 Subject: [PATCH 2/4] fix --- .github/workflows/rust.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9e95335..49380d5 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -47,7 +47,8 @@ jobs: # Only error on warnings and checks for the msrv, because new versions of # Rust will frequently add new warnings and checks. if: matrix.rust == 'msrv' - run: echo RUSTFLAGS='-Dwarnings -Wclippy::all -Wclippy::pedantic' >> $GITHUB_ENV + run: echo RUSTFLAGS='-Wclippy::all -Wclippy::pedantic' >> $GITHUB_ENV + # TODO: run: echo RUSTFLAGS='-Dwarnings -Wclippy::all -Wclippy::pedantic' >> $GITHUB_ENV - run: rustup update - run: cargo version - run: rustup target add ${{ matrix.sys.target }} From 3dfcf5b8e874450a996b804128a23704ad6e1f09 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Wed, 10 Jan 2024 12:12:22 +1000 Subject: [PATCH 3/4] add description to todo item --- .github/workflows/rust.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 49380d5..050583d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -48,7 +48,8 @@ jobs: # Rust will frequently add new warnings and checks. if: matrix.rust == 'msrv' run: echo RUSTFLAGS='-Wclippy::all -Wclippy::pedantic' >> $GITHUB_ENV - # TODO: run: echo RUSTFLAGS='-Dwarnings -Wclippy::all -Wclippy::pedantic' >> $GITHUB_ENV + # TODO: Deny warnings when the warnings have been cleaned up. + # run: echo RUSTFLAGS='-Dwarnings -Wclippy::all -Wclippy::pedantic' >> $GITHUB_ENV - run: rustup update - run: cargo version - run: rustup target add ${{ matrix.sys.target }} From db6adba05549fe67edcc16bf754e422206b6311f Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Wed, 10 Jan 2024 12:14:47 +1000 Subject: [PATCH 4/4] Add rust-toolchain.toml --- rust-toolchain.toml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 rust-toolchain.toml diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..e340b76 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "stable" +targets = ["wasm32-unknown-unknown"] +components = ["rustc", "cargo", "rustfmt", "clippy", "rust-src"]