Skip to content

Commit fcb3125

Browse files
Merge pull request #733 from square/sedwards/report-drawn
Report Fully Drawn from PerformancePoetryActivity
2 parents 9a133c4 + 9e3503a commit fcb3125

File tree

5 files changed

+112
-106
lines changed

5 files changed

+112
-106
lines changed

.github/workflows/kotlin.yml

Lines changed: 97 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
name: Kotlin CI
1+
name : Kotlin CI
22

3-
on:
4-
push:
5-
branches:
3+
on :
4+
push :
5+
branches :
66
- main
7-
pull_request:
8-
paths-ignore:
7+
pull_request :
8+
paths-ignore :
99
# Don't build the entire app when just changing tutorials, which have their own workflow.
1010
- 'samples/tutorial/**'
1111

12-
jobs:
12+
jobs :
1313

14-
cancel-stale-jobs:
15-
runs-on: ubuntu-latest
16-
steps:
14+
cancel-stale-jobs :
15+
runs-on : ubuntu-latest
16+
steps :
1717
# If CI is already running for a branch when that branch is updated, cancel the older jobs.
18-
- name: Cancel Stale Jobs
19-
uses: styfle/[email protected]
20-
env:
21-
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
22-
23-
dokka:
24-
name: Assemble & Dokka
25-
runs-on: ubuntu-latest
26-
timeout-minutes: 20
27-
steps:
28-
- uses: actions/checkout@v2
29-
- name: set up JDK 11.0.7
30-
uses: actions/setup-java@v1
31-
with:
32-
java-version: 11.0.7
18+
- name : Cancel Stale Jobs
19+
uses : styfle/[email protected]
20+
env :
21+
GITHUB_TOKEN : '${{ secrets.GITHUB_TOKEN }}'
22+
23+
dokka :
24+
name : Assemble & Dokka
25+
runs-on : ubuntu-latest
26+
timeout-minutes : 20
27+
steps :
28+
- uses : actions/checkout@v2
29+
- name : set up JDK 11.0.7
30+
uses : actions/setup-java@v1
31+
with :
32+
java-version : 11.0.7
3333

3434
## Actual task
3535
- uses : burrunan/gradle-cache-action@v1
@@ -59,17 +59,17 @@ jobs:
5959
gradle-distribution-sha-256-sum-warning : false
6060

6161
# These are all pretty quick so we run them on a single shard. Fewer shards, less queueing.
62-
check:
63-
name: Check
64-
runs-on: ubuntu-latest
65-
timeout-minutes: 20
66-
steps:
67-
- uses: actions/checkout@v2
68-
- uses: gradle/wrapper-validation-action@v1
69-
- name: set up JDK 11.0.7
70-
uses: actions/setup-java@v1
71-
with:
72-
java-version: 11.0.7
62+
check :
63+
name : Check
64+
runs-on : ubuntu-latest
65+
timeout-minutes : 20
66+
steps :
67+
- uses : actions/checkout@v2
68+
- uses : gradle/wrapper-validation-action@v1
69+
- name : set up JDK 11.0.7
70+
uses : actions/setup-java@v1
71+
with :
72+
java-version : 11.0.7
7373

7474
## Actual task
7575
- uses : burrunan/gradle-cache-action@v1
@@ -83,24 +83,24 @@ jobs:
8383
gradle-build-scan-report : false
8484
gradle-distribution-sha-256-sum-warning : false
8585

86-
instrumentation-tests:
87-
name: Instrumentation tests
88-
runs-on: macos-latest
89-
timeout-minutes: 45
90-
strategy:
86+
instrumentation-tests :
87+
name : Instrumentation tests
88+
runs-on : macos-latest
89+
timeout-minutes : 45
90+
strategy :
9191
# Allow tests to continue on other devices if they fail on one device.
92-
fail-fast: false
93-
matrix:
94-
api-level:
92+
fail-fast : false
93+
matrix :
94+
api-level :
9595
- 29
9696
# Unclear that older versions actually honor command to disable animation.
9797
# Newer versions are reputed to be too slow: https://github.com/ReactiveCircus/android-emulator-runner/issues/222
98-
steps:
99-
- uses: actions/checkout@v2
100-
- name: set up JDK 11.0.7
101-
uses: actions/setup-java@v1
102-
with:
103-
java-version: 11.0.7
98+
steps :
99+
- uses : actions/checkout@v2
100+
- name : set up JDK 11.0.7
101+
uses : actions/setup-java@v1
102+
with :
103+
java-version : 11.0.7
104104

105105
## Build before running tests, using cache.
106106
- uses : burrunan/gradle-cache-action@v1
@@ -115,69 +115,66 @@ jobs:
115115
gradle-distribution-sha-256-sum-warning : false
116116

