aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/ban-imports.yaml
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-01-13 20:45:45 +0100
committerGitHub <noreply@github.com>2024-01-13 20:45:45 +0100
commit4c3b896787d07b84c895a89f49f5dec4f42f0b31 (patch)
treeadaa0051591da12fd1a6553923e6cc54da434a42 /.github/workflows/ban-imports.yaml
parentf71f3c54ecec48f832e96b6c9a9d67e5874f2a44 (diff)
downloadskyhanni-4c3b896787d07b84c895a89f49f5dec4f42f0b31.tar.gz
skyhanni-4c3b896787d07b84c895a89f49f5dec4f42f0b31.tar.bz2
skyhanni-4c3b896787d07b84c895a89f49f5dec4f42f0b31.zip
Internal: Ban imports (#595)
Added options to ban specific imports in some packages. #595
Diffstat (limited to '.github/workflows/ban-imports.yaml')
-rw-r--r--.github/workflows/ban-imports.yaml23
1 files changed, 23 insertions, 0 deletions
diff --git a/.github/workflows/ban-imports.yaml b/.github/workflows/ban-imports.yaml
new file mode 100644
index 000000000..2d0020c85
--- /dev/null
+++ b/.github/workflows/ban-imports.yaml
@@ -0,0 +1,23 @@
+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: |
+ while IFS=' ' read search banned; do
+ echo Banning $banned from $search
+ grep -nrE -- "import $banned" src/main/java/"$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/#.*//;/^$/d')
+ found=$(wc -l temp|cut -d ' ' -f 1)
+ echo Found "$found" invalid imports. Check the files tab for more information.
+ if [[ "$found" -ne 0 ]]; then
+ exit 1
+ fi