-
Notifications
You must be signed in to change notification settings - Fork 175
200 lines (181 loc) · 7.78 KB
/
core.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: core
on:
push:
branches: [main]
paths:
- 'constraintlayout/**.java'
- 'constraintlayout/**.kt'
- 'constraintlayout/**.xml'
- 'constraintlayout/**.gradle'
pull_request:
paths:
- '.github/workflows/core.yml'
- 'constraintlayout/**.java'
- 'constraintlayout/**.kt'
- 'constraintlayout/**.xml'
- 'constraintlayout/**.gradle'
defaults:
run:
working-directory: ./constraintlayout
env:
OUT_DIR: "/tmp/out"
DIST_DIR: "/tmp/out/dist"
GRADLE_HOME: ${{ github.workspace }}/gradle-home
jobs:
assemble:
name: Assemble
runs-on: macos-latest
steps:
# These setup steps should be common across all jobs in this workflow.
- name: Checkout
uses: actions/checkout@v2
- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 1.11
uses: actions/setup-java@v1
with:
java-version: 1.11
## Caching
- name: Cache gradle dependencies
uses: actions/cache@v2
with:
path: ${{ env.GRADLE_HOME }}/caches
# Include the SHA in the hash so this step always adds a cache entry. If we didn't use the SHA, the artifacts
# would only get cached once for each build config hash.
# Don't use ${{ runner.os }} in the key so we don't re-assemble for UI tests.
key: gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/buildSrc/**') }}-${{ github.sha }}
# The first time a SHA is assembled, we still want to load dependencies from the cache.
# Note that none of jobs dependent on this one need restore keys, since they'll always have an exact hit.
restore-keys: |
gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/buildSrc/**') }}-
# We want to keep the dependencies from the cache, but clear out the build cache which contains the actual
# compiled artifacts from this project. This ensures we don't run into any issues with stale cache entries,
# and that the resulting cache we upload for the other jobs won't waste any space on stale binaries.
# A simpler approach would be simply to delete the build-cache before uploading the cache archive, however
# if we did that in this job it would defeat the purpose of sharing that directory with dependent jobs,
# and there's no way to modify the cache after the job that created it finishes.
- name: Clean gradle build cache to assemble fresh
run: |
ls -lhrt "$GRADLE_HOME/caches" || true
rm -rf "$GRADLE_HOME/caches/build-cache-1"
ls -lhrt "$GRADLE_HOME/caches" || true
- name: Assemble with gradle
run: ./gradlew assemble --build-cache --no-daemon --stacktrace --gradle-user-home "$GRADLE_HOME"
# Runs all check tasks in parallel.
test:
name: Unit Tests
needs: assemble
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 1.11
uses: actions/setup-java@v1
with:
java-version: 1.11
## Caching
- name: Cache build artifacts
uses: actions/cache@v2
with:
path: ${{ env.GRADLE_HOME }}/caches
# Don't set restore-keys so cache is always only valid for the current build config.
# Also don't use ${{ runner.os }} in the key so we don't re-assemble for UI tests.
key: gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/buildSrc/**') }}-${{ github.sha }}
## Actual task
- name: Run tests
run: ./gradlew test --build-cache --no-daemon --stacktrace --gradle-user-home "$GRADLE_HOME"
- name: Core Test Report
if: ${{ always() }}
uses: mikepenz/action-junit-report@v2.9.0
with:
report_paths: '${{ github.workspace }}/constraintlayout/core/build/test-results/test/TEST-*.xml'
compose-androidTest:
name: Compose instrumentation tests
needs: assemble
runs-on: macos-latest
strategy:
matrix:
api-level: [30]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 1.11
uses: actions/setup-java@v1
with:
java-version: 1.11
## Caching
- name: Cache build artifacts
uses: actions/cache@v2
with:
path: ${{ env.GRADLE_HOME }}/caches
# Don't set restore-keys so cache is always only valid for the current build config.
# Also don't use ${{ runner.os }} in the key so we don't re-assemble for UI tests.
key: gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/buildSrc/**') }}-${{ github.sha }}
- name: AVD cache
uses: actions/cache@v2
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: google_apis
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
## Actual task
- name: Compose Instrumentation Tests
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: ./constraintlayout
api-level: ${{ matrix.api-level }}
target: google_apis
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: ./gradlew :compose:connectedCheck --build-cache --no-daemon --stacktrace --gradle-user-home "$GRADLE_HOME"
- name: Upload results
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: instrumentation-test-results
path: ${{ github.workspace }}/constraintlayout/compose/build/reports/androidTests/connected/**
- name: Compose AndroidTest Report
if: ${{ always() }}
uses: mikepenz/action-junit-report@v2.9.0
with:
report_paths: '${{ github.workspace }}/constraintlayout/compose/build/outputs/androidTest-results/connected/TEST-*.xml'
lint:
name: Lint
needs: assemble
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 1.11
uses: actions/setup-java@v1
with:
java-version: 1.11
## Caching
- name: Cache build artifacts
uses: actions/cache@v2
with:
path: ${{ env.GRADLE_HOME }}/caches
# Don't set restore-keys so cache is always only valid for the current build config.
# Also don't use ${{ runner.os }} in the key so we don't re-assemble for UI tests.
key: gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/buildSrc/**') }}-${{ github.sha }}
## Actual task
- name: Run tests
run: ./gradlew lint --build-cache --no-daemon --stacktrace --gradle-user-home "$GRADLE_HOME"