From dadf6e91ad32abef1c45469640a1eb07bf5674a0 Mon Sep 17 00:00:00 2001 From: DrPing Date: Mon, 19 May 2025 18:40:21 +0900 Subject: [PATCH 1/3] refactor(CI): try to run clippy and test in parallel --- .github/workflows/pr-check.yml | 82 ++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 28 deletions(-) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index f59f4643..074343b3 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -1,4 +1,3 @@ - name: Pull Request Check on: @@ -8,35 +7,62 @@ on: - synchronize - closed -jobs: - check: - runs-on: ubuntu-24.04 +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + fmt: + runs-on: ubuntu-latest + container: + image: rust:1.87-slim + steps: - - name: "[Setup] Free Disk Space (insightsengineering/disk-space-reclaimer)" - uses: insightsengineering/disk-space-reclaimer@v1.1.0 - - - name: "[Setup] Linux Tools" - run: sudo apt install -y cmake pkg-config libssl-dev build-essential clang libclang-dev curl protobuf-compiler - - - name: "[Setup] Rust" - run: | - TLCHN=nightly-2024-01-21 - curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $TLCHN - rustup target add wasm32-unknown-unknown --toolchain $TLCHN - cargo install cargo-expand --locked --version 1.0.71 - - - name: Checkout Sources (actions/checkout) + - name: Checkout Sources uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: "[Check] cargo fmt" + run: cargo fmt --check - - name: "[Ceck] cargo fmt" - run: | - cargo fmt --check - - - name: "[Check] cargo test" - run: | - cargo test --release --features on-chain-release-build - - - name: "[Check] cargo clippy" + test-and-clippy: + runs-on: ubuntu-latest + container: + image: rust:1.87-slim + + steps: + - name: Checkout Sources + uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Cache build outputs + uses: actions/cache@v3 + with: + path: | + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: Run tests and clippy in parallel run: | - cargo clippy --release --features on-chain-release-build -- -Dwarnings + # Start tests and clippy in parallel + cargo test --release --features on-chain-release-build & + TEST_PID=$! + + cargo clippy --release --features on-chain-release-build -- -Dwarnings & + CLIPPY_PID=$! + + # Wait for both processes to complete + wait $TEST_PID + TEST_EXIT=$? + + wait $CLIPPY_PID + CLIPPY_EXIT=$? + + # Exit with failure if either process failed + if [ $TEST_EXIT -ne 0 ] || [ $CLIPPY_EXIT -ne 0 ]; then + exit 1 + fi \ No newline at end of file From 95b9d340478b618536c14af2d4f7157cc6c93d70 Mon Sep 17 00:00:00 2001 From: DrPing Date: Mon, 19 May 2025 18:52:55 +0900 Subject: [PATCH 2/3] fix(CI): change to more parity container for all the tools --- .github/workflows/pr-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 074343b3..ae90b1b6 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -29,7 +29,7 @@ jobs: test-and-clippy: runs-on: ubuntu-latest container: - image: rust:1.87-slim + image: paritytech/ci-linux:production steps: - name: Checkout Sources From 21b8a2e73d1b2c75a46c70b94d73ea64c0046562 Mon Sep 17 00:00:00 2001 From: DrPing Date: Fri, 30 May 2025 18:32:51 +0900 Subject: [PATCH 3/3] fix(CI): fix permission to prevent CI from failing --- .github/workflows/pr-check.yml | 41 +++++++++++++++------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index ae90b1b6..0cf964b7 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -34,35 +34,30 @@ jobs: steps: - name: Checkout Sources uses: actions/checkout@v3 - with: - fetch-depth: 1 + + - name: Fix permissions + run: | + # Fix permission issues with the rustup directory + mkdir -p ~/.cargo ~/.rustup + chown -R $(whoami):$(whoami) ~/.cargo ~/.rustup - name: Cache build outputs uses: actions/cache@v3 with: path: | - target + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: | ${{ runner.os }}-cargo- - - - name: Run tests and clippy in parallel + + - name: Run tests + run: | + RUST_BACKTRACE=1 cargo test --release --features on-chain-release-build -v + + - name: Run clippy run: | - # Start tests and clippy in parallel - cargo test --release --features on-chain-release-build & - TEST_PID=$! - - cargo clippy --release --features on-chain-release-build -- -Dwarnings & - CLIPPY_PID=$! - - # Wait for both processes to complete - wait $TEST_PID - TEST_EXIT=$? - - wait $CLIPPY_PID - CLIPPY_EXIT=$? - - # Exit with failure if either process failed - if [ $TEST_EXIT -ne 0 ] || [ $CLIPPY_EXIT -ne 0 ]; then - exit 1 - fi \ No newline at end of file + cargo clippy --release --features on-chain-release-build -- -Dwarnings \ No newline at end of file