-
Notifications
You must be signed in to change notification settings - Fork 3
84 lines (74 loc) · 3.03 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Test
on:
workflow_dispatch:
pull_request:
merge_group:
push:
branches: [ main ]
# Enrich gradle.properties for CI/CD
env:
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3584m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.incremental=false -XX:+UseParallelGC
CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 --warn
jobs:
tests:
name: Runs unit tests
runs-on: ubuntu-latest
# Allow all jobs on main. Just one per PR.
concurrency:
group: ${{ github.ref == 'refs/heads/main' && format('unit-tests-main-{0}', github.sha) || format('unit-tests-{0}', github.ref) }}
cancel-in-progress: true
steps:
# Increase swapfile size to prevent screenshot tests getting terminated
# https://github.com/actions/runner-images/discussions/7188#discussioncomment-6750749
- name: 💽 Increase swapfile size
run: |
sudo swapoff -a
sudo fallocate -l 8G /mnt/swapfile
sudo chmod 600 /mnt/swapfile
sudo mkswap /mnt/swapfile
sudo swapon /mnt/swapfile
sudo swapon --show
- name: ⏬ Checkout with LFS
uses: nschloe/[email protected]
with:
# Ensure we are building the branch and not the branch after being merged on main
# https://github.com/actions/checkout/issues/881
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }}
- name: ☕️ Use JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
- name: Configure gradle
uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
- name: ⚙️ Run unit tests and screenshot tests
run: ./gradlew testDebugUnitTest $CI_GRADLE_ARG_PROPERTIES
- name: 📈Generate kover report and verify coverage
run: ./gradlew :compound:koverHtmlReport :compound:koverXmlReport :compound:koverVerify $CI_GRADLE_ARG_PROPERTIES -Pci-build=true
- name: 🚫 Upload kover failed coverage reports
if: failure()
uses: actions/upload-artifact@v4
with:
name: kover-error-report
path: |
compound/build/reports/kover/verify.err
- name: ✅ Upload kover report (disabled)
if: always()
run: echo "This is now done only once a day, see nightlyReports.yml"
- name: 🚫 Upload test results on error
if: failure()
uses: actions/upload-artifact@v4
with:
name: tests-and-screenshot-tests-results
path: |
**/build/roborazzi/failures/
**/build/reports/tests/*UnitTest/
# https://github.com/codecov/codecov-action
- name: ☂️ Upload coverage reports to codecov
if: always()
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}