From c951db87c9adf0d293cd8f2f8a3572777abeb70f Mon Sep 17 00:00:00 2001 From: Marcel Moura Date: Thu, 6 Jul 2023 16:18:48 -0300 Subject: [PATCH] ci(offchain): run code quality assessment While here, move code format and dependency checking to the code quality workflow. --- .github/workflows/build.yml | 3 -- .github/workflows/code-quality.yml | 51 ++++++++++++++++++++++++++++++ .github/workflows/dependencies.yml | 27 ---------------- 3 files changed, 51 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/code-quality.yml delete mode 100644 .github/workflows/dependencies.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eb837ede3..fea501ca7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,9 +51,6 @@ jobs: run: cargo install cargo-cache continue-on-error: true - - name: Check format - run: cargo fmt --all -- --check - - name: Set sweep timestamp run: cargo sweep -s diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml new file mode 100644 index 000000000..1a397d199 --- /dev/null +++ b/.github/workflows/code-quality.yml @@ -0,0 +1,51 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json +name: Offchain code quality assessment +on: + push: + paths: + - '.github/workflows/code-quality.yml' + - 'offchain/**' +jobs: + assess-offchain-code-quality: + runs-on: ubuntu-latest + env: + CARGO_REGISTRIES_CARTESI_INDEX: https://github.com/cartesi/crates-index + defaults: + run: + working-directory: offchain + + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + token: ${{ secrets.CI_TOKEN }} + + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + offchain/target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo- + + - name: Install protoc + run: sudo apt update && sudo apt install -y protobuf-compiler libprotobuf-dev + + - name: Update rust + run: rustup update + + - name: Install cargo-machete + run: cargo install cargo-machete + + - name: Analyze dependencies + run: cargo machete . + continue-on-error: true + + - name: Check format + run: cargo fmt --all -- --check + + - name: Run linter + run: cargo clippy diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml deleted file mode 100644 index 56a41e99a..000000000 --- a/.github/workflows/dependencies.yml +++ /dev/null @@ -1,27 +0,0 @@ -# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json -name: Check for unused dependencies -on: - push: - paths: - - '.github/workflows/dependencies.yml' - - 'offchain/**' -jobs: - check-offchain-deps: - runs-on: ubuntu-latest - env: - CARGO_REGISTRIES_CARTESI_INDEX: https://github.com/cartesi/crates-index - defaults: - run: - working-directory: offchain - - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Install cargo-machete - run: cargo install cargo-machete - - - name: Analyze dependencies - run: cargo machete .