From f9ec84877b2aa0ba440e31a94d793f3ec1d9750c Mon Sep 17 00:00:00 2001 From: zachary0809 <139736437+zachary0809@users.noreply.github.com> Date: Mon, 5 Aug 2024 22:27:59 +0800 Subject: [PATCH] Create rust.yml Add code compilation and format detection for key branches --- .github/workflows/rust.yml | 73 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/rust.yml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..14d4827 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,73 @@ +name: Rust + +on: + push: + branches: + - 'main' + - 'main-develop' + pull_request: + branches: + - 'main' + - 'main-develop' + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - name: Free up space on runner + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + + - name: Rust Setup + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + target: wasm32-unknown-unknown + override: true + components: rustfmt, clippy + + - name: Install smove + run: cargo install --git https://github.com/eigerco/smove + + - name: Install protoc + run: | + sudo apt-get install -y protobuf-compiler + protoc --version + + - uses: actions/checkout@v3 + + - name: Rustfmt + uses: actions-rs/cargo@v1 + with: + toolchain: stable + command: fmt + args: --all --check + + - name: Rust Cache + uses: Swatinem/rust-cache@v2.5.0 + with: + cache-on-failure: true + cache-all-crates: true + + - name: Add rust-src + run: | + rustup component add rust-src + + - name: Cargo Clean + run: cargo clean + + - name: Build + run: cargo check --release + + - name: Run tests + run: cargo test --release --locked --verbose --all