From 0355084502b69d4e694837d328d7817c224300b2 Mon Sep 17 00:00:00 2001 From: Shreevatsa N Date: Thu, 26 Sep 2024 16:30:06 +0530 Subject: [PATCH] Github CI: Test CI to reduce build time with concurrency Signed-off-by: Shreevatsa N --- .../ci-on-pr-rustfmt-test-clippy-build.yml | 67 +++++++++++-------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci-on-pr-rustfmt-test-clippy-build.yml b/.github/workflows/ci-on-pr-rustfmt-test-clippy-build.yml index 7faceb8c..37bd26f1 100644 --- a/.github/workflows/ci-on-pr-rustfmt-test-clippy-build.yml +++ b/.github/workflows/ci-on-pr-rustfmt-test-clippy-build.yml @@ -1,11 +1,9 @@ -name: ci +name: CI on: pull_request: paths-ignore: - "**.md" - "doc/**" - - # Allows to run this workflow manually from the Actions tab workflow_dispatch: defaults: @@ -28,7 +26,7 @@ jobs: - name: install rust nightly run: rustup toolchain install nightly - + - name: show active toolchain run: rustup show active-toolchain @@ -50,6 +48,34 @@ jobs: test: runs-on: ubuntu-latest needs: rustfmt + strategy: + matrix: + package: + - "node/cli" + - "node/rpc" + - "node/inspect" + - "node/testing" + - "pallets/asset" + - "pallets/chain-space" + - "pallets/did" + - "pallets/did-name" + - "pallets/identity" + - "pallets/network-membership" + - "pallets/network-score" + - "pallets/node-authorization" + - "pallets/offences" + - "pallets/runtime-upgrade" + - "pallets/session-benchmarking" + - "pallets/statement" + - "primitives/cord" + - "primitives/identifier" + - "primitives/network-membership" + - "runtimes/common" + - "runtimes/braid" + - "runtimes/loom" + - "runtimes/weave" + - "utilities" + - "test-utils" steps: - name: checkout repository uses: actions/checkout@v4.1.1 @@ -57,7 +83,7 @@ jobs: - name: install dependencies run: sudo apt-get update && sudo apt-get install -y protobuf-compiler libssl-dev - - name: cache + - name: cache rust toolchain and dependencies uses: actions/cache@v4 with: path: | @@ -67,7 +93,9 @@ jobs: restore-keys: ${{ runner.os }}-rust- - name: cargo test - run: rustup component add rust-src && cargo test --release --all --all-targets --features=runtime-benchmarks --no-fail-fast --verbose --color always + run: | + rustup component add rust-src + cargo test -p ${{ matrix.package }} --release --features=runtime-benchmarks --no-fail-fast --verbose --color always clippy: runs-on: ubuntu-latest @@ -79,7 +107,7 @@ jobs: - name: install dependencies run: sudo apt-get update && sudo apt-get install -y protobuf-compiler libssl-dev - - name: cache + - name: cache rust toolchain and dependencies uses: actions/cache@v4 with: path: | @@ -89,25 +117,6 @@ jobs: restore-keys: ${{ runner.os }}-rust- - name: cargo clippy - run: rustup component add rust-src && cargo clippy --all --no-deps --all-targets --features=runtime-benchmarks -- -D warnings - - # build: - # runs-on: ubuntu-latest - # needs: rustfmt - # steps: - # - name: checkout repository - # uses: actions/checkout@v4.1.1 - # - name: install dependencies - # run: sudo apt-get update && sudo apt-get install -y protobuf-compiler libssl-dev - - # - name: cache - # uses: actions/cache@v4 - # with: - # path: | - # ~/.cargo/ - # target/ - # key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }} - # restore-keys: ${{ runner.os }}-rust- - # - name: cargo build - # run: rustup component add rust-src && cargo build --locked - + run: | + rustup component add rust-src + cargo clippy -p ${{ matrix.package }} --all-targets --features=runtime-benchmarks -- -D warnings