Skip to content

Commit

Permalink
ci: migrate running of unit tests from TravisCI to GitHub Actions
Browse files Browse the repository at this point in the history
Part of #1154
  • Loading branch information
php-coder committed Dec 3, 2022
1 parent 862d2ec commit 673fdde
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,21 @@ jobs:
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
- name: Run Jest
run: ./src/main/scripts/execute-command.sh jest
run-unit-tests:
name: Unit Tests (Java)
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on
runs-on: ubuntu-20.04
steps:
- name: Clone source code
uses: actions/[email protected] # https://github.com/actions/checkout
with:
# Whether to configure the token or SSH key with the local git config. Default: true
persist-credentials: false
- name: Install JDK
uses: actions/[email protected] # https://github.com/actions/setup-java
with:
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
- name: Run unit tests
run: ./src/main/scripts/execute-command.sh unit-tests
18 changes: 2 additions & 16 deletions src/main/scripts/ci/check-build-and-verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ if [ "${1:-}" = '--only-integration-tests' ]; then
RUN_ONLY_INTEGRATION_TESTS=yes
fi

TEST_STATUS=
CODENARC_STATUS=
SPOTBUGS_STATUS=
VERIFY_STATUS=
Expand All @@ -69,7 +68,6 @@ if [ "${SPRING_PROFILES_ACTIVE:-}" = 'travis' ] && [ "${TRAVIS_PULL_REQUEST:-fal
DANGER_STATUS=
fi

TEST_TIME=0
CODENARC_TIME=0
SPOTBUGS_TIME=0
VERIFY_TIME=0
Expand Down Expand Up @@ -104,10 +102,6 @@ if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
if [ "$AFFECTS_POM_XML" = 'no' ]; then
if [ "$AFFECTS_JAVA_FILES" = 'no' ]; then
[ "$AFFECTS_SPOTBUGS_CFG" != 'no' ] || SPOTBUGS_STATUS=skip

if [ "$AFFECTS_GROOVY_FILES" = 'no' ]; then
TEST_STATUS=skip
fi
fi

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

echo

if [ "$TEST_STATUS" != 'skip' ]; then
START_TIME=$SECONDS
"$EXEC_CMD" unit-tests >test.log 2>&1 || TEST_STATUS=fail
TEST_TIME=$((SECONDS - START_TIME))
fi
print_status "$TEST_STATUS" "$TEST_TIME" 'Run unit tests'

if [ "$CODENARC_STATUS" != 'skip' ]; then
START_TIME=$SECONDS
# run after tests for getting compiled sources
Expand Down Expand Up @@ -177,7 +164,6 @@ fi
print_status "$DANGER_STATUS" "$DANGER_TIME" 'Run danger'

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

rm -f test.log codenarc.log spotbugs.log verify.log danger.log ansible_lint.log
rm -f codenarc.log spotbugs.log verify.log danger.log ansible_lint.log

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

0 comments on commit 673fdde

Please sign in to comment.