Format in one style with clear exit codes, and build a native binary … #107
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 | |
| # 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 | |
| - name: Install GraalVM 25 for the image | |
| uses: graalvm/setup-graalvm@5298d94fb55a4f185c602eeac5de1b553882abe2 # v1.6.4 | |
| 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 | |
| # The binary itself on a file that needs formatting, a formatted one and one that does not parse. | |
| # For the Windows binary this is the only check. | |
| - 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 | |
| # The Gradle plugin does not run a native image on Windows, and its tests have never run there. | |
| - name: Test the plugins against the image | |
| if: runner.os != 'Windows' | |
| run: ./gradlew -PnativeImage=true :open-java-format-jdk-bootstrap:test :gradle-open-java-format: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 |