Skip to content

Update Caches

Update Caches #33

Workflow file for this run

name: Update Caches
on:
schedule:
- cron: "37 13 * * SAT"
workflow_dispatch:
jobs:
update-caches:
timeout-minutes: 15
runs-on: ubuntu-latest
env:
androidApiVersion: 34
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '17'
- name: 📦💥 Cleanup Existing Caches
run: |
gh extension install actions/gh-actions-cache
set +e
echo "Deleting caches for branch: $BRANCH"
cacheKeysForBranch=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
for cacheKey in $cacheKeysForBranch
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
echo "Deleted $cacheKey"
done
echo "Successfully deleted caches"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: ${{ github.ref_name }}
- name: 🔍 Detect Cache Key And Paths
id: gradle-cache
uses: actions/github-script@v7
with:
script: |
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
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: 🚧 Build
run: ./gradlew --no-configuration-cache assembleDebug
- name: 📱 Create AVD and Run UI tests
continue-on-error: 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: ./gradlew --no-configuration-cache connectedCheck
- name: 💾 📱 Save AVD Cache
uses: actions/cache/save@v4
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:
MAIL_USERNAME: ${{ secrets.MAIL_USERNAME }}
MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }}
with:
script: |
const subject = `Github Actions cache status of Jetflix ¯\\_(ツ)_/¯`
const reportGeneratorScriptPath = '/./.github/scripts/cache-update-report-generator.js'
const reportGeneratorScript = require(`${process.env.GITHUB_WORKSPACE}${reportGeneratorScriptPath}`)
const report = await reportGeneratorScript({github, context})
const mailSenderScriptPath = '/./.github/scripts/report-mail-sender.js'
const mailSenderScript = require(`${process.env.GITHUB_WORKSPACE}${mailSenderScriptPath}`)
mailSenderScript(subject, report)