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 4265b3a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,23 @@ 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
if: matrix.java == 17
# https://github.com/marketplace/actions/codecov
- uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Check forbidden classes
run: scripts/check-forbidden-classes.sh
# https://docs.github.com/en/actions/learn-github-actions/variables#detecting-the-operating-system
if: runner.os != 'Windows'
# https://remarkablemark.org/blog/2017/10/12/check-git-dirty/
- name: Check git dirty
run: |
git status --short
[ -z "$(git status --short)" ]
# https://docs.github.com/en/actions/learn-github-actions/variables#detecting-the-operating-system
if: runner.os != 'Windows'
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 4265b3a

Please sign in to comment.