diff options
author | Linnea Gräf <roman.graef@gmail.com> | 2023-11-11 21:37:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-11 21:37:23 +0100 |
commit | bc501f4eae427ce4ad07b6d78ac9f1f7764ccdb6 (patch) | |
tree | 629f1e6be7854b176ef4d0ea35d6a1c7309fcd74 /.github/workflows/ban-imports.sh | |
parent | f43e45e79d91e15e787545efb8421814318ba2b6 (diff) | |
download | NotEnoughUpdates-bc501f4eae427ce4ad07b6d78ac9f1f7764ccdb6.tar.gz NotEnoughUpdates-bc501f4eae427ce4ad07b6d78ac9f1f7764ccdb6.tar.bz2 NotEnoughUpdates-bc501f4eae427ce4ad07b6d78ac9f1f7764ccdb6.zip |
Add banned imports (#924)
Diffstat (limited to '.github/workflows/ban-imports.sh')
-rwxr-xr-x | .github/workflows/ban-imports.sh | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/.github/workflows/ban-imports.sh b/.github/workflows/ban-imports.sh new file mode 100755 index 00000000..e07d2622 --- /dev/null +++ b/.github/workflows/ban-imports.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +( +basedir="$(cd "$(dirname "$0")"; git rev-parse --show-toplevel)" +cd $basedir +while IFS=' ' read search banned; do + echo "Banning $banned from $search" + grep -nrE -- "import $banned" src/main/{java,kotlin}/"$search"|sed -E 's/^(.*):([0-9]+):(.*)/::error file=\1,line=\2::Illegal \3/g'|tee -a temp +done<<<$(cat .github/workflows/illegal-imports.txt|sed -E 's/#.*//;/^\s*$/d') +found=$(wc -l temp|cut -d ' ' -f 1) +rm -f temp +echo "# Found $found invalid imports. Check the files tab for more information.">>"$GITHUB_STEP_SUMMARY" +if [[ "$found" -ne 0 ]]; then + exit 1 +fi +) |