aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows
diff options
context:
space:
mode:
Diffstat (limited to '.github/workflows')
-rwxr-xr-x.github/workflows/ban-imports.sh16
-rw-r--r--.github/workflows/ban-imports.yaml14
-rw-r--r--.github/workflows/illegal-imports.txt8
3 files changed, 38 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
+)
diff --git a/.github/workflows/ban-imports.yaml b/.github/workflows/ban-imports.yaml
new file mode 100644
index 00000000..73d71093
--- /dev/null
+++ b/.github/workflows/ban-imports.yaml
@@ -0,0 +1,14 @@
+name: Check banned imports
+on:
+ - pull_request
+ - push
+ - workflow_dispatch
+permissions: {}
+jobs:
+ check-imports:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ name: Checkout code
+ - name: Check imports
+ run: .github/workflows/ban-imports.sh
diff --git a/.github/workflows/illegal-imports.txt b/.github/workflows/illegal-imports.txt
new file mode 100644
index 00000000..bdb7c343
--- /dev/null
+++ b/.github/workflows/illegal-imports.txt
@@ -0,0 +1,8 @@
+# Ban some packages from importing some other packages.
+# Lines starting with # are ignored
+# Every other line needs to be in the format
+# <directory without src/main/java prefix> <illegal import>
+
+io/github/moulberry scala.
+
+