From fc5f8a7eba1be59652ab340d622d6e60ac7db03e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bo=C5=99ek=20Leikep?= Date: Wed, 11 Oct 2023 10:32:23 +0200 Subject: [PATCH] ci test --- .github/workflows/build.yml | 50 +++---------------- .../BaselineProfileGenerator.kt | 25 ++++++++-- 2 files changed, 27 insertions(+), 48 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1375f4eed..002738f2f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: macos-latest permissions: contents: write steps: @@ -24,47 +24,11 @@ jobs: distribution: 'zulu' java-version: 18 - - name: ktlint - run: ./gradlew lintKotlin + - name: Setup Android SDK + uses: android-actions/setup-android@v3 - - name: Tests & Detekt & Android lint - run: ./gradlew :catalog:assembleDebug lintDebug :ui:detektAndroidDebug :ui:testDebugUnitTest :lint:test +# - name: Accept Licences +# run: echo y | sdkmanager --licenses - - name: Run Screenshot Tests - run: ./gradlew :ui:verifyPaparazziDebug - - - uses: yutailang0119/action-android-lint@v3.1.0 - name: App Lint errors to annotations - if: ${{ failure() }} - continue-on-error: true # lint may be ok - with: - xml_path: app/build/reports/lint-results-debug.xml - - uses: yutailang0119/action-android-lint@v3.1.0 - name: Lib Lint errors to annotations - if: ${{ failure() }} - continue-on-error: true # lint may be ok - with: - xml_path: lib/build/reports/lint-results-debug.xml - - name: KTLint errors to annotations - if: ${{ failure() }} - run: | - jq --raw-output '[.[] | ({ f: .file } + ( .errors[] | { l: .line, c: .column, m: .message, r: .rule } )) | "::error file=catalog/\(.f),line=\(.l),col=\(.c)::\(.m) [\(.r)]" ] | join("\n")' catalog/build/reports/ktlint/main-lint.json || true - jq --raw-output '[.[] | ({ f: .file } + ( .errors[] | { l: .line, c: .column, m: .message, r: .rule } )) | "::error file=generator/\(.f),line=\(.l),col=\(.c)::\(.m) [\(.r)]" ] | join("\n")' generator/build/reports/ktlint/main-lint.json || true - jq --raw-output '[.[] | ({ f: .file } + ( .errors[] | { l: .line, c: .column, m: .message, r: .rule } )) | "::error file=icons/\(.f),line=\(.l),col=\(.c)::\(.m) [\(.r)]" ] | join("\n")' icons/build/reports/ktlint/main-lint.json || true - jq --raw-output '[.[] | ({ f: .file } + ( .errors[] | { l: .line, c: .column, m: .message, r: .rule } )) | "::error file=illustrations/\(.f),line=\(.l),col=\(.c)::\(.m) [\(.r)]" ] | join("\n")' illustrations/build/reports/ktlint/main-lint.json || true - jq --raw-output '[.[] | ({ f: .file } + ( .errors[] | { l: .line, c: .column, m: .message, r: .rule } )) | "::error file=ui/\(.f),line=\(.l),col=\(.c)::\(.m) [\(.r)]" ] | join("\n")' ui/build/reports/ktlint/main-lint.json || true - - uses: actions/upload-artifact@v3 - if: ${{ failure() }} - with: - name: shots-results - path: ui/out/failures - - name: Build Dokka HTML - if: ${{ github.ref == 'refs/heads/main' }} - run: | - ./gradlew :dokkaHtmlMultiModule --no-configuration-cache - - name: Deploy Dokka HTML - uses: peaceiris/actions-gh-pages@v3 - if: ${{ github.ref == 'refs/heads/main' }} - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./build/dokka/htmlMultiModule + - name: Generate Baseline Profile + run: ./gradlew :catalog:generateReleaseBaselineProfile :icons:generateBaselineProfile :illustrations:generateBaselineProfile :ui:generateBaselineProfile -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=baselineprofile -Pandroid.testoptions.manageddevices.emulator.gpu=swiftshader_indirect --stacktrace diff --git a/baselineprofile/src/main/kotlin/kiwi/orbit/baselineprofile/BaselineProfileGenerator.kt b/baselineprofile/src/main/kotlin/kiwi/orbit/baselineprofile/BaselineProfileGenerator.kt index 9ad54e635..a4083bfd4 100644 --- a/baselineprofile/src/main/kotlin/kiwi/orbit/baselineprofile/BaselineProfileGenerator.kt +++ b/baselineprofile/src/main/kotlin/kiwi/orbit/baselineprofile/BaselineProfileGenerator.kt @@ -43,6 +43,7 @@ internal class BaselineProfileGenerator { private companion object { const val TIMEOUT = 5000L + const val TIMEOUT_LONG = 15000L } @get:Rule @@ -53,11 +54,15 @@ internal class BaselineProfileGenerator { rule.collect( packageName = "kiwi.orbit.compose.catalog", maxIterations = 5, - stableIterations = 2, + stableIterations = 5, ) { pressHome() startActivityAndWait() + if (!device.wait(Until.hasObject(By.res(MainScreenSemantics.Tag)), TIMEOUT_LONG)) { + error("Main screen not shown in time.") + } + profileSubScreen(MainScreenSemantics.ColorsItemTag) profileSubScreen(MainScreenSemantics.IconsItemTag) profileSubScreen(MainScreenSemantics.IllustrationsItemTag) @@ -139,16 +144,26 @@ internal class BaselineProfileGenerator { mainScreenItemTag: String, profileContent: MacrobenchmarkScope.() -> Unit = {}, ) { + if (!device.wait(Until.hasObject(By.scrollable(true)), TIMEOUT)) { + error("Scrollable not found in time. $mainScreenItemTag") + } val mainScreenScrollable = UiScrollable(UiSelector().scrollable(true)) - mainScreenScrollable.scrollIntoView(UiSelector().resourceId(mainScreenItemTag)) - device.wait(Until.hasObject(By.res(mainScreenItemTag)), TIMEOUT) + mainScreenScrollable.scrollIntoView(UiSelector().resourceId(mainScreenItemTag)) + if (!device.wait(Until.hasObject(By.res(mainScreenItemTag)), TIMEOUT)) { + error("Catalog item not found in time. $mainScreenItemTag") + } device.findObject(By.res(mainScreenItemTag)).click() - device.wait(Until.hasObject(By.res(SubScreenSemantics.Tag)), TIMEOUT) + + if (!device.wait(Until.hasObject(By.res(SubScreenSemantics.Tag)), TIMEOUT)) { + error("Sub-screen not shown in time. $mainScreenItemTag") + } profileContent() device.pressBack() - device.wait(Until.hasObject(By.res(MainScreenSemantics.Tag)), TIMEOUT) + if (!device.wait(Until.hasObject(By.res(MainScreenSemantics.Tag)), TIMEOUT)) { + error("Main screen not shown in time. $mainScreenItemTag") + } } }