Skip to content

Commit

Permalink
added subalfred to check for missing std, runtime-benchmarking, and t…
Browse files Browse the repository at this point in the history
…ry-runtime dependencies
  • Loading branch information
chexware committed Mar 22, 2024
1 parent 7ff4ae1 commit 5218a74
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
# chopsticks DB
db.sqlite

# subalfred logs
# subalfred
subalfred
# subalfred logs
list

.vscode
*.code-workspace
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
80 changes: 80 additions & 0 deletions scripts/subalfred-check.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5218a74

Please sign in to comment.