-
Notifications
You must be signed in to change notification settings - Fork 198
133 lines (121 loc) · 4 KB
/
run-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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Run Kotlin / Android tests
on:
push:
branches:
- develop
- 'current-stable'
- 'release/*'
paths:
- '**/*.java'
- '**/*.kt'
- '**/*.kts'
pull_request:
paths:
- '**/*.java'
- '**/*.kt'
- '**/*.kts'
workflow_dispatch:
permissions:
contents: read
jobs:
run-unit-tests:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 10 # so that recent tags can be found
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
- name: Set up Node.js environment
uses: actions/setup-node@v3
with:
# Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0
node-version: '20'
- name: Cache gradle dependencies
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.android/build-cache
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Cache test modules
id: cache-test-modules
uses: actions/cache@v3
with:
path: ~/.sword
key: ${{ runner.os }}-test-modules # cache auto-removes if not accessed in 7 days. If data needs to refresh, change key name here (till https://github.com/actions/cache/issues/2 is addressed)
- name: Download test modules if not cached
if: steps.cache-test-modules.outputs.cache-hit != 'true'
run: |
wget ${{ secrets.DOWNLOAD_TEST_MODULES_URL }} -O ./testmods.zip.enc
openssl aes-256-cbc -d -a -pbkdf2 -in ./testmods.zip.enc -out ./testmods.zip -pass 'pass:${{ secrets.TEST_MODULE_ENCRYPTION_KEY }}'
mkdir -p $HOME/.sword
unzip -o -d $HOME/.sword ./testmods.zip
- name: Build with Gradle and run unit tests
run: ./gradlew --console plain testStandardGoogleplayRelease
- name: Upload test results
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: unit-test-results
path: app/build/reports/**/*.html
retention-days: 5
- name: Before saving cache
run: |
rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
rm -fr $HOME/.gradle/caches/*/plugin-resolution/
run-instrument-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 10 # so that recent tags can be found
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
- name: Set up Node.js environment
uses: actions/setup-node@v3
with:
# Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0
node-version: '20'
- name: Cache gradle dependencies
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.android/build-cache
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 31
arch: x86_64
disable-animations: true
disk-size: 1500M
heap-size: 512M
script: ./gradlew --console plain connectedStandardGooglePlayDebugAndroidTest
- name: Upload test results
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: instrument-test-results
path: app/build/reports/**/*.html
retention-days: 5
- name: Before saving cache
run: |
rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
rm -fr $HOME/.gradle/caches/*/plugin-resolution/