2021-03-25 19:26:26 +08:00
|
|
|
name: Test
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request: {}
|
|
|
|
push:
|
2021-05-07 00:25:34 +08:00
|
|
|
branches: [main, develop]
|
2021-03-25 19:26:26 +08:00
|
|
|
|
2021-09-08 19:03:51 +08:00
|
|
|
# Enrich gradle.properties for CI/CD
|
|
|
|
env:
|
|
|
|
CI_GRADLE_ARG_PROPERTIES: >
|
|
|
|
-Porg.gradle.jvmargs=-Xmx2g
|
|
|
|
-Porg.gradle.parallel=false
|
2022-02-24 17:30:28 +08:00
|
|
|
|
2021-03-25 19:26:26 +08:00
|
|
|
jobs:
|
|
|
|
unit-tests:
|
2021-05-19 23:48:12 +08:00
|
|
|
name: Run Unit Tests
|
2021-03-25 19:26:26 +08:00
|
|
|
runs-on: ubuntu-latest
|
2022-02-24 07:13:30 +08:00
|
|
|
# Allow all jobs on main and develop. Just one per PR.
|
2022-02-24 02:11:46 +08:00
|
|
|
concurrency:
|
2022-02-25 00:31:17 +08:00
|
|
|
group: ${{ github.ref == 'refs/heads/main' && format('unit-tests-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('unit-tests-develop-{0}', github.sha) || format('unit-tests-{0}', github.ref) }}
|
2022-02-24 02:11:46 +08:00
|
|
|
cancel-in-progress: true
|
2021-03-25 19:26:26 +08:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.gradle/caches
|
|
|
|
~/.gradle/wrapper
|
|
|
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-gradle-
|
|
|
|
- name: Run unit tests
|
2021-09-08 19:03:51 +08:00
|
|
|
run: ./gradlew clean test $CI_GRADLE_ARG_PROPERTIES -PallWarningsAsErrors=false --stacktrace
|
2022-03-01 19:42:54 +08:00
|
|
|
- name: Format unit test results
|
|
|
|
if: always()
|
|
|
|
run: python3 ./tools/ci/render_test_output.py unit ./**/build/test-results/**/*.xml
|
2021-09-08 19:03:51 +08:00
|
|
|
- name: Publish Unit Test Results
|
|
|
|
uses: EnricoMi/publish-unit-test-result-action@v1
|
2021-09-24 16:14:57 +08:00
|
|
|
if: always() &&
|
|
|
|
github.event.sender.login != 'dependabot[bot]' &&
|
|
|
|
( github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository )
|
2021-09-08 19:03:51 +08:00
|
|
|
with:
|
|
|
|
files: ./**/build/test-results/**/*.xml
|