This is an automated email from the ASF dual-hosted git repository.
ppkarwasz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/logging-log4j-samples.git
The following commit(s) were added to refs/heads/main by this push:
new 581d9a8 Simplify GitHub Actions workflows (#407)
581d9a8 is described below
commit 581d9a858a0bcc6ae0b40f2944c2d9bacb25043a
Author: Piotr P. Karwasz <[email protected]>
AuthorDate: Mon Aug 3 06:01:48 2026 +0200
Simplify GitHub Actions workflows (#407)
* Pin GitHub Actions to major version tags
To reduce the frequency of action update PRs:
- Replace pinned SHAs of `actions/*` steps with major version tags and
configure Dependabot to ignore everything except major updates, with
a 7-day cooldown.
- Replace `graalvm/setup-graalvm` with `actions/setup-java` using the
`graalvm` distribution.
- Replace `gradle/actions/setup-gradle` with the `cache: gradle` option
of `actions/setup-java`. This also removes the Develocity build scan
injection.
Assisted-By: Claude Fable 5 <[email protected]>
* Replace manual Android emulator setup with android-emulator-runner
The `ReactiveCircus/android-emulator-runner` action is now allow-listed
in the ASF organization, so we can use it instead of managing the AVD
and emulator lifecycle by hand.
Third-party actions must be pinned by hash, so the Dependabot ignore
rule for minor and patch updates is narrowed to `actions/*`, which are
pinned to major version tags.
Assisted-By: Claude Fable 5 <[email protected]>
* Fix Gradle invocation in android-emulator-runner script
The action executes each line of `script` as a separate command, so
line continuations are not supported.
Assisted-By: Claude Fable 5 <[email protected]>
* Use consistent task paths in Gradle invocation
Assisted-By: Claude Fable 5 <[email protected]>
* Cache the AVD snapshot for Android tests
Generate an AVD snapshot on cache miss and reuse it in later runs to
speed up the emulator boot. The test run loads the snapshot with
`-no-snapshot-save`, so it never overwrites the cached image.
Assisted-By: Claude Fable 5 <[email protected]>
* Deduplicate Android emulator configuration through job environment
Move the API level and the shared emulator options of the
`android-emulator-runner` steps to job-level environment variables.
Assisted-By: Claude Fable 5 <[email protected]>
---
.github/dependabot.yaml | 13 +++-
.github/workflows/graalvm-reusable-test.yaml | 5 +-
.github/workflows/gradle-reusable-test.yaml | 105 +++++++++++----------------
3 files changed, 53 insertions(+), 70 deletions(-)
diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml
index c63ec2c..c866c50 100644
--- a/.github/dependabot.yaml
+++ b/.github/dependabot.yaml
@@ -66,7 +66,12 @@ updates:
directory: "/"
schedule:
interval: weekly
- groups:
- all:
- patterns:
- - "*"
+ cooldown:
+ default-days: 7
+ # `actions/*` are pinned to major version tags, so only major updates are
relevant.
+ # Other actions are pinned by hash and receive all updates.
+ ignore:
+ - dependency-name: "actions/*"
+ update-types:
+ - "version-update:semver-minor"
+ - "version-update:semver-patch"
diff --git a/.github/workflows/graalvm-reusable-test.yaml
b/.github/workflows/graalvm-reusable-test.yaml
index 6f0effd..f40fb58 100644
--- a/.github/workflows/graalvm-reusable-test.yaml
+++ b/.github/workflows/graalvm-reusable-test.yaml
@@ -50,14 +50,15 @@ jobs:
steps:
- name: Checkout repository
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #
6.0.2
+ uses: actions/checkout@v6
with:
repository: 'apache/logging-log4j-samples'
ref: ${{ inputs.samples-ref }}
- name: Setup GraalVM
- uses: graalvm/setup-graalvm@60c26726de13f8b90771df4bc1641a52a3159994
# 1.5.2
+ uses: actions/setup-java@v5
with:
+ distribution: 'graalvm'
java-version: '21'
- name: Build
diff --git a/.github/workflows/gradle-reusable-test.yaml
b/.github/workflows/gradle-reusable-test.yaml
index 2377e06..2711db0 100644
--- a/.github/workflows/gradle-reusable-test.yaml
+++ b/.github/workflows/gradle-reusable-test.yaml
@@ -42,27 +42,27 @@ jobs:
runs-on: ubuntu-latest
+ env:
+ ANDROID_API_LEVEL: 31
+ # The default options of `android-emulator-runner`, except:
+ # * `-no-snapshot` is removed, so the AVD snapshot cache can be used,
+ # * `-camera-back none` is added.
+ EMULATOR_OPTIONS: -no-window -gpu swiftshader_indirect -noaudio
-no-boot-anim -camera-back none
+
steps:
- name: Checkout repository
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #
6.0.2
+ uses: actions/checkout@v6
with:
repository: 'apache/logging-log4j-samples'
ref: ${{ inputs.samples-ref }}
- name: Setup Java
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 #
5.2.0
+ uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 17
-
- - name: Setup Gradle
- uses:
gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # 6.1.0
- with:
- develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- develocity-injection-enabled: true
- develocity-url: https://develocity.apache.org
- develocity-plugin-version: 3.18.2
+ cache: gradle
- name: Test log4j-samples-gradle-metadata
shell: bash
@@ -79,62 +79,39 @@ jobs:
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- - name: Create AVD Device
- id: avd
- shell: bash
- run: |
- # Debug environment variables
- printenv | grep '^ANDROID\|^HOME' | sort
-
- # Set `ANDROID_USER_HOME` since `emulator` and `avdmanager` use
different definitions:
- # * `avdmanager` uses `$XDG_CONFIG_HOME/.android` with a fallback to
`$HOME/.android`:
- #
https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:common/src/main/java/com/android/prefs/AbstractAndroidLocations.kt
- # * `emulator` uses `HOME/.android`
- export ANDROID_USER_HOME="$HOME/.android"
- echo "ANDROID_USER_HOME=$ANDROID_USER_HOME" >> $GITHUB_ENV
-
- # List installed and available packages
- $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --list
- # Download images
- echo y | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager \
- --install "system-images;android-31;default;x86_64" \
- emulator platform-tools
- # Create device
- $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd \
- --name generic-api-31-device \
- --device "5.4in FWVGA" \
- --package "system-images;android-31;default;x86_64"
- $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager list avds
- # Run emulator
- $ANDROID_HOME/emulator/emulator \
- -no-audio -no-window \
- -avd generic-api-31-device &
- # Enabled the cleanup job
- echo EMULATOR_STARTED=true >> $GITHUB_ENV
- # Wait for device to go online
- # It might take up to 5 minutes
- for i in {1..300}; do
- # Don't stop the script if `adb` fails
- boot_completed=$($ANDROID_HOME/platform-tools/adb shell getprop
sys.boot_completed 2> /dev/null || echo "0")
- if [ "${boot_completed}" = "1" ]; then break; fi
- sleep 1
- done
+ - name: AVD cache
+ id: avd-cache
+ uses: actions/cache@v6
+ with:
+ path: |
+ ~/.android/avd
+ ~/.android/adb*
+ key: avd-${{ env.ANDROID_API_LEVEL }}
+
+ # Only runs on a cache miss to create an AVD snapshot and speed up the
next builds
+ - name: Generate AVD snapshot
+ if: steps.avd-cache.outputs.cache-hit != 'true'
+ uses:
ReactiveCircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d
# 2.38.0
+ with:
+ api-level: ${{ env.ANDROID_API_LEVEL }}
+ # `x86` (the default) is not available for API level 31
+ arch: x86_64
+ force-avd-creation: false
+ emulator-options: ${{ env.EMULATOR_OPTIONS }}
+ disable-animations: false
+ script: echo "Generated AVD snapshot"
- name: Test log4j-samples-android
- shell: bash
+ uses:
ReactiveCircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d
# 2.38.0
env:
LOG4J_VERSION: ${{ inputs.log4j-version }}
LOG4J_REPOSITORY_URL: ${{ inputs.log4j-repository-url }}
- run: |
- ./gradlew \
- :app:build :app:connectedCheck
-
- - name: Remove AVD Device
- if: ${{ always() && env.EMULATOR_STARTED == 'true' }}
- shell: bash
- run: |
- # Kill the emulator
- $ANDROID_HOME/platform-tools/adb -s emulator-5554 emu kill
- # Delete the device
- $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager delete avd \
- --name generic-api-31-device
+ with:
+ api-level: ${{ env.ANDROID_API_LEVEL }}
+ # `x86` (the default) is not available for API level 31
+ arch: x86_64
+ force-avd-creation: false
+ # `-no-snapshot-save` loads the cached snapshot, but does not
overwrite it
+ emulator-options: -no-snapshot-save ${{ env.EMULATOR_OPTIONS }}
+ script: |
+ ./gradlew :app:build :app:connectedCheck