Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save github actions build cache #273

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ async function extractGradleVersion() {
}

function cacheGradleFiles(gradleVersion, core) {
const cacheKey = `${process.platform}-gradle-${gradleVersion}`;
const cachePaths = [
const gradleCachePaths = [
'~/.gradle/caches',
'~/.gradle/wrapper',
'~/.gradle/configuration-cache',
`~/.gradle/${gradleVersion}`
];

core.setOutput('cache-key', cacheKey);
core.setOutput('cache-paths', cachePaths.join('\n'));
core.setOutput('gradle-version', gradleVersion);
core.setOutput('gradle-cache-key', `${process.platform}-gradle-${gradleVersion}`);
core.setOutput('gradle-cache-paths', gradleCachePaths.join('\n'));
core.setOutput('build-cache-key', `${process.platform}-build-${gradleVersion}`);
core.setOutput('build-cache-paths', `**/build`);
}
39 changes: 15 additions & 24 deletions .github/workflows/ui-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,26 @@ jobs:
with:
distribution: 'corretto'
java-version: '17'
- name: 🔍 Detect Gradle Version And Cache
- name: 🔍 Detect Cache Key And Paths
id: gradle-cache
uses: actions/github-script@v7
with:
script: |
const gradleCacheDetectorScriptPath = '/./.github/scripts/gradle-version-cache-detector.js'
const gradleCacheDetectorScript = require(`${process.env.GITHUB_WORKSPACE}${gradleCacheDetectorScriptPath}`)
await gradleCacheDetectorScript({core});
- name: Fetch gradle cache
uses: actions/cache@v4
const cacheDetectorScriptPath = '/./.github/scripts/gradle-cache-detector.js'
const cacheDetectorScript = require(`${process.env.GITHUB_WORKSPACE}${cacheDetectorScriptPath}`)
await cacheDetectorScript({core});
- name: 🐘 Fetch gradle cache
uses: actions/cache/restore@v4
with:
path: ${{ steps.gradle-cache.outputs['cache-paths'] }}
key: ${{ steps.gradle-cache.outputs['cache-key'] }}
- name: Fetch AVD Cache
uses: actions/cache@v4
path: ${{ steps.gradle-cache.outputs['gradle-cache-paths'] }}
key: ${{ steps.gradle-cache.outputs['gradle-cache-key'] }}
- name: 🐘 Fetch build cache
uses: actions/cache/restore@v4
with:
path: ${{ steps.gradle-cache.outputs['build-cache-paths'] }}
key: ${{ steps.gradle-cache.outputs['build-cache-key'] }}
- name: 📱 Fetch AVD Cache
uses: actions/cache/restore@v4
id: avd-cache
with:
path: |
Expand All @@ -42,20 +47,6 @@ jobs:
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: 📱 Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.androidApiVersion }}
target: aosp_atd
channel: stable
arch: x86_64
ram-size: 4096M
disk-size: 2048M
force-avd-creation: false
disable-animations: true
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: echo "Generated AVD snapshot for caching."
- name: 🤖 Run Ui Tests
uses: reactivecircus/android-emulator-runner@v2
with:
Expand Down
21 changes: 13 additions & 8 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,24 @@ jobs:
with:
distribution: 'corretto'
java-version: '17'
- name: 🔍 Detect Gradle Version And Cache
- name: 🔍 Detect Cache Key And Paths
id: gradle-cache
uses: actions/github-script@v7
with:
script: |
const gradleCacheDetectorScriptPath = '/./.github/scripts/gradle-version-cache-detector.js'
const gradleCacheDetectorScript = require(`${process.env.GITHUB_WORKSPACE}${gradleCacheDetectorScriptPath}`)
await gradleCacheDetectorScript({core});
- name: Fetch gradle cache
uses: actions/cache@v4
const cacheDetectorScriptPath = '/./.github/scripts/gradle-cache-detector.js'
const cacheDetectorScript = require(`${process.env.GITHUB_WORKSPACE}${cacheDetectorScriptPath}`)
await cacheDetectorScript({core});
- name: 🐘 Fetch gradle cache
uses: actions/cache/restore@v4
with:
path: ${{ steps.gradle-cache.outputs['cache-paths'] }}
key: ${{ steps.gradle-cache.outputs['cache-key'] }}
path: ${{ steps.gradle-cache.outputs['gradle-cache-paths'] }}
key: ${{ steps.gradle-cache.outputs['gradle-cache-key'] }}
- name: 🐘 Fetch build cache
uses: actions/cache/restore@v4
with:
path: ${{ steps.gradle-cache.outputs['build-cache-paths'] }}
key: ${{ steps.gradle-cache.outputs['build-cache-key'] }}
- name: Run unit tests
run: ./gradlew testDebugUnitTest --continue
- name: Publish Unit Test Results
Expand Down
26 changes: 15 additions & 11 deletions .github/workflows/update-caches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,14 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: ${{ github.ref_name }}
- name: 🔍 Detect Gradle Version And Cache
- name: 🔍 Detect Cache Key And Paths
id: gradle-cache
uses: actions/github-script@v7
with:
script: |
const gradleCacheDetectorScriptPath = '/./.github/scripts/gradle-version-cache-detector.js'
const gradleCacheDetectorScript = require(`${process.env.GITHUB_WORKSPACE}${gradleCacheDetectorScriptPath}`)
await gradleCacheDetectorScript({core});
- name: Fetch gradle cache
uses: actions/cache@v4
with:
path: ${{ steps.gradle-cache.outputs['cache-paths'] }}
key: ${{ steps.gradle-cache.outputs['cache-key'] }}
const cacheDetectorScriptPath = '/./.github/scripts/gradle-cache-detector.js'
const cacheDetectorScript = require(`${process.env.GITHUB_WORKSPACE}${cacheDetectorScriptPath}`)
await cacheDetectorScript({core});
- name: Enable KVM group permissions for emulator hardware acceleration
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
Expand All @@ -66,14 +61,23 @@ jobs:
script: echo "Generated AVD snapshot for caching."
- name: 🚧 Build
run: gradle assembleDebug --configuration-cache
- name: 💾 Save AVD Cache
- name: 💾 📱 Save AVD Cache
uses: actions/cache/save@v4
if: always()
with:
path: |
~/.android/avd/*
~/.android/adb*
key: ${{ runner.os }}-avd-${{ env.androidApiVersion }}
- name: 💾 🐘 Save Gradle Cache
uses: actions/cache/save@v4
with:
path: ${{ steps.gradle-cache.outputs['gradle-cache-paths'] }}
key: ${{ steps.gradle-cache.outputs['gradle-cache-key'] }}
- name: 💾 🐘 Save Gradle Build Cache
uses: actions/cache/save/@v4
with:
path: ${{ steps.gradle-cache.outputs['build-cache-paths'] }}
key: ${{ steps.gradle-cache.outputs['build-cache-key'] }}
- name: 💌 Send email report
uses: actions/github-script@v7
env:
Expand Down
Loading