From 5218a74487f3e0db2f3eb014569b4a987a2fa738 Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Fri, 22 Mar 2024 22:41:18 +0000 Subject: [PATCH] added subalfred to check for missing std, runtime-benchmarking, and try-runtime dependencies --- .gitignore | 4 +- Makefile | 4 ++ scripts/subalfred-check.sh | 80 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100755 scripts/subalfred-check.sh diff --git a/.gitignore b/.gitignore index 2abe96ed..a0116955 100644 --- a/.gitignore +++ b/.gitignore @@ -16,8 +16,10 @@ # chopsticks DB db.sqlite -# subalfred logs +# subalfred subalfred +# subalfred logs +list .vscode *.code-workspace diff --git a/Makefile b/Makefile index 72649bdc..898fbe91 100644 --- a/Makefile +++ b/Makefile @@ -95,6 +95,10 @@ run-chopsticks-pioneer: run-chopsticks-pioneer-xcm: npx @acala-network/chopsticks xcm -r kusama -p statemine -p scripts/chopsticks/chopsticks_pioneer.yml +.PHONY: check-missing-std-dependencies +check-missing-std-dependencies: + cargo install subalfred && ./scripts/subalfred-check.sh "benchmarking|frame-try-runtime|frame-std" + GITHOOKS_SRC = $(wildcard githooks/*) GITHOOKS_DEST = $(patsubst githooks/%, .git/hooks/%, $(GITHOOKS_SRC)) diff --git a/scripts/subalfred-check.sh b/scripts/subalfred-check.sh new file mode 100755 index 00000000..13d51ff5 --- /dev/null +++ b/scripts/subalfred-check.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +# Make sure this file is clean before running dir iteration +> list + +if [[ -z $1 ]]; then + echo "Please provide a regex to filter out false positivies" + exit 1 +fi + +for dir in $(ls pallets); do + if [[ $dir == "mock" ]]; then + continue; + fi; + + echo pallets/$dir >> list +done + +for dir in $(ls runtime); do + if [[ $dir == "mock" ]]; then + continue; + fi; + + echo runtime/$dir >> list +done + +ERRORS=false + +echo 🔎 Subalfred feature checks +for dir in $(cat list); do + echo + RESULT=$(subalfred check features $dir) + CHECK_RESULT=$? # 0 if it's good, anything else is bad + + # If subalfred fails with 130||1, then we dont want to proceed with the check + # Its probably cargo error + if [[ $CHECK_RESULT == 130 || $CHECK_RESULT == 1 ]]; then + echo "❌ Subalfred failed to run check features in $dir" + echo "$RESULT" + ERRORS=true + + continue + fi + + # Sanitizing subalfred output + # First line is always "checking: $PATH/Cargo.toml" + RESULT=$(echo "$RESULT" | tail -n+2) + + # Filter out false positives + RESULT_OUTPUT=$(echo "$RESULT" | grep -vE "($1)") + # Trim whitespaces + RESULT_OUTPUT=${RESULT_OUTPUT##*( )} + + # We are checking here if there is anything left in the output after filtering out false positives + if [[ "$RESULT_OUTPUT" == "" ]]; then + echo "✅ $dir" + continue + fi + + echo "$RESULT_OUTPUT" | grep '`std`' > /dev/null + GREP_RESULT=$? # 0 if it's bad, 1 if it's good + + # If result is non empty and there are no std features, then we're yellow + if [[ "$GREP_RESULT" == 1 && "$CHECK_RESULT" != 0 && "$RESULT_OUTPUT" != "" ]]; then + echo "🟡 $dir" + echo -e "$RESULT_OUTPUT" + + # If there are std errors, then we're red + else + echo "❌ $dir" + echo -e "$RESULT_OUTPUT" + ERRORS=true + fi +done + +if [[ $ERRORS == true ]]; then + exit 1 +fi + +rm list \ No newline at end of file