Optimize CI a bit
MODIFY
.github/workflows/main.yml
.github/workflows/main.yml
name: Main
+
on:
pull_request:
push:
@@ -7,30 +8,24 @@ on:
jobs:
validation:
- name: "Validation"
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
checks:
- runs-on: macos-latest
+ runs-on: ubuntu-latest
steps:
-
- - name: Project Checkout
- uses: actions/checkout@v2
-
- - name: Setup JDK 1.8
- uses: actions/setup-java@v2
+ - uses: actions/checkout@v3
+ - uses: actions/setup-java@v3
with:
java-version: 8
distribution: 'zulu'
-
+ - uses: gradle/gradle-build-action@v2
- name: Build project
run: ./gradlew build --stacktrace
instrumentation-tests:
- name: Instrumentation tests
runs-on: macos-latest
timeout-minutes: 30
strategy:
@@ -59,33 +54,46 @@ jobs:
# api-level: 30
# target: aosp_atd
# channel: canary
-
steps:
- - name: Project Checkout
- uses: actions/checkout@v2
-
- - name: Setup JDK 1.8
- uses: actions/setup-java@v2
+ - uses: actions/checkout@v3
+ - uses: actions/setup-java@v3
with:
java-version: 8
distribution: 'zulu'
-
+ - uses: gradle/gradle-build-action@v2
+ - name: AVD cache
+ uses: actions/cache@v3
+ id: avd-cache
+ with:
+ path: |
+ ~/.android/avd/*
+ ~/.android/adb*
+ key: avd-${{ matrix.api-level }}-${{ matrix.os }}-${{ matrix.target }}
+ - 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: ${{ matrix.api-level }}
+ target: ${{ matrix.target }}
+ arch: ${{ matrix.arch }}
+ force-avd-creation: false
+ emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
+ disable-animations: false
+ script: echo "Generated AVD snapshot for caching."
- name: Instrumentation Tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
- channel: ${{ matrix.channel }}
arch: ${{ matrix.arch }}
script: |
touch emulator.log # create log file
chmod 777 emulator.log # allow writing to log file
adb logcat >> emulator.log & # pipe all logcat messages into log file as a background process
./gradlew leakcanary-android-core:connectedCheck leakcanary-android:connectedCheck leakcanary-android-instrumentation:connectedCheck --no-build-cache --no-daemon --stacktrace
-
- name: Upload results
if: ${{ always() }}
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: ${{ matrix.api-level }}-${{ matrix.arch }}-instrumentation-test-results
path: |
@@ -97,22 +105,17 @@ jobs:
needs: [ checks, instrumentation-tests ]
runs-on: ubuntu-latest
steps:
-
- - name: Project Checkout
- uses: actions/checkout@v2
-
- - name: Setup JDK 1.8
- uses: actions/setup-java@v2
+ - uses: actions/checkout@v3
+ - uses: actions/setup-java@v3
with:
java-version: 8
distribution: 'zulu'
-
+ - uses: gradle/gradle-build-action@v2
- name: Deploy snapshot
run: ./gradlew publish
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
-
- name: Cleanup secrets
if: always()
run: rm -rf ~/.gradle/gradle.properties

MODIFY
.github/workflows/stale.yaml
.github/workflows/stale.yaml
@@ -9,7 +9,7 @@ jobs:
permissions:
issues: write
steps:
- - uses: actions/stale@v4
+ - uses: actions/stale@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-stale: 30

Optimize CI a bit