blob: f50c747e3dda9e2c1fa8825184a7c78c2132ebc7 [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:
# java.xml is pure Java, so the OS and JDK axes barely interact.
# The one OS-specific behavior this library touches is file URI / systemId normalization on Windows,
# which is old, stable code: a single Windows job exercises it, so there is no reason to cross OSes with JDK versions.
# The axes that do change results are the JDK major version and, more weakly, the vendor's class-library lineage.
#
# - JDK majors, Windows only. Covers systemId normalization at every version for free.
# - One Linux canary, on the current LTS: case-sensitive filesystem, and what contributors and downstream CI run.
# - Distribution variance, one job each:
# * Semeru 8 and 21 OpenJ9's class library is the most divergent runtime setup-java offers,
# and the most plausible source of surprises in factory lookup and class loading.
# * Zulu Pinned to an old 8 patch level.
# Verifies the hardening degrades gracefully on a runtime predating the later jdk.xml.* backports.
# * GraalVM Runs the suite as a native image via the `native-xalan` profile:
# the JAXP providers resolve at build time under the closed-world assumption, a different code path from
# the JVM's run-time ServiceLoader lookup. 25 is the latest GraalVM release.
#
# macOS is intentionally omitted: its filesystem is case-insensitive like Windows and POSIX-pathed like Linux, so
# it is strictly interior to the other two. Vendors that track the OpenJDK Updates projects closely (Corretto,
# Liberica, Microsoft, SapMachine) are likewise omitted: for java.xml purposes they are interchangeable with
# Temurin.
name: build (${{ matrix.os }}, ${{ matrix.distribution }} ${{ matrix.java-version }})
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental || false }}
strategy:
max-parallel: 20
fail-fast: false
matrix:
os: [ windows-latest ]
java-version: [ "8", "11", "17", "21", "25", "26", "27-ea" ]
distribution: [ temurin ]
include:
- os: ubuntu-latest
java-version: 25
distribution: temurin
- os: ubuntu-latest
java-version: 8
distribution: semeru
- os: ubuntu-latest
java-version: 21
distribution: semeru
- os: ubuntu-latest
java-version: 8.0.201
distribution: zulu
- os: ubuntu-latest
java-version: 25
distribution: graalvm
experimental: true
# The test is slower than all JVM tests; run only `test` to skip Javadoc and static-analysis goals
maven-args: -Pnative-xalan test
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 ${{ matrix.maven-args }}
- name: Upload Surefire reports
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: surefire-reports-${{ matrix.os }}-${{ matrix.distribution }}${{ 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