Skip to content

Commit 0a26cb4

Browse files
Merge pull request #791 from JoseAlcerreca/main_ci
Migrates CI to GHA
2 parents a6156ad + be80191 commit 0a26cb4

File tree

7 files changed

+109
-123
lines changed

7 files changed

+109
-123
lines changed

.circleci/config.yml

Lines changed: 0 additions & 92 deletions
This file was deleted.

.github/ci-gradle.properties

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# Copyright 2020 The Android Open Source Project
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
org.gradle.daemon=false
18+
org.gradle.parallel=true
19+
org.gradle.jvmargs=-Xmx5120m
20+
org.gradle.workers.max=2
21+
22+
kotlin.incremental=false
23+
kotlin.compiler.execution.strategy=in-process

.github/workflows/blueprints.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: blueprints
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 30
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
20+
- name: Copy CI gradle.properties
21+
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
22+
23+
- name: Set up JDK 11
24+
uses: actions/setup-java@v1
25+
with:
26+
java-version: 11
27+
28+
- uses: actions/cache@v2
29+
with:
30+
path: |
31+
~/.gradle/caches/modules-*
32+
~/.gradle/caches/jars-*
33+
~/.gradle/caches/build-cache-*
34+
key: gradle-${{ hashFiles('checksum.txt') }}
35+
36+
- name: Build project
37+
run: ./gradlew spotlessCheck assembleMockDebug assembleProdDebug testMockDebugUnitTest testProdDebugUnitTest --stacktrace
38+
39+
- name: Upload build reports
40+
if: always()
41+
uses: actions/upload-artifact@v2
42+
with:
43+
name: build-reports
44+
path: app/build/reports/
45+
46+
test:
47+
needs: build
48+
runs-on: macOS-latest # enables hardware acceleration in the virtual machine
49+
timeout-minutes: 30
50+
strategy:
51+
matrix:
52+
api-level: [23, 29]
53+
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v2
57+
58+
- name: Copy CI gradle.properties
59+
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
60+
61+
- name: Set up JDK 11
62+
uses: actions/setup-java@v1
63+
with:
64+
java-version: 11
65+
66+
- name: Run instrumentation tests
67+
uses: reactivecircus/android-emulator-runner@v2
68+
with:
69+
api-level: ${{ matrix.api-level }}
70+
arch: x86
71+
disable-animations: true
72+
script: ./gradlew app:cMDAT --stacktrace
73+
74+
- name: Upload test reports
75+
if: always()
76+
uses: actions/upload-artifact@v2
77+
with:
78+
name: test-reports
79+
path: app/build/reports/

.travis.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

app/src/main/java/com/example/android/architecture/blueprints/todoapp/ViewModelFactory.kt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@
1515
*/
1616
package com.example.android.architecture.blueprints.todoapp
1717

18-
import android.app.Application
1918
import android.os.Bundle
2019
import androidx.lifecycle.AbstractSavedStateViewModelFactory
2120
import androidx.lifecycle.SavedStateHandle
22-
import androidx.lifecycle.SavedStateViewModelFactory
2321
import androidx.lifecycle.ViewModel
24-
import androidx.lifecycle.ViewModelProvider
2522
import androidx.savedstate.SavedStateRegistryOwner
2623
import com.example.android.architecture.blueprints.todoapp.addedittask.AddEditTaskViewModel
2724
import com.example.android.architecture.blueprints.todoapp.data.source.TasksRepository
@@ -34,15 +31,15 @@ import com.example.android.architecture.blueprints.todoapp.tasks.TasksViewModel
3431
*/
3532
@Suppress("UNCHECKED_CAST")
3633
class ViewModelFactory constructor(
37-
private val tasksRepository: TasksRepository,
38-
owner: SavedStateRegistryOwner,
39-
defaultArgs: Bundle? = null
34+
private val tasksRepository: TasksRepository,
35+
owner: SavedStateRegistryOwner,
36+
defaultArgs: Bundle? = null
4037
) : AbstractSavedStateViewModelFactory(owner, defaultArgs) {
4138

4239
override fun <T : ViewModel> create(
43-
key: String,
44-
modelClass: Class<T>,
45-
handle: SavedStateHandle
40+
key: String,
41+
modelClass: Class<T>,
42+
handle: SavedStateHandle
4643
) = with(modelClass) {
4744
when {
4845
isAssignableFrom(StatisticsViewModel::class.java) ->

app/src/main/java/com/example/android/architecture/blueprints/todoapp/tasks/TasksViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ class TasksViewModel(
238238
_forceUpdate.value = true
239239
}
240240

241-
private fun getSavedFilterType() : TasksFilterType {
241+
private fun getSavedFilterType(): TasksFilterType {
242242
return savedStateHandle.get(TASKS_FILTER_SAVED_STATE_KEY) ?: ALL_TASKS
243243
}
244244
}

app/src/test/java/com/example/android/architecture/blueprints/todoapp/LiveDataTestUtil.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ fun <T> LiveData<T>.getOrAwaitValue(
5353
this.removeObserver(observer)
5454
throw TimeoutException("LiveData value was never set.")
5555
}
56-
5756
} finally {
5857
this.removeObserver(observer)
5958
}

0 commit comments

Comments
 (0)