-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import some scripts from other repositories #86
Closed
joao-paulo-parity
wants to merge
5
commits into
paritytech:master
from
joao-paulo-parity:check-each-crate
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5718309
add check-each-crate script
joao-paulo-parity 7dd9a87
add create-benchmark-pr.sh script
joao-paulo-parity 668ae63
adjust for review comment https://github.com/paritytech/pipeline-scri…
joao-paulo-parity b8a27a7
adjust for review comment https://github.com/paritytech/pipeline-scri…
joao-paulo-parity 3d890c8
adjust for review comment https://github.com/paritytech/pipeline-scri…
joao-paulo-parity File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env bash | ||
|
||
## A script that runs "cargo check" for 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. | ||
## Crates are partitioned into groups based on $target_group and $groups_total, | ||
## where each group has ($crates_total / $groups_total) crates within it. Those | ||
## groups can be used in parallel for speeding up the checks' overall time to | ||
## completion while minimizing redundant work between runners. | ||
## For example usage within GitLab CI, see: | ||
## https://github.com/paritytech/substrate/blob/f80c370cdce7c996e8bf8710b6522dac639fbab0/scripts/ci/gitlab/pipeline/test.yml#L427 | ||
|
||
set -Eeu -o pipefail | ||
shopt -s inherit_errexit | ||
|
||
set -vx | ||
|
||
# $target_group is the number of the group to be executed in this run, from | ||
# 1..$groups_total (inclusive) | ||
target_group="$1" | ||
# $groups_total is the total amount of groups | ||
groups_total="$2" | ||
|
||
readarray -t workspace_crates < <(\ | ||
cargo tree --workspace --depth 0 --prefix none | | ||
awk '{ if (length($1) == 0 || substr($1, 1, 1) == "[") { skip } else { print $1 } }' | | ||
sort | | ||
uniq | ||
) | ||
|
||
crates_total=${#workspace_crates[*]} | ||
if [ "$crates_total" -lt 1 ]; then | ||
>&2 echo "No crates detected for $PWD" | ||
exit 1 | ||
fi | ||
|
||
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 | ||
crates_in_group=("${workspace_crates[@]:$i:$crates_per_group}") | ||
echo "crates in the group: ${crates_in_group[*]}" >/dev/null # >/dev/null due to "set -x" | ||
for crate in "${crates_in_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env bash | ||
|
||
## A script that generates a link to the weights comparison tool, then creates a | ||
## PR with the generated link in its description. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would be cool to add info where is it used (integrated) and why. How people get the link to PR or how is it used overall |
||
## Its usage started in Cumulus to create a PR for updating weights generated from CI jobs: | ||
## https://github.com/paritytech/cumulus/blob/e4855e352f972f59a2d5941d7bce2d5174ab34ee/scripts/ci/gitlab/pipeline/benchmarks.yml#L31 | ||
## See https://github.com/paritytech/cumulus/pull/1789 for an example of using it. | ||
|
||
set -Eeu -o pipefail | ||
shopt -s inherit_errexit | ||
|
||
PR_TITLE="$1" | ||
HEAD_REF="$2" | ||
|
||
ORG="{ORG:-paritytech}" | ||
REPO="$CI_PROJECT_NAME" | ||
BASE_REF="$CI_COMMIT_BRANCH" | ||
# Change threshold in %. Bigger values excludes the small changes. | ||
THRESHOLD=${THRESHOLD:-30} | ||
|
||
WEIGHTS_COMPARISON_URL_PARTS=( | ||
"https://weights.tasty.limo/compare?" | ||
"repo=$REPO&" | ||
"threshold=$THRESHOLD&" | ||
"path_pattern=**%2Fweights%2F*.rs&" | ||
"method=guess-worst&" | ||
"ignore_errors=true&" | ||
"unit=time&" | ||
"old=$BASE_REF&" | ||
"new=$HEAD_REF" | ||
) | ||
printf -v WEIGHTS_COMPARISON_URL %s "${WEIGHTS_COMPARISON_URL_PARTS[@]}" | ||
|
||
PAYLOAD="$(jq -n \ | ||
--arg title "$PR_TITLE" \ | ||
--arg body " | ||
This PR is generated automatically by CI. | ||
|
||
Compare the weights with \`$BASE_REF\`: $WEIGHTS_COMPARISON_URL | ||
|
||
- [ ] Backport to master and node release branch once merged | ||
" \ | ||
--arg base "$BASE_REF" \ | ||
--arg head "$HEAD_REF" \ | ||
'{ | ||
title: $title, | ||
body: $body, | ||
head: $head, | ||
base: $base | ||
}' | ||
)" | ||
|
||
echo "PAYLOAD: $PAYLOAD" | ||
|
||
curl \ | ||
-H "Authorization: token $GITHUB_TOKEN" \ | ||
-X POST \ | ||
-d "$PAYLOAD" \ | ||
"https://api.github.com/repos/$ORG/$REPO/pulls" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please describe how the target group look like? so it's a bit more clear how to test this e.g. the context you run it and examples of where you get these groups