Merge pull request #59 from openjavaformat/long-generic-field-type-go… #179
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| 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 | |
| - name: Install JDK 21 | |
| uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1 | |
| with: | |
| distribution: temurin | |
| java-version: '21' | |
| - name: Build | |
| run: ./gradlew test | |
| - name: Publish Test Report | |
| uses: mikepenz/action-junit-report@a9170d5795813c01ab4901ffb045b52bab4ab09d # v6.5.0 | |
| 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 main branch requires. | |
| jdk: | |
| name: build (JDK ${{ matrix.jdk }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - jdk: 25 | |
| gradle_args: '' | |
| gradle_args_reason: '' | |
| - jdk: 26 | |
| gradle_args: '' | |
| gradle_args_reason: '' | |
| - jdk: 27 | |
| gradle_args: -x :gradle-open-java-format:test | |
| gradle_args_reason: >- | |
| Gradle 9.7.1 does not run on Java 27 yet, and the Gradle plugin's tests run their TestKit builds on | |
| the test JVM, where they fail with "Unsupported class file major version 71". Those tests are left | |
| out until the wrapper's Gradle supports Java 27. | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Install JDK ${{ matrix.jdk }} for the tests | |
| id: test-jdk | |
| uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1 | |
| with: | |
| distribution: temurin | |
| java-version: ${{ matrix.jdk }} | |
| # Installed last, so that it is the JAVA_HOME Gradle runs and compiles on. | |
| - name: Install JDK 21 | |
| uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1 | |
| with: | |
| distribution: temurin | |
| java-version: '21' | |
| - 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. | |
| - name: Build | |
| run: >- | |
| ./gradlew test -PjavaRuntime=${{ matrix.jdk }} ${{ matrix.gradle_args }} | |
| -Porg.gradle.java.installations.paths=${{ steps.test-jdk.outputs.path }} | |
| - name: Publish Test Report | |
| uses: mikepenz/action-junit-report@a9170d5795813c01ab4901ffb045b52bab4ab09d # v6.5.0 | |
| 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.platform }}) | |
| 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: | |
| include: | |
| - platform: linux-x86-64 | |
| runner: ubuntu-latest | |
| - platform: linux-aarch64 | |
| runner: ubuntu-24.04-arm | |
| - platform: macos-aarch64 | |
| runner: macos-15 | |
| - platform: macos-x86-64 | |
| runner: macos-15-intel | |
| - platform: windows-x86-64 | |
| runner: windows-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| # 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. | |
| - name: Install JDK 21 for the jars | |
| id: jdk21 | |
| uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1 | |
| with: | |
| distribution: temurin | |
| java-version: '21' | |
| - name: Install GraalVM 25 for the image | |
| uses: graalvm/setup-graalvm@0426e2e191540e8514dff98dc52a5f5146a2a276 # v1.6.6 | |
| with: | |
| java-version: '25' | |
| distribution: 'graalvm-community' | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - 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 | |
| - name: Test the plugins against the image | |
| run: ./gradlew -PnativeImage=true :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@a9170d5795813c01ab4901ffb045b52bab4ab09d # v6.5.0 | |
| if: ${{ !cancelled() }} | |
| with: | |
| report_paths: '**/build/test-results/test/*.xml' | |
| annotate_only: true | |
| job_summary: true |