-
Notifications
You must be signed in to change notification settings - Fork 8
136 lines (130 loc) · 4.7 KB
/
checks.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
134
135
136
name: Checks
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches: [master, develop]
jobs:
code-style:
name: "Code Style"
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Find PR Base Commit
id: vars
run: |
git fetch origin develop
echo "::set-output name=branchBaseCommit::$(git merge-base origin/develop HEAD)"
- name: XML of changed files
run: |
curl -s -L https://github.com/ByteHamster/android-xml-formatter/releases/download/1.1.0/android-xml-formatter.jar > android-xml-formatter.jar
git diff --name-only ${{ steps.vars.outputs.branchBaseCommit }} --diff-filter=AM | { grep "res/layout/" || true; } | xargs java -jar android-xml-formatter.jar
test $(git diff | wc -l) -eq 0 || (echo -e "\n\n===== Found XML code style violations! See output below how to fix them. =====\n\n" && git --no-pager diff --color=always && false)
wrapper-validation:
name: "Gradle Wrapper Validation"
needs: code-style
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
static-analysis:
name: "Static Code Analysis"
needs: code-style
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
- name: Lint :app module recursively
run: ./gradlew :app:lintPlayRelease
# - name: SpotBugs
# run: ./gradlew spotbugsPlayDebug spotbugsDebug 2>&1 | grep -i "spotbugs"
unit-test:
name: "Unit Test: ${{ matrix.variant }}"
needs: code-style
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
matrix:
include:
- variant: "PlayDebug"
base-variant: "Debug"
execute-tests: true
upload-artifact: true
- variant: "PlayRelease"
base-variant: "Release"
execute-tests: true
upload-artifact: false
- variant: "FreeRelease"
base-variant: "Release"
execute-tests: false
upload-artifact: false
steps:
- uses: actions/checkout@v3
- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
- name: Create temporary release keystore
run: keytool -noprompt -genkey -v -keystore "app/keystore" -alias alias -storepass password -keypass password -keyalg RSA -validity 10 -dname "CN=podcini.org, OU=dummy, O=dummy, L=dummy, S=dummy, C=US"
- name: Build
run: ./gradlew assemble${{ matrix.variant }}
- name: Test
if: matrix.execute-tests == true
run: ./gradlew test${{ matrix.variant }}UnitTest test${{ matrix.base-variant }}UnitTest
- uses: actions/upload-artifact@v3
if: matrix.upload-artifact == true
with:
name: app-play-debug.apk
path: app/build/outputs/apk/play/debug/app-play-debug.apk
emulator-test:
name: "Emulator Test"
needs: code-style
runs-on: macOS-latest
timeout-minutes: 45
env:
api-level: 30
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
- name: Build with Gradle
run: ./gradlew assemblePlayDebugAndroidTest
- name: Android Emulator test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.api-level }}
target: aosp_atd
channel: canary
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: zsh .github/workflows/runEmulatorTests.sh
- uses: actions/upload-artifact@v3
if: failure()
with:
name: test-report
path: app/build/reports/androidTests/connected/flavors/PLAY/