Files
pezkuwi-subxt/polkadot/scripts/ci/github/verify_updated_weights.sh
T
Martin Pugh b50e512ed4 [CI] Add weights verification jobs (#6996)
* add weights verification job

* switch to a github action

* rename script..

* add swc check

* fix perms...

* debugging

* fix comments, remove artifact. I hate CI

* switch to swc compare files

* sigh

* switch back to compare commits

* fix output

* fix output... again. yay markdown!

* remove test version number

* remove TODO

* switch to docker image

* Revert "remove TODO"

This reverts commit c313afd4604c437ebd25ffa84bb8cc7d95cd1092.

* fix docker registry url

* revert docker experiment

too janky. will fix upstream stuff and fix as a separate PR

reverts commits:

- 3be2043a95f15579453e68ff96360f60aeae24e3
- fd17a0fbf8a75449720fe3861f941f4a91fcc9c7
- 59f0ebfef49e37060cb2dc63cf67c7809befcf57

---------

Co-authored-by: parity-processbot <>
Co-authored-by: Martin <parity@tofu.lan>
2023-04-13 15:28:00 +00:00

56 lines
1.4 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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