forked from paritytech/substrate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* check all crates individually It's relevant to check workspace crates individually because otherwise their compilation problems due to feature misconfigurations won't be caught, as exemplified by paritytech#12705 * adapt to lack of multiple macos runners paritytech#12709 (comment) * fix cancel-pipeline-cargo-check-each-crate-macos * fix cargo-check-each-crate-macos again * time command execution * fix YAML anchors * add explanation for rounding division * ensure the minimum of one crate per group * collect artifacts for pipeline stopper * revert hardcoded crates_per_group * re-add crates_per_group=1
- Loading branch information
1 parent
08b559e
commit cfba985
Showing
4 changed files
with
98 additions
and
34 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
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
|
||
## A script that checks each workspace crate individually. | ||
## It's relevant to check workspace crates individually because otherwise their compilation problems | ||
## due to feature misconfigurations won't be caught, as exemplified by | ||
## https://github.com/paritytech/substrate/issues/12705 | ||
|
||
set -Eeu -o pipefail | ||
shopt -s inherit_errexit | ||
|
||
set -x | ||
|
||
target_group="$1" | ||
groups_total="$2" | ||
|
||
readarray -t workspace_crates < <(\ | ||
cargo tree --workspace --depth 0 | \ | ||
awk '{ if (length($1) == 0 || substr($1, 1, 1) == "[") { skip } else { print $1 } }' | ||
) | ||
|
||
crates_total=${#workspace_crates[*]} | ||
|
||
if [ "$crates_total" -lt "$groups_total" ]; then | ||
# `crates_total / groups_total` would result in 0, so round it up to 1 | ||
crates_per_group=1 | ||
else | ||
# We add `crates_total % groups_total > 0` (which evaluates to 1 in case there's a remainder for | ||
# `crates_total % groups_total`) to round UP `crates_total / groups_total` 's | ||
# potentially-fractional result to the nearest integer. Doing that ensures that we'll not miss any | ||
# crate in case `crates_total / groups_total` would normally result in a fractional number, since | ||
# in those cases Bash would round DOWN the result to the nearest integer. For example, if | ||
# `crates_total = 5` and `groups_total = 2`, then `crates_total / groups_total` would round down | ||
# to 2; since the loop below would then step by 2, we'd miss the 5th crate. | ||
crates_per_group=$(( (crates_total / groups_total) + (crates_total % groups_total > 0) )) | ||
fi | ||
|
||
group=1 | ||
for ((i=0; i < crates_total; i += crates_per_group)); do | ||
if [ $group -eq "$target_group" ]; then | ||
for crate in "${workspace_crates[@]:$i:$crates_per_group}"; do | ||
cargo check --locked --release -p "$crate" | ||
done | ||
break | ||
fi | ||
group=$(( group + 1 )) | ||
done |
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
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