Skip to content

Commit ed24277

Browse files
committed
ci: migrate checking by SpotBugs from TravisCI to GitHub Actions
Part of #1154
1 parent aeb81e0 commit ed24277

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

.github/workflows/static-analysis.yml

+25
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,28 @@ jobs:
185185
compile
186186
- name: Run CodeNarc
187187
run: ./src/main/scripts/execute-command.sh codenarc
188+
run-spotbugs:
189+
name: Run SpotBugs
190+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on
191+
runs-on: ubuntu-20.04
192+
steps:
193+
- name: Clone source code
194+
uses: actions/[email protected] # https://github.com/actions/checkout
195+
with:
196+
# Whether to configure the token or SSH key with the local git config. Default: true
197+
persist-credentials: false
198+
- name: Install JDK
199+
uses: actions/[email protected] # https://github.com/actions/setup-java
200+
with:
201+
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
202+
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
203+
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
204+
- name: Compile sources
205+
run: >-
206+
mvn \
207+
--batch-mode \
208+
-Denforcer.skip=true \
209+
-DskipMinify \
210+
compile
211+
- name: Run SpotBugs
212+
run: ./src/main/scripts/execute-command.sh spotbugs

src/main/scripts/ci/check-build-and-verify.sh

+2-22
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ if [ "${1:-}" = '--only-integration-tests' ]; then
5858
RUN_ONLY_INTEGRATION_TESTS=yes
5959
fi
6060

61-
SPOTBUGS_STATUS=
6261
VERIFY_STATUS=
6362
ANSIBLE_LINT_STATUS=
6463

@@ -67,7 +66,6 @@ if [ "${SPRING_PROFILES_ACTIVE:-}" = 'travis' ] && [ "${TRAVIS_PULL_REQUEST:-fal
6766
DANGER_STATUS=
6867
fi
6968

70-
SPOTBUGS_TIME=0
7169
VERIFY_TIME=0
7270
ANSIBLE_LINT_TIME=0
7371
DANGER_TIME=0
@@ -90,18 +88,9 @@ if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
9088
MODIFIED_FILES="$(git --no-pager diff --name-only "$TRAVIS_COMMIT_RANGE" -- 2>/dev/null || :)"
9189

9290
if [ -n "$MODIFIED_FILES" ]; then
93-
AFFECTS_POM_XML="$(echo "$MODIFIED_FILES" | grep -Fxq 'pom.xml' || echo 'no')"
9491
AFFECTS_TRAVIS_CFG="$(echo "$MODIFIED_FILES" | grep -Fxq '.travis.yml' || echo 'no')"
95-
AFFECTS_SPOTBUGS_CFG="$(echo "$MODIFIED_FILES" | grep -q 'spotbugs-filter\.xml$' || echo 'no')"
96-
AFFECTS_JAVA_FILES="$(echo "$MODIFIED_FILES" | grep -q '\.java$' || echo 'no')"
9792
AFFECTS_PLAYBOOKS="$(echo "$MODIFIED_FILES" | grep -Eq '(vagrant|prod|deploy|bootstrap|/roles/.+)\.yml$' || echo 'no')"
9893

99-
if [ "$AFFECTS_POM_XML" = 'no' ]; then
100-
if [ "$AFFECTS_JAVA_FILES" = 'no' ]; then
101-
[ "$AFFECTS_SPOTBUGS_CFG" != 'no' ] || SPOTBUGS_STATUS=skip
102-
fi
103-
fi
104-
10594
if [ "$AFFECTS_TRAVIS_CFG" = 'no' ]; then
10695
if [ "$AFFECTS_PLAYBOOKS" = 'no' ]; then
10796
ANSIBLE_LINT_STATUS=skip
@@ -120,14 +109,6 @@ if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
120109

121110
echo
122111

123-
if [ "$SPOTBUGS_STATUS" != 'skip' ]; then
124-
START_TIME=$SECONDS
125-
# run after tests for getting compiled sources
126-
"$EXEC_CMD" spotbugs >spotbugs.log 2>&1 || SPOTBUGS_STATUS=fail
127-
SPOTBUGS_TIME=$((SECONDS - START_TIME))
128-
fi
129-
print_status "$SPOTBUGS_STATUS" "$SPOTBUGS_TIME" 'Run SpotBugs'
130-
131112
if [ "$ANSIBLE_LINT_STATUS" != 'skip' ]; then
132113
START_TIME=$SECONDS
133114
"$EXEC_CMD" ansible-lint >ansible_lint.log 2>&1 || ANSIBLE_LINT_STATUS=fail
@@ -151,7 +132,6 @@ fi
151132
print_status "$DANGER_STATUS" "$DANGER_TIME" 'Run danger'
152133

153134
if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
154-
[ "$SPOTBUGS_STATUS" = 'skip' ] || print_log spotbugs.log 'Run SpotBugs'
155135
[ "$ANSIBLE_LINT_STATUS" = 'skip' ] || print_log ansible_lint.log 'Run Ansible Lint'
156136
fi
157137

@@ -161,8 +141,8 @@ if [ "$DANGER_STATUS" != 'skip' ]; then
161141
print_log danger.log 'Run danger'
162142
fi
163143

164-
rm -f spotbugs.log verify.log danger.log ansible_lint.log
144+
rm -f verify.log danger.log ansible_lint.log
165145

166-
if echo "$SPOTBUGS_STATUS$VERIFY_STATUS$DANGER_STATUS$ANSIBLE_LINT_STATUS" | grep -Fqs 'fail'; then
146+
if echo "$VERIFY_STATUS$DANGER_STATUS$ANSIBLE_LINT_STATUS" | grep -Fqs 'fail'; then
167147
exit 1
168148
fi

0 commit comments

Comments
 (0)