[#149] Use Gradle action to manage build cache
This commit is contained in:
parent
a663dc6ca1
commit
ff6c9123e4
|
@ -1,70 +0,0 @@
|
|||
name: 'Setup Java and Dependency Cache'
|
||||
description: "Configures the build environment and caches Gradle, dependencies, and build outputs."
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Set Env
|
||||
shell: bash
|
||||
run: |
|
||||
echo "home=${HOME}" >> "$GITHUB_ENV"
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Disable Gradle Daemon
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir ~/.gradle
|
||||
|
||||
echo "org.gradle.daemon=false" >> ~/.gradle/gradle.properties
|
||||
- name: Gradle Wrapper Cache
|
||||
id: gradle-wrapper-cache
|
||||
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812
|
||||
with:
|
||||
path: ~/.gradle/wrapper
|
||||
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles(format('{0}{1}', github.workspace, '/gradle/wrapper/gradle-wrapper.properties')) }}
|
||||
- name: Gradle Dependency Cache
|
||||
id: gradle-dependency-cache
|
||||
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812
|
||||
with:
|
||||
path: ~/.gradle/caches/modules-2
|
||||
key: ${{ runner.os }}-gradle-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/gradle.properties'), format('{0}{1}', github.workspace, '/gradle/libs.versions.toml')) }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-deps-
|
||||
- name: Kotlin Dependency Cache
|
||||
id: kotlin-dependency-cache
|
||||
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812
|
||||
with:
|
||||
path: |
|
||||
~/.konan
|
||||
key: ${{ runner.os }}-kotlin-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/gradle.properties')) }}
|
||||
# The build cache is doing two things:
|
||||
# 1. Relying on the most recent main branch build to provide a partial cache for both main branch and PR builds.
|
||||
# 2. Relying on the sha for an exact match so that the prime_cache job is re-used by all dependent jobs in a single workflow run
|
||||
- name: Gradle Build Cache
|
||||
id: gradle-build-cache
|
||||
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches/build-cache-1
|
||||
~/.gradle/caches/transforms-3
|
||||
.gradle/configuration-cache
|
||||
key: ${{ runner.os }}-gradle-build-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-build-
|
||||
- name: Download Gradle
|
||||
if: steps.gradle-wrapper-cache.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
./gradlew --version
|
||||
- name: Download Gradle Dependencies
|
||||
if: steps.gradle-dependency-cache.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
./gradlew dependencies :bip39-lib:dependencies
|
||||
- name: Compile
|
||||
if: steps.gradle-build-cache.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
./gradlew assemble testClasses
|
|
@ -52,10 +52,17 @@ jobs:
|
|||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
|
||||
- name: Setup
|
||||
id: setup
|
||||
timeout-minutes: 30
|
||||
uses: ./.github/actions/setup
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98
|
||||
timeout-minutes: 1
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Set up Gradle
|
||||
uses: gradle/gradle-build-action@6095a76664413da4c8c134ee32e8a8ae900f0f1f
|
||||
timeout-minutes: 10
|
||||
with:
|
||||
gradle-home-cache-cleanup: true
|
||||
# While not strictly necessary, this sanity checks the build before attempting to upload.
|
||||
# This adds minimal additional build time, since most of the work is cached and re-used
|
||||
# in the next step.
|
||||
|
@ -78,10 +85,10 @@ jobs:
|
|||
- name: Collect Artifacts
|
||||
timeout-minutes: 1
|
||||
if: ${{ always() }}
|
||||
env:
|
||||
ARTIFACTS_DIR_PATH: ${{ format('{0}/artifacts', env.home) }}
|
||||
BINARIES_ZIP_PATH: ${{ format('{0}/artifacts/release_binaries.zip', env.home) }}
|
||||
run: |
|
||||
export ARTIFACTS_DIR_PATH=~/artifacts
|
||||
export BINARIES_ZIP_PATH=${ARTIFACTS_DIR_PATH}/release_binaries.zip
|
||||
|
||||
mkdir ${ARTIFACTS_DIR_PATH}
|
||||
|
||||
zip -r ${BINARIES_ZIP_PATH} . -i *build/libs/*
|
||||
|
|
|
@ -61,10 +61,17 @@ jobs:
|
|||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
|
||||
- name: Setup
|
||||
id: setup
|
||||
timeout-minutes: 30
|
||||
uses: ./.github/actions/setup
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98
|
||||
timeout-minutes: 1
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Set up Gradle
|
||||
uses: gradle/gradle-build-action@6095a76664413da4c8c134ee32e8a8ae900f0f1f
|
||||
timeout-minutes: 10
|
||||
with:
|
||||
gradle-home-cache-cleanup: true
|
||||
# While not strictly necessary, this sanity checks the build before attempting to upload.
|
||||
# This adds minimal additional build time, since most of the work is cached and re-used
|
||||
# in the next step.
|
||||
|
@ -85,10 +92,10 @@ jobs:
|
|||
- name: Collect Artifacts
|
||||
timeout-minutes: 1
|
||||
if: ${{ always() }}
|
||||
env:
|
||||
ARTIFACTS_DIR_PATH: ${{ format('{0}/artifacts', env.home) }}
|
||||
BINARIES_ZIP_PATH: ${{ format('{0}/artifacts/snapshot_binaries.zip', env.home) }}
|
||||
run: |
|
||||
export ARTIFACTS_DIR_PATH=~/artifacts
|
||||
export BINARIES_ZIP_PATH=${ARTIFACTS_DIR_PATH}/snapshot_binaries.zip
|
||||
|
||||
mkdir ${ARTIFACTS_DIR_PATH}
|
||||
|
||||
zip -r ${BINARIES_ZIP_PATH} . -i *build/libs/*
|
||||
|
|
|
@ -28,22 +28,8 @@ jobs:
|
|||
timeout-minutes: 1
|
||||
uses: gradle/wrapper-validation-action@8d49e559aae34d3e0eb16cde532684bc9702762b
|
||||
|
||||
prime_cache:
|
||||
runs-on: ubuntu-latest
|
||||
needs: validate_gradle_wrapper
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
|
||||
- name: Setup
|
||||
id: setup
|
||||
timeout-minutes: 15
|
||||
uses: ./.github/actions/setup
|
||||
|
||||
static_analysis_detekt:
|
||||
needs: prime_cache
|
||||
needs: validate_gradle_wrapper
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
|
@ -51,10 +37,15 @@ jobs:
|
|||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
|
||||
- name: Setup
|
||||
id: setup
|
||||
timeout-minutes: 5
|
||||
uses: ./.github/actions/setup
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98
|
||||
timeout-minutes: 1
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Set up Gradle
|
||||
uses: gradle/gradle-build-action@6095a76664413da4c8c134ee32e8a8ae900f0f1f
|
||||
timeout-minutes: 3
|
||||
- name: Detekt
|
||||
timeout-minutes: 4
|
||||
run: |
|
||||
|
@ -62,10 +53,10 @@ jobs:
|
|||
- name: Collect Artifacts
|
||||
timeout-minutes: 1
|
||||
if: ${{ always() }}
|
||||
env:
|
||||
ARTIFACTS_DIR_PATH: ${{ format('{0}/artifacts', env.home) }}
|
||||
REPORTS_ZIP_PATH: ${{ format('{0}/artifacts/static_analysis_detekt.zip', env.home) }}
|
||||
run: |
|
||||
export ARTIFACTS_DIR_PATH=~/artifacts
|
||||
export REPORTS_ZIP_PATH=${ARTIFACTS_DIR_PATH}/static_analysis_detekt.zip
|
||||
|
||||
mkdir ${ARTIFACTS_DIR_PATH}
|
||||
|
||||
zip -r ${REPORTS_ZIP_PATH} . -i build/reports/detekt/\*
|
||||
|
@ -78,7 +69,7 @@ jobs:
|
|||
path: ~/artifacts
|
||||
|
||||
static_analysis_ktlint:
|
||||
needs: prime_cache
|
||||
needs: validate_gradle_wrapper
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
|
@ -86,10 +77,15 @@ jobs:
|
|||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
|
||||
- name: Setup
|
||||
id: setup
|
||||
timeout-minutes: 5
|
||||
uses: ./.github/actions/setup
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98
|
||||
timeout-minutes: 1
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Set up Gradle
|
||||
uses: gradle/gradle-build-action@6095a76664413da4c8c134ee32e8a8ae900f0f1f
|
||||
timeout-minutes: 3
|
||||
- name: Ktlint
|
||||
timeout-minutes: 4
|
||||
run: |
|
||||
|
@ -97,10 +93,10 @@ jobs:
|
|||
- name: Collect Artifacts
|
||||
timeout-minutes: 1
|
||||
if: ${{ always() }}
|
||||
env:
|
||||
ARTIFACTS_DIR_PATH: ${{ format('{0}/artifacts', env.home) }}
|
||||
REPORTS_ZIP_PATH: ${{ format('{0}/artifacts/static_analysis_ktlint.zip', env.home) }}
|
||||
run: |
|
||||
export ARTIFACTS_DIR_PATH=~/artifacts
|
||||
export REPORTS_ZIP_PATH=${ARTIFACTS_DIR_PATH}/static_analysis_ktlint.zip
|
||||
|
||||
mkdir ${ARTIFACTS_DIR_PATH}
|
||||
|
||||
zip -r ${REPORTS_ZIP_PATH} . -i build/reports/ktlint/\*
|
||||
|
@ -113,7 +109,7 @@ jobs:
|
|||
path: ~/artifacts
|
||||
|
||||
test:
|
||||
needs: prime_cache
|
||||
needs: validate_gradle_wrapper
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
|
@ -121,9 +117,15 @@ jobs:
|
|||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
|
||||
- name: Setup
|
||||
timeout-minutes: 5
|
||||
uses: ./.github/actions/setup
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98
|
||||
timeout-minutes: 1
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Set up Gradle
|
||||
uses: gradle/gradle-build-action@6095a76664413da4c8c134ee32e8a8ae900f0f1f
|
||||
timeout-minutes: 3
|
||||
- name: Test
|
||||
timeout-minutes: 12
|
||||
run: |
|
||||
|
@ -131,10 +133,10 @@ jobs:
|
|||
- name: Collect Artifacts
|
||||
timeout-minutes: 1
|
||||
if: ${{ always() }}
|
||||
env:
|
||||
ARTIFACTS_DIR_PATH: ${{ format('{0}/artifacts', env.home) }}
|
||||
TEST_RESULTS_ZIP_PATH: ${{ format('{0}/artifacts/test_results.zip', env.home) }}
|
||||
run: |
|
||||
export ARTIFACTS_DIR_PATH=~/artifacts
|
||||
export TEST_RESULTS_ZIP_PATH=${ARTIFACTS_DIR_PATH}/test_results.zip
|
||||
|
||||
mkdir ${ARTIFACTS_DIR_PATH}
|
||||
|
||||
zip -r ${TEST_RESULTS_ZIP_PATH} . -i build/reports/\* \*/build/reports/\*
|
||||
|
|
Loading…
Reference in New Issue