117117
## Actual task
118-
- name: Instrumentation Tests
119-
uses: reactivecircus/android-emulator-runner@v2
120-
with:
118+
- name : Instrumentation Tests
119+
uses : reactivecircus/android-emulator-runner@v2
120+
with :
121121
# @ychescale9 suspects Galaxy Nexus is the fastest one
122-
profile: Galaxy Nexus
123-
api-level: ${{ matrix.api-level }}
124-
arch: x86_64
122+
profile : Galaxy Nexus
123+
api-level : ${{ matrix.api-level }}
124+
arch : x86_64
125125
# Skip the benchmarks as this is running on emulators
126-
script: ./gradlew connectedCheck -x :benchmarks:dungeon-benchmark:connectedCheck -x :benchmarks:performance-poetry:complex-benchmark:connectedCheck --no-daemon --stacktrace
126+
script : ./gradlew connectedCheck -x :benchmarks:dungeon-benchmark:connectedCheck -x :benchmarks:performance-poetry:complex-benchmark:connectedCheck --no-daemon --stacktrace
127127

128-
- name: Upload results
129-
if: ${{ always() }}
130-
uses: actions/upload-artifact@v2
131-
with:
132-
name: instrumentation-test-results-${{ matrix.api-level }}
133-
path: ./**/build/reports/androidTests/connected/**
128+
- name : Upload results
129+
if : ${{ always() }}
130+
uses : actions/upload-artifact@v2
131+
with :
132+
name : instrumentation-test-results-${{ matrix.api-level }}
133+
path : ./**/build/reports/androidTests/connected/**
134134

135-
upload-to-mobiledev:
136-
name: mobile.dev | Build & Upload
135+
upload-to-mobiledev :
136+
name : mobile.dev | Build & Upload
137137
runs-on : ubuntu-latest
138-
timeout-minutes: 20
138+
timeout-minutes : 20
139139
steps :
140-
- uses: actions/checkout@v2
141-
- name: set up JDK 11.0.7
142-
uses: actions/setup-java@v1
143-
with:
144-
java-version: 11.0.7
145-
146-
## Build artifact, using cache.
147-
- uses: burrunan/gradle-cache-action@v1
148-
name: Build Performance Poetry APK
149-
with:
150-
gradle-dependencies-cache-key: |
140+
- uses : actions/checkout@v2
141+
- name : set up JDK 11.0.7
142+
uses : actions/setup-java@v1
143+
with :
144+
java-version : 11.0.7
145+
146+
## Build artifact for upload with cache
147+
- uses : burrunan/gradle-cache-action@v1
148+
name : Build Performance Poetry APK
149+
with :
150+
gradle-dependencies-cache-key : |
151151
gradle/libs.versions.toml
152-
arguments: |
153-
:benchmarks:performance-poetry:complex-poetry:assembleRelease --no-daemon --stacktrace
154-
concurrent: true
155-
gradle-build-scan-report: false
156-
gradle-distribution-sha-256-sum-warning: false
152+
arguments : |
153+
benchmarks:performance-poetry:complex-poetry:assembleRelease --no-daemon --stacktrace
154+
concurrent : true
155+
gradle-build-scan-report : false
156+
gradle-distribution-sha-256-sum-warning : false
157157

158158
## Upload with POST
159-
- name: Upload Poetry to mobile.dev
160-
run: |
161-
curl -X POST \
159+
- name : Upload Poetry to mobile.dev
160+
id : upload_apk
161+
run : |
162+
#!/usr/bin/env bash
163+
set -e
164+
set -x
165+
RESPONSE_ID=$(curl -X POST \
162166
-H 'Content-Type: multipart/form-data' \
163167
-H "Authorization: Bearer $MOBILE_DEV_API_KEY" \
164168
--data-binary "@$APP_FILE" \
165-
https://api.mobile.dev/apk > mobile-dev.json
166-
env:
169+
https://api.mobile.dev/apk | jq -r .id)
170+
echo "::set-output name=apk_id::$RESPONSE_ID"
171+
env :
167172
MOBILE_DEV_API_KEY : ${{ secrets.MOBILE_DEV_API_KEY }}
168-
APP_FILE : benchmarks/performance-poetry/complex-poetry/build/outputs/apk/release/complex-poetry-release-unsigned.apk
169-
170-
## Extract ID
171-
- name : Get JSON Property
172-
uses : notiz-dev/github-action-json-property@release
173-
id: upload_id
174-
with:
175-
path: 'mobile-dev.json'
176-
prop_path: 'id'
173+
APP_FILE : benchmarks/performance-poetry/complex-poetry/build/outputs/apk/release/complex-poetry-release.apk
177174

178175
## Start analysis
179-
- name: Start analysis on mobile.dev
180-
run: |
176+
- name : Start analysis on mobile.dev
177+
run : |
181178
#!/usr/bin/env bash
182179
set -e
183180
set -x
@@ -192,8 +189,8 @@ jobs:
192189
-H "Authorization: Bearer $MOBILE_DEV_API_KEY" \
193190
https://api.mobile.dev/analysis \
194191
--data "{\"benchmarkName\": \"$BENCHMARK_NAME\", \"apkId\": \"$APP_ID\", \"branch\": \"$BRANCH_NAME\"$PR_DATA}"
195-
env:
196-
APP_ID : ${{ steps.upload_id.outputs.prop }}
192+
env :
193+
APP_ID : ${{ steps.upload_apk.outputs.apk_id }}
197194
MOBILE_DEV_API_KEY : ${{ secrets.MOBILE_DEV_API_KEY }}
198195
REPO_OWNER : ${{ github.repository_owner }}
199196
REPO_NAME : ${{ github.repository }}

benchmarks/performance-poetry/complex-poetry/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ android {
2424
}
2525

2626
buildTypes {
27+
release {
28+
signingConfig = signingConfigs.getByName("debug")
29+
isDebuggable = false
30+
}
2731
create("benchmark") {
2832
initWith(buildTypes.getByName("release"))
2933
signingConfig = signingConfigs.getByName("debug")

benchmarks/performance-poetry/complex-poetry/src/main/java/com/squareup/benchmarks/performance/complex/poetry/PerformancePoetryActivity.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ class PerformancePoetryActivity : AppCompatActivity() {
5353
setContentView(
5454
WorkflowLayout(this).apply { start(lifecycle, model.renderings, viewRegistry) }
5555
)
56+
57+
// We can report this here as the first rendering from the Workflow is rendered synchronously.
58+
this.reportFullyDrawn()
5659
}
5760

5861
/**

benchmarks/performance-poetry/complex-poetry/src/main/java/com/squareup/benchmarks/performance/complex/poetry/robots/DeviceRobots.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import androidx.test.uiautomator.UiObject2
66
import androidx.test.uiautomator.Until
77
import java.io.ByteArrayOutputStream
88

9+
const val DEFAULT_UI_AUTOMATOR_TIMEOUT: Long = 5_000
10+
911
fun UiDevice.waitForAndClick(
1012
selector: BySelector,
11-
timeout: Long = 3_000
13+
timeout: Long = DEFAULT_UI_AUTOMATOR_TIMEOUT
1214
) {
1315
val uiObject = wait(Until.findObject(selector), timeout)
1416
check(uiObject != null) {
@@ -20,7 +22,7 @@ fun UiDevice.waitForAndClick(
2022

2123
fun UiDevice.waitFor(
2224
selector: BySelector,
23-
timeout: Long = 3_000
25+
timeout: Long = DEFAULT_UI_AUTOMATOR_TIMEOUT
2426
): UiObject2 {
2527
val uiObject = wait(Until.findObject(selector), timeout)
2628
check(uiObject != null) {

benchmarks/performance-poetry/complex-poetry/src/main/java/com/squareup/benchmarks/performance/complex/poetry/robots/PoetryRobots.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ val RavenPoemSelector: BySelector = By.textContains("The Raven")
1313
val NextSelector: BySelector = By.textStartsWith("next")
1414
val PreviousSelector: BySelector = By.textEndsWith("previous")
1515

16-
fun UiDevice.waitForPoetry(timeout: Long = 3_000) {
16+
fun UiDevice.waitForPoetry(timeout: Long = DEFAULT_UI_AUTOMATOR_TIMEOUT) {
1717
wait(Until.hasObject(PoetryPackageSelector), timeout)
1818
}
1919

20-
fun UiDevice.waitForLoading(timeout: Long = 3_000) {
20+
fun UiDevice.waitForLoading(timeout: Long = DEFAULT_UI_AUTOMATOR_TIMEOUT) {
2121
waitFor(LoadingDialogSelector, timeout)
2222
}
2323

24-
fun UiDevice.next(timeout: Long = 3_000) {
24+
fun UiDevice.next(timeout: Long = DEFAULT_UI_AUTOMATOR_TIMEOUT) {
2525
waitForAndClick(NextSelector, timeout)
2626
waitForLoading(timeout)
2727
}
2828

29-
fun UiDevice.previous(timeout: Long = 3_000) {
29+
fun UiDevice.previous(timeout: Long = DEFAULT_UI_AUTOMATOR_TIMEOUT) {
3030
waitForAndClick(PreviousSelector, timeout)
3131
waitForLoading(timeout)
3232
}

0 commit comments

Comments
 (0)