Skip to content

Commit 4e8e271

Browse files
committed
ci: migrate checking by CodeNarc from TravisCI to GitHub Actions
Part of #1154
1 parent 673fdde commit 4e8e271

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

.github/workflows/static-analysis.yml

+20
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,23 @@ jobs:
160160
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
161161
- name: Run maven-enforcer-plugin
162162
run: ./src/main/scripts/execute-command.sh enforcer
163+
run-codenarc:
164+
name: Run CodeNarc
165+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on
166+
runs-on: ubuntu-20.04
167+
steps:
168+
- name: Clone source code
169+
uses: actions/[email protected] # https://github.com/actions/checkout
170+
with:
171+
# Whether to configure the token or SSH key with the local git config. Default: true
172+
persist-credentials: false
173+
- name: Install JDK
174+
uses: actions/[email protected] # https://github.com/actions/setup-java
175+
with:
176+
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
177+
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
178+
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
179+
- name: Compile sources
180+
run: mvn compile
181+
- name: Run CodeNarc
182+
run: ./src/main/scripts/execute-command.sh codenarc

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

+2-16
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-
CODENARC_STATUS=
6261
SPOTBUGS_STATUS=
6362
VERIFY_STATUS=
6463
ANSIBLE_LINT_STATUS=
@@ -68,7 +67,6 @@ if [ "${SPRING_PROFILES_ACTIVE:-}" = 'travis' ] && [ "${TRAVIS_PULL_REQUEST:-fal
6867
DANGER_STATUS=
6968
fi
7069

71-
CODENARC_TIME=0
7270
SPOTBUGS_TIME=0
7371
VERIFY_TIME=0
7472
ANSIBLE_LINT_TIME=0
@@ -96,15 +94,12 @@ if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
9694
AFFECTS_TRAVIS_CFG="$(echo "$MODIFIED_FILES" | grep -Fxq '.travis.yml' || echo 'no')"
9795
AFFECTS_SPOTBUGS_CFG="$(echo "$MODIFIED_FILES" | grep -q 'spotbugs-filter\.xml$' || echo 'no')"
9896
AFFECTS_JAVA_FILES="$(echo "$MODIFIED_FILES" | grep -q '\.java$' || echo 'no')"
99-
AFFECTS_GROOVY_FILES="$(echo "$MODIFIED_FILES" | grep -q '\.groovy$' || echo 'no')"
10097
AFFECTS_PLAYBOOKS="$(echo "$MODIFIED_FILES" | grep -Eq '(vagrant|prod|deploy|bootstrap|/roles/.+)\.yml$' || echo 'no')"
10198

10299
if [ "$AFFECTS_POM_XML" = 'no' ]; then
103100
if [ "$AFFECTS_JAVA_FILES" = 'no' ]; then
104101
[ "$AFFECTS_SPOTBUGS_CFG" != 'no' ] || SPOTBUGS_STATUS=skip
105102
fi
106-
107-
[ "$AFFECTS_GROOVY_FILES" != 'no' ] || CODENARC_STATUS=skip
108103
fi
109104

110105
if [ "$AFFECTS_TRAVIS_CFG" = 'no' ]; then
@@ -125,14 +120,6 @@ if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
125120

126121
echo
127122

128-
if [ "$CODENARC_STATUS" != 'skip' ]; then
129-
START_TIME=$SECONDS
130-
# run after tests for getting compiled sources
131-
"$EXEC_CMD" codenarc >codenarc.log 2>&1 || CODENARC_STATUS=fail
132-
CODENARC_TIME=$((SECONDS - START_TIME))
133-
fi
134-
print_status "$CODENARC_STATUS" "$CODENARC_TIME" 'Run CodeNarc'
135-
136123
if [ "$SPOTBUGS_STATUS" != 'skip' ]; then
137124
START_TIME=$SECONDS
138125
# run after tests for getting compiled sources
@@ -164,7 +151,6 @@ fi
164151
print_status "$DANGER_STATUS" "$DANGER_TIME" 'Run danger'
165152

166153
if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
167-
[ "$CODENARC_STATUS" = 'skip' ] || print_log codenarc.log 'Run CodeNarc'
168154
[ "$SPOTBUGS_STATUS" = 'skip' ] || print_log spotbugs.log 'Run SpotBugs'
169155
[ "$ANSIBLE_LINT_STATUS" = 'skip' ] || print_log ansible_lint.log 'Run Ansible Lint'
170156
fi
@@ -175,8 +161,8 @@ if [ "$DANGER_STATUS" != 'skip' ]; then
175161
print_log danger.log 'Run danger'
176162
fi
177163

178-
rm -f codenarc.log spotbugs.log verify.log danger.log ansible_lint.log
164+
rm -f spotbugs.log verify.log danger.log ansible_lint.log
179165

180-
if echo "$CODENARC_STATUS$SPOTBUGS_STATUS$VERIFY_STATUS$DANGER_STATUS$ANSIBLE_LINT_STATUS" | grep -Fqs 'fail'; then
166+
if echo "$SPOTBUGS_STATUS$VERIFY_STATUS$DANGER_STATUS$ANSIBLE_LINT_STATUS" | grep -Fqs 'fail'; then
181167
exit 1
182168
fi

0 commit comments

Comments
 (0)