blob: 21f86f65899a348983dc1aacd66ffda96156faf6 [file]
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Java CI
on:
push:
branches:
- main
pull_request: { }
# Default-deny at the workflow scope; any job that needs a token grants it on the job itself.
permissions: { }
# Cancel in-progress runs when a newer commit lands on the same PR; pushes to main run to completion.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build:
# JDK coverage across all current LTS versions and all three OSes, but sparingly:
#
# - On ubuntu-latest we run every LTS (8, 11, 17, 21, 25).
# - On windows-latest and macos-latest we run only the endpoints (8 and 25),
# since cross-OS regressions almost always surface at the version endpoints
# rather than in between.
#
# Temurin does not publish a JDK 8 build for ARM-based macOS runners, so that
# one combination uses Zulu.
name: build (${{ matrix.os }}, JDK ${{ matrix.java-version }})
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 20
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
java-version: [ 8, 25 ]
distribution: [ temurin ]
exclude:
- os: macos-latest
java-version: 8
include:
- os: macos-latest
java-version: 8
distribution: zulu
- os: ubuntu-latest
java-version: 11
distribution: temurin
- os: ubuntu-latest
java-version: 17
distribution: temurin
- os: ubuntu-latest
java-version: 21
distribution: temurin
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.java-version }}
- name: Set up Maven cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 #v6.1.0
with:
path: |
~/.m2/repository
~/.gradle/wrapper
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: mvn --errors --show-version --batch-mode --no-transfer-progress
- name: Upload Surefire reports
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: surefire-reports-${{ matrix.os }}-jdk${{ matrix.java-version }}
path: '**/target/surefire-reports/'
if-no-files-found: ignore
retention-days: 14
build-android:
# API 33 mirrors the Pixel 6a AVD baseline configured in android-tests/build.gradle.kts; API 35 covers the latest stable platform.
# Linux runners only: GitHub-hosted macOS / Windows runners no longer ship KVM / HAXM acceleration, and arm64 / x86 emulator images
# without acceleration boot too slowly to be useful in CI.
name: build (android, API ${{ matrix.api-level }})
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
api-level: [ 33, 35 ]
steps:
- name: Enable KVM
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: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Set up JDK 17
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
with:
distribution: temurin
java-version: 17
# We only restore, since the JDK build's cache will be more comprehensive
- name: Set up Maven cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build library JAR
run: mvn --errors --show-version --batch-mode --no-transfer-progress -DskipTests package
- name: AVD cache
id: avd-cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.android/avd
~/.android/adb*
key: avd-${{ matrix.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@e89f39f1abbbd05b1113a29cf4db69e7540cae5a # v2.37.0
with:
api-level: ${{ matrix.api-level }}
target: default
arch: x86_64
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"
- name: Gradle cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('android-tests/*.gradle.kts', 'android-tests/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Run instrumented tests
uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a # v2.37.0
with:
api-level: ${{ matrix.api-level }}
target: default
arch: x86_64
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
working-directory: android-tests
script: ./gradlew connectedDebugAndroidTest
- name: Upload Android test reports
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: android-test-reports-api${{ matrix.api-level }}
path: |
android-tests/build/outputs/androidTest-results/
android-tests/build/reports/androidTests/
if-no-files-found: ignore
retention-days: 14