|
| 1 | +--- |
| 2 | +name: "ci_checks" |
| 3 | +on: |
| 4 | + pull_request: null |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - "main" |
| 8 | + - "initial-version" |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + force_gradle_cache_clean: |
| 12 | + description: "Force gradle cache clean" |
| 13 | + required: false |
| 14 | + default: "false" |
| 15 | +concurrency: |
| 16 | + group: "${{ github.workflow }}-${{ github.ref }}" |
| 17 | + cancel-in-progress: true |
| 18 | +jobs: |
| 19 | + gradleCheck: |
| 20 | + name: "run checks using gradlew" |
| 21 | + runs-on: "ubuntu-latest" |
| 22 | + outputs: |
| 23 | + RELEASE_VERSION: ${{ steps.get_version.outputs.VERSION }} |
| 24 | + env: |
| 25 | + SEGMENT_DOWNLOAD_TIMEOUT_MINS: "15" |
| 26 | + steps: |
| 27 | + - name: "Checkout" |
| 28 | + uses: "actions/checkout@v4" |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
| 31 | + - name: "Install JDK 21" |
| 32 | + uses: "actions/setup-java@v4" |
| 33 | + with: |
| 34 | + distribution: "graalvm" |
| 35 | + java-version: 21 |
| 36 | + - name: "Install Node.js" |
| 37 | + uses: actions/setup-node@v4 |
| 38 | + with: |
| 39 | + node-version: "lts/jod" # 22 |
| 40 | + - name: "debug node" |
| 41 | + run: "node --version && npm --version" |
| 42 | + - name: "Setup Gradle" |
| 43 | + uses: "gradle/actions/setup-gradle@v4" |
| 44 | + with: |
| 45 | + cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/initial-version' }} # TODO remove when initial-version is removed |
| 46 | + - name: "Nuke gradle cache" |
| 47 | + if: "${{ github.event.inputs.force_gradle_cache_clean == 'true' }}" |
| 48 | + run: "rm -rf ~/.gradle/caches" |
| 49 | + - name: "Run check on build-logic subproject" |
| 50 | + run: "./gradlew :build-logic:check --no-configuration-cache" |
| 51 | + - name: "Run check on project" |
| 52 | + run: "./gradlew generateUsage && ./gradlew check" |
| 53 | + - name: "Get version and set to output" |
| 54 | + id: get_version |
| 55 | + run: echo "VERSION=$(./gradlew changelogPrintCurrentVersion --quiet)" >> "$GITHUB_OUTPUT" |
| 56 | + - name: "junit result" |
| 57 | + uses: "mikepenz/action-junit-report@v5" |
| 58 | + if: "always()" |
| 59 | + with: |
| 60 | + check_name: "JUnit Report" |
| 61 | + report_paths: "**/build/test-results/tes*/*.xml" # multiple test tasks |
| 62 | + nativeCompile: |
| 63 | + name: "${{ matrix.platform.name }} nativeCompile testing" |
| 64 | + needs: "gradleCheck" |
| 65 | + strategy: |
| 66 | + matrix: |
| 67 | + platform: |
| 68 | + - name: "linux-x86_64" |
| 69 | + runner: "ubuntu-latest" |
| 70 | + - name: "linux-aarch_64" |
| 71 | + runner: "ubuntu-24.04-arm" |
| 72 | + - name: "windows-x86_64" |
| 73 | + runner: "windows-latest" |
| 74 | + - name: "osx-aarch_64" |
| 75 | + runner: "macos-latest" |
| 76 | + - name: "osx-x86_64" |
| 77 | + runner: "macos-13" |
| 78 | + fail-fast: false |
| 79 | + runs-on: "${{ matrix.platform.runner }}" |
| 80 | + env: |
| 81 | + SEGMENT_DOWNLOAD_TIMEOUT_MINS: "15" |
| 82 | + steps: |
| 83 | + - name: "Checkout" |
| 84 | + uses: "actions/checkout@v4" |
| 85 | + with: |
| 86 | + fetch-depth: 0 |
| 87 | + - name: "Install JDK 21" |
| 88 | + uses: "actions/setup-java@v4" |
| 89 | + with: |
| 90 | + distribution: "graalvm" |
| 91 | + java-version: 21 |
| 92 | + - name: "Install Node.js" |
| 93 | + uses: actions/setup-node@v4 |
| 94 | + with: |
| 95 | + node-version: "lts/jod" # 22 |
| 96 | + - name: "Setup Gradle" |
| 97 | + uses: "gradle/actions/setup-gradle@v4" |
| 98 | + with: |
| 99 | + cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/initial-version' }} # TODO remove when initial-version is removed |
| 100 | + - name: "Check if binary works" |
| 101 | + run: "./gradlew testAllCliNative" |
| 102 | + - name: "junit result" |
| 103 | + uses: "mikepenz/action-junit-report@v5" |
| 104 | + if: "always()" |
| 105 | + with: |
| 106 | + check_name: "JUnit Report ${{ matrix.platform.name }}" |
| 107 | + report_paths: "**/build/test-results/tes*/*.xml" # multiple test tasks |
| 108 | + - name: "upload binary" # for debugging |
| 109 | + uses: actions/upload-artifact@v4 |
| 110 | + with: |
| 111 | + name: "spotless-native-binary--${{ matrix.platform.name }}" |
| 112 | + path: app/build/native/nativeCompile/spotless* |
| 113 | + retention-days: 7 |
| 114 | + if-no-files-found: "error" |
| 115 | + |
| 116 | + dryRunRelease: |
| 117 | + name: "dry run release" |
| 118 | + needs: ["gradleCheck", "nativeCompile"] |
| 119 | + strategy: |
| 120 | + matrix: |
| 121 | + platform: |
| 122 | + - name: "linux-x86_64" |
| 123 | + runner: "ubuntu-latest" |
| 124 | + - name: "windows-x86_64" |
| 125 | + runner: "windows-latest" |
| 126 | + runs-on: "${{ matrix.platform.runner }}" |
| 127 | + steps: |
| 128 | + - name: "Checkout" |
| 129 | + uses: "actions/checkout@v4" |
| 130 | + with: |
| 131 | + fetch-depth: 0 |
| 132 | + - name: "Install JDK 21" |
| 133 | + uses: "actions/setup-java@v4" |
| 134 | + with: |
| 135 | + distribution: "graalvm" |
| 136 | + java-version: 21 |
| 137 | + - name: "Setup Gradle" |
| 138 | + uses: "gradle/actions/setup-gradle@v4" |
| 139 | + - name: "Retrieve binaries" |
| 140 | + uses: "actions/download-artifact@v4" |
| 141 | + with: |
| 142 | + # no name - download all artifacts |
| 143 | + path: "app/build/collected-binaries" |
| 144 | + - name: "Prepare release zips for distribution" |
| 145 | + run: "./gradlew -PreleaseBinariesRootDir=app/build/collected-binaries prepareReleaseBinaryZips" |
| 146 | + - name: "Prepare jreleaser for distribution" |
| 147 | + run: "./gradlew prepareJReleaserConfig" |
| 148 | + - name: "Dry-run choco distribution" |
| 149 | + if: "${{ matrix.platform.name == 'windows-x86_64' }}" |
| 150 | + uses: jreleaser/release-action@v2 |
| 151 | + with: |
| 152 | + setup-java: false |
| 153 | + arguments: "publish --dry-run" |
| 154 | + env: |
| 155 | + JRELEASER_PROJECT_VERSION: ${{ needs.gradleCheck.outputs.RELEASE_VERSION }} |
| 156 | + JRELEASER_GITHUB_TOKEN: abc # don't provide correct token, just a dry-run |
| 157 | + JRELEASER_DISTRIBUTIONS_SPOTLESS_CLI_CHOCOLATEY_ACTIVE: ALWAYS |
| 158 | + JRELEASER_CHOCOLATEY_GITHUB_TOKEN: abc # don't provide correct token, just a dry-run |
| 159 | + JRELEASER_CHOCOLATEY_USER: abc # don't provide correct token, just a dry-run |
| 160 | + JRELEASER_CHOCOLATEY_API_KEY: abc # don't provide correct token, just a dry-run |
| 161 | + - name: "Dry-run brew distribution" |
| 162 | + if: "${{ matrix.platform.name == 'linux-x86_64' }}" |
| 163 | + uses: jreleaser/release-action@v2 |
| 164 | + with: |
| 165 | + setup-java: false |
| 166 | + arguments: "publish --dry-run" |
| 167 | + env: |
| 168 | + JRELEASER_PROJECT_VERSION: ${{ needs.gradleCheck.outputs.RELEASE_VERSION }} |
| 169 | + JRELEASER_GITHUB_TOKEN: abc # don't provide correct token, just a dry-run |
| 170 | + JRELEASER_DISTRIBUTIONS_SPOTLESS_CLI_BREW_ACTIVE: ALWAYS |
| 171 | + JRELEASER_HOMEBREW_GITHUB_TOKEN: abc # don't provide correct token, just a dry-run |
| 172 | + - name: "Persist jreleaser output" |
| 173 | + if: always() |
| 174 | + uses: actions/upload-artifact@v4 |
| 175 | + with: |
| 176 | + name: "jreleaser-distribution-dry-run--${{ matrix.platform.name }}" |
| 177 | + path: | |
| 178 | + out/jreleaser/trace.log |
| 179 | + out/jreleaser/output.properties |
| 180 | + out/jreleaser/package/spotless-cli/** |
0 commit comments