Skip to content

Commit 673fdde

Browse files
committed
ci: migrate running of unit tests from TravisCI to GitHub Actions
Part of #1154
1 parent 862d2ec commit 673fdde

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

.github/workflows/unit-tests.yml

+18
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,21 @@ jobs:
2222
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
2323
- name: Run Jest
2424
run: ./src/main/scripts/execute-command.sh jest
25+
run-unit-tests:
26+
name: Unit Tests (Java)
27+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on
28+
runs-on: ubuntu-20.04
29+
steps:
30+
- name: Clone source code
31+
uses: actions/[email protected] # https://github.com/actions/checkout
32+
with:
33+
# Whether to configure the token or SSH key with the local git config. Default: true
34+
persist-credentials: false
35+
- name: Install JDK
36+
uses: actions/[email protected] # https://github.com/actions/setup-java
37+
with:
38+
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
39+
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
40+
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
41+
- name: Run unit tests
42+
run: ./src/main/scripts/execute-command.sh unit-tests

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

72-
TEST_TIME=0
7371
CODENARC_TIME=0
7472
SPOTBUGS_TIME=0
7573
VERIFY_TIME=0
@@ -104,10 +102,6 @@ if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
104102
if [ "$AFFECTS_POM_XML" = 'no' ]; then
105103
if [ "$AFFECTS_JAVA_FILES" = 'no' ]; then
106104
[ "$AFFECTS_SPOTBUGS_CFG" != 'no' ] || SPOTBUGS_STATUS=skip
107-
108-
if [ "$AFFECTS_GROOVY_FILES" = 'no' ]; then
109-
TEST_STATUS=skip
110-
fi
111105
fi
112106

113107
[ "$AFFECTS_GROOVY_FILES" != 'no' ] || CODENARC_STATUS=skip
@@ -131,13 +125,6 @@ if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
131125

132126
echo
133127

134-
if [ "$TEST_STATUS" != 'skip' ]; then
135-
START_TIME=$SECONDS
136-
"$EXEC_CMD" unit-tests >test.log 2>&1 || TEST_STATUS=fail
137-
TEST_TIME=$((SECONDS - START_TIME))
138-
fi
139-
print_status "$TEST_STATUS" "$TEST_TIME" 'Run unit tests'
140-
141128
if [ "$CODENARC_STATUS" != 'skip' ]; then
142129
START_TIME=$SECONDS
143130
# run after tests for getting compiled sources
@@ -177,7 +164,6 @@ fi
177164
print_status "$DANGER_STATUS" "$DANGER_TIME" 'Run danger'
178165

179166
if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
180-
[ "$TEST_STATUS" = 'skip' ] || print_log test.log 'Run unit tests'
181167
[ "$CODENARC_STATUS" = 'skip' ] || print_log codenarc.log 'Run CodeNarc'
182168
[ "$SPOTBUGS_STATUS" = 'skip' ] || print_log spotbugs.log 'Run SpotBugs'
183169
[ "$ANSIBLE_LINT_STATUS" = 'skip' ] || print_log ansible_lint.log 'Run Ansible Lint'
@@ -189,8 +175,8 @@ if [ "$DANGER_STATUS" != 'skip' ]; then
189175
print_log danger.log 'Run danger'
190176
fi
191177

192-
rm -f test.log codenarc.log spotbugs.log verify.log danger.log ansible_lint.log
178+
rm -f codenarc.log spotbugs.log verify.log danger.log ansible_lint.log
193179

194-
if echo "$TEST_STATUS$CODENARC_STATUS$SPOTBUGS_STATUS$VERIFY_STATUS$DANGER_STATUS$ANSIBLE_LINT_STATUS" | grep -Fqs 'fail'; then
180+
if echo "$CODENARC_STATUS$SPOTBUGS_STATUS$VERIFY_STATUS$DANGER_STATUS$ANSIBLE_LINT_STATUS" | grep -Fqs 'fail'; then
195181
exit 1
196182
fi

0 commit comments

Comments
 (0)