Skip to content

Name the 17 line in the README's Versions #769

Name the 17 line in the README's Versions

Name the 17 line in the README's Versions #769

Workflow file for this run

name: CI
on:
push:
branches:
- '*.X.X' # a release line is named after the Java version it is built for: 21.X.X
pull_request:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# setup-java's problem matcher turns javac's warnings, Error Prone's among them, into annotations on
# the diff. This is the one job that keeps it: every other job compiles the same sources, and with
# the matcher on there too each warning showed once per job. GitHub keeps only the first ten
# warnings of a step, so the annotations are the first ten warnings the parallel build prints.
- name: Install JDK 21
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: '21'
problem-matcher: true
# Gradle's downloads come from the Actions cache rather than the network: the wrapper's distribution
# (services.gradle.org timed out and failed DNS on macos-15-intel, twice in a month) and the
# dependencies (Maven Central reset the connection on three runners and failed DNS on a fourth, all
# on 2026-10-19). Only builds of the default branch write the cache; pull requests read it. Two
# things stay out: the local build cache, left out on purpose for now, and the IDE the IntelliJ
# plugin's tests start, whose 852 MB zip and the 2.1 GB it unpacks to under transforms would take
# longer to restore than to download and fill much of the repository's 10 GB. One thing goes in besides
# the default `caches` and `notifications`: the downloads of the Gradle plugins' TestKit builds, the
# Android Gradle plugin and its dependencies above all. Those builds have a Gradle user home of their
# own, under build/tmp by default, which the cache did not reach: every job downloaded it all from
# Maven Central again, until Maven Central answered 429 Too Many Requests on 2026-11-28. -PtestkitDir
# puts that home at test-kit in this one. Choosing paths is a feature of the default, proprietary
# cache provider, bundled in the action and free for public repositories; the open-source one has none.
- name: Cache Gradle's downloads
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
with:
gradle-home-cache-includes: |
caches
notifications
test-kit/caches/modules-2
gradle-home-cache-excludes: |
caches/build-cache-1
caches/modules-2/files-2.1/com.jetbrains.intellij.idea
caches/*/transforms
- name: Build
run: ./gradlew check -PtestkitDir="$GRADLE_USER_HOME/test-kit"
- name: Publish Test Report
uses: mikepenz/action-junit-report@a16be3a69023e9bd7e748ede768b3282ea7b30ce # v6.7.1
if: ${{ !cancelled() }}
with:
report_paths: '**/build/test-results/test/*.xml'
annotate_only: true
job_summary: true
# The tests of `build` on the newer JDKs, in parallel with everything else: nothing waits for these
# jobs and nothing they build is kept. The code is still compiled for Java 21 by JDK 21, as in the
# release; -PjavaRuntime moves only the test JVMs, and with them the javac whose internals the
# formatter parses with. The IntelliJ plugin's tests stay on the runtime of the IDE they start.
# JDK 21 itself is `build`, the check the default branch requires.
jdk:
name: build (JDK ${{ matrix.jdk }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# `gradle` is what the Gradle plugins' tests build their projects with: the oldest release that runs on
# the leg's JDK (https://docs.gradle.org/current/userguide/compatibility.html#java_runtime), or 9.3.1,
# the oldest the plugins support, where that is older. Each leg thus tests the far end of what it can.
# 28-ea has none that runs on it yet.
include:
- jdk: 25
gradle: 9.3.1
gradle_args: ''
gradle_args_reason: ''
- jdk: 26
gradle: 9.4.0
gradle_args: ''
gradle_args_reason: ''
- jdk: 27
gradle: 9.8.0
gradle_args: ''
gradle_args_reason: ''
# Value classes (JEP 401) are a preview feature of JDK 28, so until it is released the `value` modifier
# tests (#131) run on its early-access builds and are skipped everywhere else. The version is spelled
# as setup-java spells it; Gradle gets the number alone.
- jdk: 28-ea
gradle: ''
gradle_args: -x :gradle-open-java-format:test
gradle_args_reason: >-
No Gradle release runs on Java 28 yet: 9.8.2, the newest, fails to compile a build script there with
"Unsupported class file major version 72". The Gradle plugins' tests build their projects with Gradle
on the test JVM, so they are left out until a release runs on it.
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# No problem matcher in this job: `build` annotates the warnings.
- name: Install JDK ${{ matrix.jdk }} for the tests
id: test-jdk
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: ${{ matrix.jdk }}
problem-matcher: false
# Installed last, so that it is the JAVA_HOME Gradle runs and compiles on.
- name: Install JDK 21
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: '21'
problem-matcher: false
# The same cache as in `build`.
- name: Cache Gradle's downloads
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
with:
gradle-home-cache-includes: |
caches
notifications
test-kit/caches/modules-2
gradle-home-cache-excludes: |
caches/build-cache-1
caches/modules-2/files-2.1/com.jetbrains.intellij.idea
caches/*/transforms
- name: Explain the extra Gradle arguments
if: ${{ matrix.gradle_args != '' }}
env:
GRADLE_ARGS: ${{ matrix.gradle_args }}
REASON: ${{ matrix.gradle_args_reason }}
run: echo "::notice title=JDK ${{ matrix.jdk }} runs with $GRADLE_ARGS::$REASON"
# Gradle does not look into the runner's tool cache, so it is told where the test JDK is. The path is
# a step's output, so it reaches the shell as a variable rather than being pasted into the script.
# -PjavaRuntime takes a number, so an early-access leg loses its -ea suffix here.
- name: Build
env:
TEST_JDK: ${{ steps.test-jdk.outputs.path }}
JDK: ${{ matrix.jdk }}
TESTKIT_GRADLE: ${{ matrix.gradle }}
run: >-
./gradlew test -PjavaRuntime="${JDK%-ea}" -PtestkitGradleVersion="$TESTKIT_GRADLE" ${{ matrix.gradle_args }}
-Porg.gradle.java.installations.paths="$TEST_JDK" -PtestkitDir="$GRADLE_USER_HOME/test-kit"
- name: Publish Test Report
uses: mikepenz/action-junit-report@a16be3a69023e9bd7e748ede768b3282ea7b30ce # v6.7.1
if: ${{ !cancelled() }}
with:
report_paths: '**/build/test-results/test/*.xml'
annotate_only: true
job_summary: true
# One explicit job per target, so every binary we ship is traceable to a named run.
native:
name: native (${{ matrix.runner }})
needs: build
runs-on: ${{ matrix.runner }}
timeout-minutes: 90
# bash on Windows too, so that every step reads the same on every runner.
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
# Linux on the previous Ubuntu LTS, not the newest: a binary built against a newer glibc may need that
# glibc to start, and the older one keeps the binaries running on older systems. GitHub retires an
# image once two newer ones are out. release.yml builds on the same images. Elsewhere the newest
# images; Intel macOS has no free -latest label, so its image is named.
runner:
- ubuntu-24.04
- ubuntu-24.04-arm
# macOS on Apple silicon is built for a release only, in release.yml.
# - macos-latest
- macos-26-intel
- windows-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# The jars compile with a Java 21 toolchain, which gradle.properties looks up in JDK21_HOME. On
# Linux and macOS Gradle also finds the runner's own JDK 21 by its location, on Windows it does not.
# Installed before GraalVM, so that Gradle itself still runs on GraalVM. No problem matcher: `build`
# annotates the warnings.
- name: Install JDK 21 for the jars
id: jdk21
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: '21'
problem-matcher: false
- name: Install GraalVM 25 for the image
uses: graalvm/setup-graalvm@60e76998d25690099182b796e99b8804da582d90 # v1.6.10
with:
java-version: '25'
distribution: 'graalvm-community'
github-token: ${{ secrets.GITHUB_TOKEN }}
# The same cache as in `build`.
- name: Cache Gradle's downloads
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
with:
gradle-home-cache-includes: |
caches
notifications
test-kit/caches/modules-2
gradle-home-cache-excludes: |
caches/build-cache-1
caches/modules-2/files-2.1/com.jetbrains.intellij.idea
caches/*/transforms
- name: Compile the native image
run: ./gradlew -PnativeImage=true :open-java-format-native:nativeCompile
env:
JDK21_HOME: ${{ steps.jdk21.outputs.path }}
# The binary itself on a file that needs formatting, a formatted one, one that does not parse and
# one in Java 25 syntax.
- name: Smoke-test the binary
run: |
binary="$PWD/$(ls open-java-format-native/build/native/nativeCompile/open-java-format-* | grep -v '\.txt$')"
mkdir smoke-test && cd smoke-test
"$binary" --version
printf 'class A{int x;}\n' > A.java
"$binary" --replace A.java
printf 'class A {\n int x;\n}\n' | diff - A.java
"$binary" --dry-run --set-exit-if-changed A.java
printf 'class B {\n' > B.java
set +e; "$binary" B.java; status=$?; set -e
test "$status" -eq 2
# Java 25 syntax: a compact source file with a module import and an unnamed pattern.
printf 'import module java.base;\nrecord Box(int a,int b){}\nvoid main(){Object o=new Box(1,2);if(o instanceof Box(_,_)){IO.println(List.of(1));}}\n' > C.java
"$binary" --replace C.java
printf 'import module java.base;\n\nrecord Box(int a, int b) {}\n\nvoid main() {\n Object o = new Box(1, 2);\n if (o instanceof Box(_, _)) {\n IO.println(List.of(1));\n }\n}\n' | diff - C.java
# Packaged as release.yml packages it for the GitHub release and the apt repository, under the version
# the binary prints.
- name: Find the binary and its version
id: binary
if: runner.os == 'Linux'
run: |
binary="$(ls open-java-format-native/build/native/nativeCompile/open-java-format-* | grep -v '\.txt$')"
echo "path=$binary" >> "$GITHUB_OUTPUT"
echo "version=$("$binary" --version 2>&1 | sed -n 's/^open-java-format: Version //p')" >> "$GITHUB_OUTPUT"
- name: Package and install the binary as a .deb
if: runner.os == 'Linux'
uses: $/.github/actions/deb-package
with:
binary: ${{ steps.binary.outputs.path }}
version: ${{ steps.binary.outputs.version }}
out-dir: ${{ runner.temp }}/deb-package
- name: Test the plugins against the image
run: >-
./gradlew -PnativeImage=true -PtestkitDir="$GRADLE_USER_HOME/test-kit"
:open-java-format-jdk-bootstrap:test :gradle-open-java-format:test
env:
JDK21_HOME: ${{ steps.jdk21.outputs.path }}
- name: Publish Test Report
uses: mikepenz/action-junit-report@a16be3a69023e9bd7e748ede768b3282ea7b30ce # v6.7.1
if: ${{ !cancelled() }}
with:
report_paths: '**/build/test-results/test/*.xml'
annotate_only: true
job_summary: true
# The WebAssembly module, built and tested as the release's `wasm` job does, so that a change that breaks it shows
# in its pull request rather than in a release. The module itself is not kept.
wasm:
name: wasm
needs: build
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# The jars compile with Java 21 through JDK21_HOME, as in `native`. Installed before GraalVM, so that Gradle
# still runs on GraalVM. No problem matcher: `build` annotates the warnings.
- name: Install JDK 21 for the jars
id: jdk21
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: '21'
problem-matcher: false
# The same release as in release.yml: Web Image is experimental, and its options and output change between
# releases.
- name: Install Oracle GraalVM 25 for the module
uses: graalvm/setup-graalvm@60e76998d25690099182b796e99b8804da582d90 # v1.6.10
with:
java-version: '25.0.4'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
# Web Image runs wasm-opt from the PATH, and needs Binaryen 119 or later; Ubuntu's package is older.
- name: Install Binaryen
env:
BINARYEN_VERSION: version_133
BINARYEN_SHA256: 2dc9c7813f5375db93d96ead4b78222fcc3e2677bbb832297af4797782a37489
run: |
archive="binaryen-${BINARYEN_VERSION}-x86_64-linux.tar.gz"
curl --fail --silent --show-error --location --output "${RUNNER_TEMP}/${archive}" \
"https://github.com/WebAssembly/binaryen/releases/download/${BINARYEN_VERSION}/${archive}"
echo "${BINARYEN_SHA256} ${RUNNER_TEMP}/${archive}" | sha256sum --check
tar -xzf "${RUNNER_TEMP}/${archive}" -C "${RUNNER_TEMP}"
echo "${RUNNER_TEMP}/binaryen-${BINARYEN_VERSION}/bin" >> "$GITHUB_PATH"
# Node 24 has the WebAssembly GC and exception handling the module needs.
- name: Install Node.js 24 for the tests
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '24'
package-manager-cache: false
# The same cache as in `build`.
- name: Cache Gradle's downloads
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
with:
gradle-home-cache-includes: |
caches
notifications
test-kit/caches/modules-2
gradle-home-cache-excludes: |
caches/build-cache-1
caches/modules-2/files-2.1/com.jetbrains.intellij.idea
caches/*/transforms
# wasmTest: the smoke test, then every Java 21 and Java 25 test case's input against the runnable jar.
- name: Build and test the module
run: ./gradlew -Pwasm=true :open-java-format-wasm:wasmTest
env:
JDK21_HOME: ${{ steps.jdk21.outputs.path }}