From fcbbe2eb1b49e919df6693defba8a5586b74362b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Alc=C3=A9rreca?= Date: Wed, 19 May 2021 15:36:34 +0000 Subject: [PATCH 1/4] Initial GHA config Change-Id: Ibb27ba0cfaa525055bd0b709014d824ba4c1486a --- .github/ci-gradle.properties | 23 ++++++++++ .github/workflows/iosched.yaml | 78 ++++++++++++++++++++++++++++++++++ .travis.yml | 33 -------------- 3 files changed, 101 insertions(+), 33 deletions(-) create mode 100644 .github/ci-gradle.properties create mode 100644 .github/workflows/iosched.yaml delete mode 100644 .travis.yml diff --git a/.github/ci-gradle.properties b/.github/ci-gradle.properties new file mode 100644 index 0000000000..c349fe2392 --- /dev/null +++ b/.github/ci-gradle.properties @@ -0,0 +1,23 @@ +# +# Copyright 2020 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +org.gradle.daemon=false +org.gradle.parallel=true +org.gradle.jvmargs=-Xmx5120m +org.gradle.workers.max=2 + +kotlin.incremental=false +kotlin.compiler.execution.strategy=in-process \ No newline at end of file diff --git a/.github/workflows/iosched.yaml b/.github/workflows/iosched.yaml new file mode 100644 index 0000000000..809d27bc87 --- /dev/null +++ b/.github/workflows/iosched.yaml @@ -0,0 +1,78 @@ +name: iosched + +on: + push: + branches: + - main + - compose + - main_gha + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 30 + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + + - uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches/modules-* + ~/.gradle/caches/jars-* + ~/.gradle/caches/build-cache-* + key: gradle-${{ hashFiles('checksum.txt') }} + + - name: Build project + run: ./gradlew spotlessCheck assembleDebug --stacktrace + + - name: Upload build reports + if: always() + uses: actions/upload-artifact@v2 + with: + name: build-reports + path: mobile/build/reports + + test: + needs: build + runs-on: macOS-latest # enables hardware acceleration in the virtual machine + timeout-minutes: 30 + strategy: + matrix: + api-level: [23, 26, 29] + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Run instrumentation tests + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api-level }} + arch: x86 + disable-animations: true + script: ./gradlew mobile:cAT --stacktrace + + - name: Upload test reports + if: always() + uses: actions/upload-artifact@v2 + with: + name: test-reports + path: mobile/build/reports diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 82d68b5741..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2014 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -language: android -android: - components: - - tools - - platform-tools - - build-tools-28.0.3 - - android-29 - - addon-google_apis-google-29 - - extra-google-m2repository - - extra-android-m2repository -script: - - ./gradlew test -before_cache: - - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock -cache: - directories: - - $HOME/.m2 - - $HOME/.gradle/caches/ - - $HOME/.gradle/wrapper/ - From e973521b9499fc49226e24872b6cbf9e68572d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Alc=C3=A9rreca?= Date: Wed, 19 May 2021 16:16:20 +0000 Subject: [PATCH 2/4] Fixes upload-artifacts path Change-Id: I083e6ceb5edc3fc4486bcb2c9d61dd735b637b1a --- .github/workflows/iosched.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/iosched.yaml b/.github/workflows/iosched.yaml index 809d27bc87..7a4d231932 100644 --- a/.github/workflows/iosched.yaml +++ b/.github/workflows/iosched.yaml @@ -40,7 +40,7 @@ jobs: uses: actions/upload-artifact@v2 with: name: build-reports - path: mobile/build/reports + path: mobile/build/reports/ test: needs: build @@ -75,4 +75,4 @@ jobs: uses: actions/upload-artifact@v2 with: name: test-reports - path: mobile/build/reports + path: mobile/build/reports/ From c9cc1464e3ce8a18199cd96b04eaf9b0a8b48c77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Alc=C3=A9rreca?= Date: Wed, 19 May 2021 17:57:58 +0000 Subject: [PATCH 3/4] Temporary fix to the codelab test Change-Id: Ie12aaf8caffe84d7e27994e54824fbd0bdf9a960 --- .../com/google/samples/apps/iosched/tests/ui/CodelabTest.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mobile/src/androidTest/java/com/google/samples/apps/iosched/tests/ui/CodelabTest.kt b/mobile/src/androidTest/java/com/google/samples/apps/iosched/tests/ui/CodelabTest.kt index 67ac4a9a42..bb0c9cadb6 100644 --- a/mobile/src/androidTest/java/com/google/samples/apps/iosched/tests/ui/CodelabTest.kt +++ b/mobile/src/androidTest/java/com/google/samples/apps/iosched/tests/ui/CodelabTest.kt @@ -29,8 +29,12 @@ import com.google.samples.apps.iosched.shared.data.FakeConferenceDataSource import com.google.samples.apps.iosched.tests.SetPreferencesRule import dagger.hilt.android.testing.HiltAndroidRule import dagger.hilt.android.testing.HiltAndroidTest +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.test.TestCoroutineDispatcher +import kotlinx.coroutines.test.setMain import org.hamcrest.CoreMatchers.allOf import org.hamcrest.CoreMatchers.instanceOf +import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -55,6 +59,7 @@ class CodelabTest { onView(allOf(instanceOf(TextView::class.java), withParent(withId(R.id.toolbar)))) .check(matches(withText(R.string.event_codelabs_title))) // One of the codelabs + Thread.sleep(400) // TODO: RecyclerView is async so it makes the test fail onView(withText(FakeConferenceDataSource.FAKE_CODELAB_TITLE)).check(matches(isDisplayed())) } } From 10535763daf6d7ba1f2a38bace8d24b7c43711ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Alc=C3=A9rreca?= Date: Wed, 19 May 2021 18:58:05 +0000 Subject: [PATCH 4/4] Spotless./gradlew spotlessApply Change-Id: I2be9155251c91692c20d2aa0c909ee4fcbfa0c4a --- .../com/google/samples/apps/iosched/tests/ui/CodelabTest.kt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mobile/src/androidTest/java/com/google/samples/apps/iosched/tests/ui/CodelabTest.kt b/mobile/src/androidTest/java/com/google/samples/apps/iosched/tests/ui/CodelabTest.kt index bb0c9cadb6..55b71e612f 100644 --- a/mobile/src/androidTest/java/com/google/samples/apps/iosched/tests/ui/CodelabTest.kt +++ b/mobile/src/androidTest/java/com/google/samples/apps/iosched/tests/ui/CodelabTest.kt @@ -29,12 +29,8 @@ import com.google.samples.apps.iosched.shared.data.FakeConferenceDataSource import com.google.samples.apps.iosched.tests.SetPreferencesRule import dagger.hilt.android.testing.HiltAndroidRule import dagger.hilt.android.testing.HiltAndroidTest -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.test.TestCoroutineDispatcher -import kotlinx.coroutines.test.setMain import org.hamcrest.CoreMatchers.allOf import org.hamcrest.CoreMatchers.instanceOf -import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith