From b24784d17cbd99757bebbc895430f8b6a2bf19b5 Mon Sep 17 00:00:00 2001 From: Alex Todorov Date: Tue, 20 Dec 2022 20:59:12 +0000 Subject: [PATCH] Add sanity check to tell us if we're using log::warn! directly --- .github/workflows/ci.yml | 4 ++++ scripts/check-usage-of-log-warn.sh | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100755 scripts/check-usage-of-log-warn.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8ef3d4539..2d2aab3517 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,10 @@ jobs: run: | ./scripts/check-parity-bw-extrinsics-benchmarks-weights.sh + - name: Check for direct usage of log::warn vs. warn_or_panic in migrations + run: | + ./scripts/check-usage-of-log-warn.sh + fmt: name: Rustfmt runs-on: ubuntu-latest diff --git a/scripts/check-usage-of-log-warn.sh b/scripts/check-usage-of-log-warn.sh new file mode 100755 index 0000000000..05339a170f --- /dev/null +++ b/scripts/check-usage-of-log-warn.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -xeuo pipefail + +# shellcheck disable=SC2038 +OUTPUT=$(find . -wholename "*/migrations/*.rs" | xargs grep "log::warn" || true) +if [ -n "$OUTPUT" ]; then + echo "FAIL" + echo "$OUTPUT" + exit 1 +fi + +echo "PASS" +exit 0