This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[CI] Add weights verification jobs #6996
Merged
Merged
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
fda5f66
add weights verification job
s3krit 582db77
switch to a github action
s3krit 58881f9
rename script..
s3krit c028211
Merge remote-tracking branch 'origin/master' into mp-weights-verifica…
6c53276
add swc check
1b9568b
fix perms...
b267e82
debugging
s3krit ff1d4f3
fix comments, remove artifact. I hate CI
s3krit b0e2a97
switch to swc compare files
s3krit 0ce1170
sigh
s3krit 4d4a447
switch back to compare commits
s3krit f3392cd
fix output
s3krit 3ea563f
fix output... again. yay markdown!
s3krit 2dfb6a1
remove test version number
s3krit c313afd
remove TODO
s3krit 59f0ebf
switch to docker image
s3krit fd17a0f
Revert "remove TODO"
s3krit 3be2043
fix docker registry url
s3krit 277c7a3
revert docker experiment
s3krit 949ba87
Merge remote-tracking branch 'origin/master' into mp-weights-verifica…
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,51 @@ | ||
name: Check updated weights | ||
|
||
on: | ||
pull_request: | ||
# uncomment before merging | ||
# paths: | ||
# - 'runtime/*/src/weights/' | ||
|
||
jobs: | ||
check_weights_files: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
runtime: [westend, kusama, polkadot, rococo] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
- name: Check weights files | ||
shell: bash | ||
run: | | ||
scripts/ci/github/verify_updated_weights.sh ${{ matrix.runtime }} | ||
|
||
# This job uses https://github.com/ggwpez/substrate-weight-compare to compare the weights of the current | ||
# release with the last release, then adds them as a comment to the PR. | ||
check_weight_changes: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
runtime: [westend, kusama, polkadot, rococo] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get latest release | ||
run: | | ||
LAST_RELEASE=$(curl -s https://api.github.com/repos/paritytech/polkadot/releases/latest | jq -r .tag_name) | ||
echo "LAST_RELEASE=$LAST_RELEASE" >> $GITHUB_ENV | ||
- name: Checkout current sources | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: addnab/docker-run-action@v3 | ||
with: | ||
image: ghcr.io/ggwpez/swc:sha-30d1cd6 | ||
options: -v ${{ github.workspace }}:/polkadot -w /polkadot | ||
run: | | ||
/polkadot/scripts/ci/github/check_weights_swc.sh ${{ matrix.runtime }} "$LAST_RELEASE" | tee /polkadot/swc_output_${{ matrix.runtime }}.md | ||
- name: Add comment | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
filePath: ./swc_output_${{ matrix.runtime }}.md | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,20 @@ | ||
#!/usr/bin/env bash | ||
# Need to set globstar for ** magic | ||
shopt -s globstar | ||
|
||
RUNTIME=$1 | ||
VERSION=$2 | ||
echo "<details>" | ||
echo "<summary>Weight changes for $RUNTIME</summary>" | ||
echo | ||
swc compare commits \ | ||
--method asymptotic \ | ||
--offline \ | ||
--path-pattern "./runtime/$RUNTIME/src/weights/**/*.rs" \ | ||
--no-color \ | ||
--format markdown \ | ||
--strip-path-prefix "runtime/$RUNTIME/src/weights/" \ | ||
"$VERSION" | ||
#--ignore-errors | ||
echo | ||
echo "</details>" |
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,56 @@ | ||
#!/bin/bash | ||
|
||
ROOT="$(dirname "$0")/../../.." | ||
RUNTIME="$1" | ||
|
||
# If we're on a mac, use gdate for date command (requires coreutils installed via brew) | ||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
DATE="gdate" | ||
else | ||
DATE="date" | ||
fi | ||
|
||
function check_date() { | ||
# Get the dates as input arguments | ||
LAST_RUN="$1" | ||
TODAY="$($DATE +%Y-%m-%d)" | ||
# Calculate the date two days before today | ||
CUTOFF=$($DATE -d "$TODAY - 2 days" +%Y-%m-%d) | ||
|
||
if [[ "$LAST_RUN" > "$CUTOFF" ]]; then | ||
return 0 | ||
else | ||
return 1 | ||
fi | ||
} | ||
|
||
check_weights(){ | ||
FILE=$1 | ||
CUR_DATE=$2 | ||
DATE_REGEX='[0-9]{4}-[0-9]{2}-[0-9]{2}' | ||
LAST_UPDATE="$(grep -E "//! DATE: $DATE_REGEX" "$FILE" | sed -r "s/.*DATE: ($DATE_REGEX).*/\1/")" | ||
# If the file does not contain a date, flag it as an error. | ||
if [ -z "$LAST_UPDATE" ]; then | ||
echo "Skipping $FILE, no date found." | ||
return 0 | ||
fi | ||
if ! check_date "$LAST_UPDATE" ; then | ||
echo "ERROR: $FILE was not updated for the current date. Last update: $LAST_UPDATE" | ||
return 1 | ||
fi | ||
# echo "OK: $FILE" | ||
} | ||
|
||
echo "Checking weights for $RUNTIME" | ||
CUR_DATE="$(date +%Y-%m-%d)" | ||
HAS_ERROR=0 | ||
for FILE in "$ROOT"/runtime/"$RUNTIME"/src/weights/*.rs; do | ||
if ! check_weights "$FILE" "$CUR_DATE"; then | ||
HAS_ERROR=1 | ||
fi | ||
done | ||
|
||
if [ $HAS_ERROR -eq 1 ]; then | ||
echo "ERROR: One or more weights files were not updated during the last benchmark run. Check the logs above." | ||
exit 1 | ||
fi |
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.
One thing that comes to my mind is that we probably also want this in cumulus, so could be that the scripts could also live in https://github.com/paritytech/pipeline-scripts/
Although on the other hand we should "soon" have our monorepo, in which case it needs to be shuffled around anyway.