Update Actions caching and add workflow to validate Gradle wrapper (#754)
This commit is contained in:
parent
92131bc6d4
commit
9696af4024
4 changed files with 83 additions and 6 deletions
23
.github/checksum.sh
vendored
Executable file
23
.github/checksum.sh
vendored
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env bash
|
||||
RESULT_FILE=$1
|
||||
|
||||
if [ -f $RESULT_FILE ]; then
|
||||
rm $RESULT_FILE
|
||||
fi
|
||||
touch $RESULT_FILE
|
||||
|
||||
checksum_file() {
|
||||
echo $(sha256sum $1 | awk '{print $1}')
|
||||
}
|
||||
|
||||
FILES=()
|
||||
while read -r -d ''; do
|
||||
FILES+=("$REPLY")
|
||||
done < <(find . -type f \( -name "build.gradle*" -o -name "dependencies.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
|
||||
sort $RESULT_FILE -o $RESULT_FILE
|
28
.github/workflows/branch_deploy.yml
vendored
28
.github/workflows/branch_deploy.yml
vendored
|
@ -20,10 +20,32 @@ jobs:
|
|||
- name: Copy CI gradle.properties
|
||||
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
|
||||
|
||||
- uses: actions/cache@v1
|
||||
- name: Generate cache key
|
||||
run: ./.github/checksum.sh checksum.txt
|
||||
|
||||
- name: Cache gradle modules
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.gradle/caches
|
||||
key: gradle-${{ runner.os }}-${{ hashFiles('**/build.gradle') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/dependencies.gradle') }}
|
||||
path: ~/.gradle/caches/modules-2
|
||||
key: ${{ runner.os }}-gradlemodules-${{ hashFiles('checksum.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradlemodules-
|
||||
|
||||
- name: Cache gradle jars
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.gradle/caches/jars-3
|
||||
key: ${{ runner.os }}-gradlejars-${{ hashFiles('checksum.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradlejars-
|
||||
|
||||
- name: Cache gradle build
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.gradle/caches/build-cache-1
|
||||
key: ${{ runner.os }}-gradlebuildcache-${{ hashFiles('checksum.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradlebuildcache-
|
||||
|
||||
- name: Download gradle dependencies
|
||||
run: ./gradlew dependencies
|
||||
|
|
28
.github/workflows/pull_request.yml
vendored
28
.github/workflows/pull_request.yml
vendored
|
@ -15,10 +15,32 @@ jobs:
|
|||
- name: Copy CI gradle.properties
|
||||
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
|
||||
|
||||
- uses: actions/cache@v1
|
||||
- name: Generate cache key
|
||||
run: ./.github/checksum.sh checksum.txt
|
||||
|
||||
- name: Cache gradle modules
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.gradle/caches
|
||||
key: gradle-${{ runner.os }}-${{ hashFiles('**/build.gradle') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/dependencies.gradle') }}
|
||||
path: ~/.gradle/caches/modules-2
|
||||
key: ${{ runner.os }}-gradlemodules-${{ hashFiles('checksum.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradlemodules-
|
||||
|
||||
- name: Cache gradle jars
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.gradle/caches/jars-3
|
||||
key: ${{ runner.os }}-gradlejars-${{ hashFiles('checksum.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradlejars-
|
||||
|
||||
- name: Cache gradle build
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.gradle/caches/build-cache-1
|
||||
key: ${{ runner.os }}-gradlebuildcache-${{ hashFiles('checksum.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradlebuildcache-
|
||||
|
||||
- name: Run unit tests
|
||||
run: ./gradlew spotlessCheck test${{ matrix.variant }} lint${{ matrix.variant}} -Dpre-dex=false
|
||||
|
|
10
.github/workflows/validate_wrapper.yml
vendored
Normal file
10
.github/workflows/validate_wrapper.yml
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
name: "Validate Gradle Wrapper"
|
||||
on: pull_request
|
||||
|
||||
jobs:
|
||||
validation:
|
||||
name: "Wrapper validation"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: gradle/wrapper-validation-action@v1
|
Loading…
Reference in a new issue