Skip to content

Commit

Permalink
build/ci: add check-forbidden-classes.sh 🚫
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Apr 3, 2024
1 parent 569bc13 commit 14752da
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ jobs:
distribution: zulu
java-version: ${{ matrix.java }}
cache: maven
- run: ./mvnw -V --no-transfer-progress clean package
- name: Run dev mode test
run: ./mvnw -V --no-transfer-progress clean package
if: matrix.java != 17
- run: ./mvnw -V --no-transfer-progress clean package spotbugs:check git-commit-id:validateRevision -DperformRelease
- name: Run release mode test(JDK ${{ matrix.java }})
run: |
./mvnw -V --no-transfer-progress clean package spotbugs:check git-commit-id:validateRevision -DperformRelease
scripts/check-forbidden-classes.sh
if: matrix.java == 17
- name: Check forbidden classes
run: scripts/check-forbidden-classes.sh
if: runner.os == 'Linux'
# https://github.com/marketplace/actions/codecov
- uses: codecov/codecov-action@v4
env:
Expand Down
19 changes: 19 additions & 0 deletions scripts/check-forbidden-classes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -eEuo pipefail

# cd to project root dir
cd "${0%/*}"/..

readonly forbidden_classes=(
javax.annotation.Nullable
javax.annotation.Nonnull
org.jetbrains.annotations.Nullable
org.jetbrains.annotations.NotNull
)

grep_pattern=$(printf '%s\n' "${forbidden_classes[@]}")

grep_options=("$grep_pattern" -F -n -C2 -r src/)
[[ "${GITHUB_ACTIONS:-}" = true || -t 1 ]] && grep_options=("${grep_options[@]}" --color=always)

! grep "${grep_options[@]}"

0 comments on commit 14752da

Please sign in to comment.