rust: Run rustfmt and clippy in CI
This commit is contained in:
parent
676d729e3a
commit
e7554f8b9e
|
@ -117,7 +117,7 @@ jobs:
|
||||||
${{ runner.os }}-
|
${{ runner.os }}-
|
||||||
|
|
||||||
- name: Install rust toolchain
|
- name: Install rust toolchain
|
||||||
uses: dtolnay/rust-toolchain@master
|
uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb
|
||||||
with:
|
with:
|
||||||
toolchain: ${{ steps.toolchain.outputs.version }}
|
toolchain: ${{ steps.toolchain.outputs.version }}
|
||||||
components: "clippy,rustfmt"
|
components: "clippy,rustfmt"
|
||||||
|
@ -268,33 +268,56 @@ jobs:
|
||||||
# Run Rust lints and tests
|
# Run Rust lints and tests
|
||||||
rust-lint-and-tests:
|
rust-lint-and-tests:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
|
env:
|
||||||
|
RUSTFLAGS: -Dwarnings
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
manifest:
|
manifest:
|
||||||
|
- cosmwasm/Cargo.toml
|
||||||
- terra/Cargo.toml
|
- terra/Cargo.toml
|
||||||
- sdk/rust/Cargo.toml
|
- sdk/rust/Cargo.toml
|
||||||
steps:
|
steps:
|
||||||
- name: Check out source
|
- name: Check out source
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install stable rust toolchain
|
- name: Install rust toolchain
|
||||||
uses: actions-rs/toolchain@v1
|
uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
default: true
|
components: "clippy,rustfmt"
|
||||||
|
|
||||||
- name: Run `cargo check`
|
- name: Create cache key
|
||||||
uses: actions-rs/cargo@v1
|
id: cachekey
|
||||||
with:
|
env:
|
||||||
command: check
|
MANIFEST: ${{ matrix.manifest }}
|
||||||
args: --workspace --manifest-path ${{ matrix.manifest }}
|
run: |
|
||||||
|
LOCKFILE="$(dirname "${MANIFEST}")/Cargo.lock"
|
||||||
|
NAME="${MANIFEST%%/*}"
|
||||||
|
HASH="$(sha256sum "${LOCKFILE}" | awk '{ print $1 }')"
|
||||||
|
echo "::set-output name=name::${NAME}"
|
||||||
|
echo "::set-output name=hash::${HASH}"
|
||||||
|
|
||||||
- name: Run `cargo test`
|
- name: Cache rust packages
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
command: test
|
path: ~/.cargo/registry
|
||||||
args: --workspace --manifest-path ${{ matrix.manifest }}
|
key: ${{ runner.os }}-build-${{ steps.cachekey.outputs.name }}-${{ steps.cachekey.outputs.hash }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-build-${{ matrix.manifest }}-
|
||||||
|
|
||||||
|
- name: Run `rustfmt`
|
||||||
|
env:
|
||||||
|
MANIFEST: ${{ matrix.manifest }}
|
||||||
|
# In its infinite wisdom, `cargo fmt --all` will also format path-based dependencies so
|
||||||
|
# instead we have to manually format each ".rs" file.
|
||||||
|
run: find "$(dirname "${MANIFEST}")" -name '*.rs' -exec rustfmt --check {} +
|
||||||
|
|
||||||
|
- name: Run `cargo clippy`
|
||||||
|
run: cargo clippy --workspace --tests --locked --manifest-path ${{ matrix.manifest }}
|
||||||
|
|
||||||
|
- name: Run unit tests
|
||||||
|
run: cargo test --workspace --locked --manifest-path ${{ matrix.manifest }}
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
Loading…
Reference in New Issue