-
Notifications
You must be signed in to change notification settings - Fork 39
155 lines (146 loc) · 4.61 KB
/
main.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Build & Test
on:
push:
branches:
- main
pull_request:
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- name: Gradle cache
uses: gradle/gradle-build-action@v2
- name: set up JDK
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'buildSrc/src/main/kotlin/*') }}
- name: Build, lint and spotless
run: ./gradlew spotlessCheck assemble assembleAndroidTest lintDebug
- name: Cleanup Gradle Cache
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
test:
runs-on: macOS-latest
needs: build
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
api-level: [ 29 ]
steps:
- uses: actions/checkout@v2
- name: set up JDK
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'buildSrc/src/main/kotlin/*') }}
- name: Build tests
run: ./gradlew assembleDebugAndroidTest
- name: Run functional tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
sdcard-path-or-size: 50M
profile: Nexus 6P
script: ./gradlew connectedCheck --exclude-task app:connectedCheck
- name: Upload functional test results
if: always()
uses: actions/upload-artifact@v2
with:
name: test-results-functional-${{ matrix.api-level }}
path: "**/build/outputs/*/connected/*.xml"
- name: Cleanup Gradle Cache
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
#
# apk:
# name: Generate and Deploy APK
# runs-on: ubuntu-latest
# needs:
# - test
# steps:
# - name: Checkout Code
# uses: actions/checkout@v2
#
# - name: Set up JDK 11
# uses: actions/setup-java@v1
# with:
# java-version: 11
#
# - name: Build APK
# run: ./gradlew assembleDebug --stacktrace
#
# - name: Generate Hash of New APK
# id: hash_new_apk
# run: |
# apk_hash=$(sha256sum app/sample.apk | awk '{print $1}')
# echo "::set-output name=hash::$apk_hash"
#
# - name: Download Hash of Previous APK
# id: download_hash
# uses: actions/download-artifact@v2
# with:
# name: previous_apk_hash
# path: previous_apk_hash.txt
# if: always()
#
# - name: Compare Hashes
# id: compare_hashes
# run: |
# if [ ! -f "previous_apk_hash.txt" ]; then
# echo "No previous APK hash found. Continuing..."
# elif [ "$(cat previous_apk_hash.txt)" = "${{ steps.hash_new_apk.outputs.hash }}" ]; then
# echo "APK has not changed. Exiting."
# exit 0
# fi
# echo "${{ steps.hash_new_apk.outputs.hash }}" > previous_apk_hash.txt
#
# - name: Rename and Move APK
# run: |
# mv app/build/outputs/apk/debug/app-debug.apk app/sample.apk
#
# - name: Upload APK
# uses: actions/upload-artifact@v2
# with:
# name: sample.apk
# path: app/sample.apk
#
# - name: Create Pull Request
# uses: peter-evans/create-pull-request@v3
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# commit-message: "(General) Update sample APK"
# title: "(General) Update sample APK"
# branch: "apk-update"
# body: |
# This pull request updates the sample APK.
#
# ```
# Version code: ${{ steps.version.outputs.version_code }}
# Version name: ${{ steps.version.outputs.version_name }}
# ```
#
# - name: Clean up artifacts
# if: ${{ always() }}
# run: |
# rm -f previous_apk_hash.txt
# echo "Deleted previous_apk_hash.txt"
# echo "Deleting sample APK..."
# curl -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "${{ github.api_url }}/repos/${{ github.repository }}/actions/artifacts/sample.apk"