|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: ci-${{ github.ref }} |
| 14 | + cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 15 | + |
| 16 | +jobs: |
| 17 | + # Compiles everything, runs the whole test suite, and — because the GraalVM |
| 18 | + # plugin wires `nativeCompile` into `assemble` — also produces the |
| 19 | + # linux-x86-64 native image. This is the job every other one depends on. |
| 20 | + build: |
| 21 | + name: build (linux-x86-64) |
| 22 | + runs-on: ubuntu-24.04 |
| 23 | + timeout-minutes: 90 |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 |
| 26 | + with: |
| 27 | + # gradle-git-version derives the project version from `git describe`, |
| 28 | + # so it needs the full history and all tags. |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + - name: Cache JDKs provisioned by gradle-jdks |
| 32 | + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 |
| 33 | + with: |
| 34 | + path: ~/.gradle/gradle-jdks |
| 35 | + key: gradle-jdks-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('gradle/jdks/**', 'gradle/gradle-daemon-jdk-version') }} |
| 36 | + |
| 37 | + # gradle/actions/setup-gradle needs a JVM on PATH. This is only a bootstrap: |
| 38 | + # the Gradle daemon and every toolchain come from gradle-jdks (gradle/jdks/**), |
| 39 | + # because gradle.properties disables installation auto-detection. Kept in sync |
| 40 | + # with gradle/gradle-daemon-jdk-version. |
| 41 | + - name: Set up a bootstrap JDK |
| 42 | + uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.9.1 |
| 43 | + with: |
| 44 | + distribution: temurin |
| 45 | + java-version: '21' |
| 46 | + |
| 47 | + - uses: gradle/actions/setup-gradle@748248ddd2a24f49513d8f472f81c3a07d4d50e1 # v4.4.4 |
| 48 | + with: |
| 49 | + # Only the default branch writes to the shared Gradle cache; every |
| 50 | + # other ref reads it. Avoids pinning the trunk name in two places. |
| 51 | + cache-read-only: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} |
| 52 | + |
| 53 | + - name: Build |
| 54 | + run: ./gradlew --stacktrace --continue build |
| 55 | + |
| 56 | + - name: Upload native image |
| 57 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 58 | + with: |
| 59 | + name: native-image-linux-x86-64 |
| 60 | + path: palantir-java-format-native/build/native/nativeCompile/* |
| 61 | + if-no-files-found: error |
| 62 | + |
| 63 | + - name: Upload jars and plugin distributions |
| 64 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 65 | + with: |
| 66 | + name: jars |
| 67 | + path: | |
| 68 | + */build/libs/*.jar |
| 69 | + idea-plugin/build/distributions/*.zip |
| 70 | + if-no-files-found: error |
| 71 | + |
| 72 | + - name: Upload test results |
| 73 | + if: always() |
| 74 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 75 | + with: |
| 76 | + name: test-results-linux-x86-64 |
| 77 | + path: '**/build/test-results/**/*.xml' |
| 78 | + if-no-files-found: warn |
| 79 | + |
| 80 | + # The platforms the linux-x86-64 job cannot produce. One explicit job per |
| 81 | + # target, so every published binary is traceable to a named workflow run. |
| 82 | + native: |
| 83 | + name: nativeCompile (${{ matrix.platform }}) |
| 84 | + needs: build |
| 85 | + runs-on: ${{ matrix.runner }} |
| 86 | + timeout-minutes: 90 |
| 87 | + strategy: |
| 88 | + fail-fast: false |
| 89 | + matrix: |
| 90 | + include: |
| 91 | + - platform: linux-aarch64 |
| 92 | + runner: ubuntu-24.04-arm |
| 93 | + - platform: macos-aarch64 |
| 94 | + runner: macos-15 |
| 95 | + steps: |
| 96 | + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 |
| 97 | + with: |
| 98 | + fetch-depth: 0 |
| 99 | + |
| 100 | + - name: Cache JDKs provisioned by gradle-jdks |
| 101 | + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 |
| 102 | + with: |
| 103 | + path: ~/.gradle/gradle-jdks |
| 104 | + key: gradle-jdks-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('gradle/jdks/**', 'gradle/gradle-daemon-jdk-version') }} |
| 105 | + |
| 106 | + # gradle/actions/setup-gradle needs a JVM on PATH. This is only a bootstrap: |
| 107 | + # the Gradle daemon and every toolchain come from gradle-jdks (gradle/jdks/**), |
| 108 | + # because gradle.properties disables installation auto-detection. Kept in sync |
| 109 | + # with gradle/gradle-daemon-jdk-version. |
| 110 | + - name: Set up a bootstrap JDK |
| 111 | + uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.9.1 |
| 112 | + with: |
| 113 | + distribution: temurin |
| 114 | + java-version: '21' |
| 115 | + |
| 116 | + - uses: gradle/actions/setup-gradle@748248ddd2a24f49513d8f472f81c3a07d4d50e1 # v4.4.4 |
| 117 | + with: |
| 118 | + cache-read-only: true |
| 119 | + |
| 120 | + - name: Compile native image |
| 121 | + run: ./gradlew --stacktrace :palantir-java-format-native:nativeCompile |
| 122 | + |
| 123 | + - name: Upload native image |
| 124 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 125 | + with: |
| 126 | + name: native-image-${{ matrix.platform }} |
| 127 | + path: palantir-java-format-native/build/native/nativeCompile/* |
| 128 | + if-no-files-found: error |
0 commit comments