-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Github CI: Test CI to reduce build time with concurrency
Signed-off-by: Shreevatsa N <[email protected]>
- Loading branch information
Showing
1 changed file
with
58 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,6 @@ on: | |
paths-ignore: | ||
- "**.md" | ||
- "doc/**" | ||
|
||
# Allows to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
defaults: | ||
|
@@ -47,7 +45,7 @@ jobs: | |
- name: rustfmt | ||
run: cargo +nightly fmt --all -- --check | ||
|
||
test: | ||
clippy: | ||
runs-on: ubuntu-latest | ||
needs: rustfmt | ||
steps: | ||
|
@@ -66,48 +64,68 @@ jobs: | |
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }} | ||
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 | ||
- name: cargo clippy | ||
run: rustup component add rust-src && cargo clippy --all --no-deps --all-targets --features=runtime-benchmarks -- -D warnings | ||
|
||
clippy: | ||
check-runtime-benchmarks: | ||
runs-on: ubuntu-latest | ||
needs: rustfmt | ||
outputs: | ||
packages_with_feature: ${{ steps.set_output_with.outputs.packages_with_feature }} | ||
packages_without_feature: ${{ steps.set_output_without.outputs.packages_without_feature }} | ||
steps: | ||
- name: checkout repository | ||
uses: actions/[email protected] | ||
|
||
- 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 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/[email protected] | ||
# - 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 | ||
- name: Check for runtime-benchmarks feature in packages | ||
id: set_output_with | ||
run: | | ||
echo "Checking for 'runtime-benchmarks' feature in Cargo.toml files..." | ||
packages_with_feature=() | ||
packages_without_feature=() | ||
for cargo_file in $(find . -name "Cargo.toml"); do | ||
if grep -q "\[features\]" "$cargo_file"; then | ||
if grep -q "runtime-benchmarks" "$cargo_file"; then | ||
package_name=$(basename $(dirname "$cargo_file")) | ||
packages_with_feature+=("$package_name") | ||
else | ||
package_name=$(basename $(dirname "$cargo_file")) | ||
packages_without_feature+=("$package_name") | ||
fi | ||
else | ||
package_name=$(basename $(dirname "$cargo_file")) | ||
packages_without_feature+=("$package_name") | ||
fi | ||
done | ||
echo "Packages with runtime-benchmarks feature: ${packages_with_feature[*]}" | ||
echo "Packages without runtime-benchmarks feature: ${packages_without_feature[*]}" | ||
# Set outputs | ||
echo "::set-output name=packages_with_feature::$(IFS=,; echo "${packages_with_feature[*]}")" | ||
echo "::set-output name=packages_without_feature::$(IFS=,; echo "${packages_without_feature[*]}")" | ||
test_with_runtime_benchmarks: | ||
runs-on: ubuntu-latest | ||
needs: [rustfmt, check-runtime-benchmarks] | ||
if: needs.check-runtime-benchmarks.outputs.packages_with_feature != '' | ||
strategy: | ||
matrix: | ||
package: ${{ fromJson('["' + needs.check-runtime-benchmarks.outputs.packages_with_feature + '"]') }} | ||
steps: | ||
- name: Run tests with runtime-benchmarks | ||
run: | | ||
cargo test --release --package "${{ matrix.package }}" --features "runtime-benchmarks" --no-fail-fast | ||
test_without_runtime_benchmarks: | ||
runs-on: ubuntu-latest | ||
needs: [rustfmt, check-runtime-benchmarks] | ||
if: needs.check-runtime-benchmarks.outputs.packages_without_feature != '' | ||
strategy: | ||
matrix: | ||
package: ${{ fromJson('["' + needs.check-runtime-benchmarks.outputs.packages_without_feature + '"]') }} | ||
steps: | ||
- name: Run tests without runtime-benchmarks | ||
run: | | ||
cargo test --release --package "${{ matrix.package }}" --no-fail-fast |