diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 19de711..050583d 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,21 @@ 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='-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 }} - 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 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"]