Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
revert hardcoded crates_per_group
  • Loading branch information
joao-paulo-parity committed Nov 17, 2022
commit 56d29482fd55f515a9e6e8c656dcd32ee9961f2c
20 changes: 8 additions & 12 deletions scripts/ci/gitlab/check-each-crate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,14 @@ readarray -t workspace_crates < <(\

crates_total=${#workspace_crates[*]}

if [ "$crates_total" -le "$groups_total" ]; then
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
# 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) ))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the > 0 doing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment in 53f28d5


group=1
for ((i=0; i < crates_total; i += crates_per_group)); do
Expand Down