Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
add explanation for rounding division
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-paulo-parity committed Nov 16, 2022
1 parent d94857d commit 53f28d5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions scripts/ci/gitlab/check-each-crate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ readarray -t workspace_crates < <(\
)

crates_total=${#workspace_crates[*]}

# 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) ))

group=1
Expand Down

0 comments on commit 53f28d5

Please sign in to comment.