Skip to content

Commit d86207f

Browse files
Manuel Vivomanuelvicnt
Manuel Vivo
authored andcommittedDec 17, 2019
Adds cache and Ktlint to Github actions
1 parent 47867a6 commit d86207f

File tree

4 files changed

+131
-37
lines changed

4 files changed

+131
-37
lines changed
 

‎.github/ci-gradle.properties

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2019 Google, Inc.
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/ci.yaml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
ci:
11+
name: Build + Test
12+
runs-on: macOS-latest # enables hardware acceleration in the virtual machine
13+
strategy:
14+
matrix:
15+
api-level: [21, 29]
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
with:
20+
fetch-depth: 1
21+
22+
- name: Set up JDK 1.8
23+
uses: actions/setup-java@v1
24+
with:
25+
java-version: 1.8
26+
27+
- name: Make files executable
28+
run: chmod +x ./JetNews/gradlew && chmod +x ./JetNews/checksum.sh
29+
30+
- name: Generate cache key
31+
run: ./JetNews/checksum.sh checksum.txt
32+
33+
- name: Copy CI gradle.properties
34+
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
35+
36+
- uses: actions/cache@v1
37+
with:
38+
path: ~/.gradle/caches/modules-2
39+
key: ${{ runner.os }}-gradlemodules-${{ hashFiles('checksum.txt') }}
40+
restore-keys: |
41+
${{ runner.os }}-gradlemodules-
42+
43+
- uses: actions/cache@v1
44+
with:
45+
path: ~/.gradle/caches/jars-3
46+
key: ${{ runner.os }}-gradlejars-${{ hashFiles('checksum.txt') }}
47+
restore-keys: |
48+
${{ runner.os }}-gradlejars-
49+
50+
- uses: actions/cache@v1
51+
with:
52+
path: ~/.gradle/caches/build-cache-1
53+
key: ${{ runner.os }}-gradlebuildcache-${{ hashFiles('checksum.txt') }}
54+
restore-keys: |
55+
${{ runner.os }}-gradlebuildcache-
56+
57+
- name: Ktlint
58+
run: cd JetNews && ./gradlew ktlint --stacktrace
59+
60+
- name: Build project
61+
run: cd JetNews && ./gradlew assemble --stacktrace
62+
63+
- name: Run instrumentation tests
64+
uses: reactivecircus/android-emulator-runner@v2
65+
with:
66+
api-level: ${{ matrix.api-level }}
67+
arch: x86
68+
disable-animations: true
69+
script: cd JetNews && ./gradlew connectedCheck --stacktrace

‎JetNews/.github/workflows/ci.yaml

-37
This file was deleted.

‎JetNews/checksum.sh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#
2+
# Copyright 2019 Google, Inc.
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+
#!/bin/bash
18+
RESULT_FILE=$1
19+
20+
if [ -f $RESULT_FILE ]; then
21+
rm $RESULT_FILE
22+
fi
23+
touch $RESULT_FILE
24+
25+
checksum_file() {
26+
echo $(openssl md5 $1 | awk '{print $2}')
27+
}
28+
29+
FILES=()
30+
while read -r -d ''; do
31+
FILES+=("$REPLY")
32+
done < <(find . -type f \( -name "build.gradle*" -o -name "gradle-wrapper.properties" \) -print0)
33+
34+
# Loop through files and append MD5 to result file
35+
for FILE in ${FILES[@]}; do
36+
echo $(checksum_file $FILE) >> $RESULT_FILE
37+
done
38+
# Now sort the file so that it is
39+
sort $RESULT_FILE -o $RESULT_FILE

0 commit comments

Comments
 (0)
Please sign in to comment.