Skip to content

Commit

Permalink
Add caching to actions (#23)
Browse files Browse the repository at this point in the history
* Add caching to actions

* Locate java

* Print version

* More info

* Don't bother caching JDK

* Clean up memory reclamation

* Nix logging

* Update checksum.sh
  • Loading branch information
ZacSweers authored Feb 12, 2020
1 parent 91fe5c0 commit ab9830e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ jobs:
uses: actions/checkout@v2
- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v1
- name: Generate cache key
run: ./checksum.sh checksum.txt
- uses: actions/cache@v1.1.2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ matrix.ci_agp_version }}-${{ matrix.job }}-${{ hashFiles('checksum.txt') }}
restore-keys: |
${{ runner.os }}-gradle-${{ matrix.ci_agp_version }}-${{ matrix.job }}-
- name: Install JDK ${{ matrix.ci_java_version }}
uses: actions/setup-java@v1.3.0
with:
Expand All @@ -40,9 +48,6 @@ jobs:
cd keeper-gradle-plugin
./gradlew clean check --stacktrace -PkeeperTest.agpVersion=${{ matrix.ci_agp_version }}
cd ..
- name: Reclaim memory for emulator
run: ./gradlew --stop && jps|grep -E 'KotlinCompileDaemon|GradleDaemon'| awk '{print $1}'| xargs kill -9 || true
if: matrix.job == 'instrumentation'
- name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
if: matrix.job == 'instrumentation'
Expand All @@ -60,7 +65,7 @@ jobs:
with:
name: error-report
path: build-reports.zip
- name: Reclaim memory for snapshot upload
- name: Reclaim memory
run: ./gradlew --stop && jps|grep -E 'KotlinCompileDaemon|GradleDaemon'| awk '{print $1}'| xargs kill -9 || true
if: success() && github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && matrix.ci_java_version == '1.8' && matrix.ci_agp_version == '3.5.3' && matrix.job == 'plugin'
- name: Upload snapshot (master only)
Expand Down
24 changes: 24 additions & 0 deletions checksum.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

RESULT_FILE=$1

if [[ -f ${RESULT_FILE} ]]; then
rm ${RESULT_FILE}
fi
touch ${RESULT_FILE}

checksum_file() {
echo $(openssl md5 $1 | awk '{print $2}')
}

FILES=()
while read -r -d ''; do
FILES+=("$REPLY")
done < <(find . -type f \( -name "build.gradle*" -o -name "settings.gradle*" -o -name "gradle-wrapper.properties" \) -print0)

# Loop through files and append MD5 to result file
for FILE in ${FILES[@]}; do
echo $(checksum_file ${FILE}) >> ${RESULT_FILE}
done
# Now sort the file so that it is idempotent.
sort ${RESULT_FILE} -o ${RESULT_FILE}

0 comments on commit ab9830e

Please sign in to comment.