Build tests once and copy to other platforms to run #1598
Workflow file for this run
This file contains 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: build | |
on: | |
pull_request: {} | |
workflow_dispatch: {} | |
push: | |
branches: | |
- 'trunk' | |
tags-ignore: | |
- '**' | |
env: | |
GRADLE_OPTS: "-Dkotlin.incremental=false -Dorg.gradle.logging.stacktrace=full" | |
jobs: | |
terminal: | |
runs-on: macos-15 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version-file: .github/.java-version | |
- uses: goto-bus-stop/setup-zig@v2 | |
with: | |
version: 0.13.0 | |
- run: zig build -p src/jvmMain/resources/jni | |
working-directory: mosaic-terminal | |
- run: ./gradlew :mosaic-terminal:installJvmTestDistribution :mosaic-terminal:linkNativeDebugTests | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: jni-binaries | |
path: mosaic-terminal/src/jvmMain/resources/jni | |
if-no-files-found: error | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: mosaic-terminal-jvm-tests | |
path: mosaic-terminal/build/install/jvmTest | |
if-no-files-found: error | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: mosaic-terminal-native-tests | |
path: mosaic-terminal/build/bin | |
if-no-files-found: error | |
tests: | |
needs: | |
- terminal | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- os: macOS-13 | |
target: macosX64 | |
- os: macOS-14 | |
target: macosArm64 | |
- os: macOS-15 | |
target: macosArm64 | |
- os: ubuntu-20.04 | |
target: linuxX64 | |
- os: ubuntu-22.04 | |
target: linuxX64 | |
- os: ubuntu-24.04 | |
target: linuxX64 | |
- os: windows-2019 | |
target: mingwX64 | |
- os: windows-2022 | |
target: mingwX64 | |
tests: | |
- type: native | |
- type: java | |
version: 8 | |
- type: java | |
version: 11 | |
- type: java | |
version: 17 | |
- type: java | |
version: 21 | |
- type: java | |
version: latest | |
runs-on: ${{ matrix.platform.os }} | |
steps: | |
### NATIVE | |
- uses: actions/download-artifact@v4 | |
if: matrix.tests.type == 'native' | |
with: | |
name: mosaic-terminal-native-tests | |
- name: Set executable bit | |
if: ${{ matrix.tests.type == 'native' && !startsWith(matrix.platform.os, 'windows-') }} | |
run: chmod +x ${{ matrix.platform.target }}/debugTest/test.* | |
- run: ${{ matrix.platform.target }}/debugTest/test.* | |
if: matrix.tests.type == 'native' | |
### JAVA | |
- uses: actions/checkout@v4 | |
if: ${{ matrix.tests.type == 'java' && matrix.tests.version == 'latest' }} | |
with: | |
sparse-checkout: .github/.java-version | |
sparse-checkout-cone-mode: false | |
- uses: actions/setup-java@v4 | |
if: ${{ matrix.tests.type == 'java' && matrix.tests.version == 'latest' }} | |
with: | |
distribution: 'zulu' | |
java-version-file: .github/.java-version | |
- uses: actions/setup-java@v4 | |
if: ${{ matrix.tests.type == 'java' && matrix.tests.version != 'latest' }} | |
with: | |
distribution: 'zulu' | |
java-version: ${{ matrix.tests.version }} | |
- uses: actions/download-artifact@v4 | |
if: matrix.tests.type == 'java' | |
with: | |
name: mosaic-terminal-jvm-tests | |
- name: Set executable bit | |
if: ${{ matrix.tests.type == 'java' && !startsWith(matrix.platform.os, 'windows-') }} | |
run: chmod +x bin/mosaic-terminal-test | |
- run: bin/mosaic-terminal-test | |
if: matrix.tests.type == 'java' | |
binaries: | |
runs-on: macos-15 | |
needs: | |
- terminal | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: jni-binaries | |
path: mosaic-terminal/src/jvmMain/resources/jni | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version-file: .github/.java-version | |
- uses: gradle/actions/setup-gradle@v4 | |
- run: ./gradlew --continue assemble | |
checks: | |
runs-on: macos-15 | |
needs: | |
- terminal | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: jni-binaries | |
path: mosaic-terminal/src/jvmMain/resources/jni | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version-file: .github/.java-version | |
- uses: gradle/actions/setup-gradle@v4 | |
- run: ./gradlew --continue spotlessCheck apiCheck | |
publish: | |
runs-on: macos-15 | |
needs: | |
- binaries | |
- checks | |
- tests | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: jni-binaries | |
path: mosaic-terminal/src/jvmMain/resources/jni | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version-file: .github/.java-version | |
- uses: gradle/actions/setup-gradle@v4 | |
- run: ./gradlew publish | |
if: ${{ github.ref == 'refs/heads/trunk' && github.repository == 'JakeWharton/mosaic' }} | |
env: | |
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} | |
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} | |
- run: ./gradlew dokkaHtmlMultiModule | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: html-docs | |
path: build/dokka/htmlMultiModule/ | |
if-no-files-found: error | |
- uses: JamesIves/github-pages-deploy-action@releases/v3 | |
if: ${{ github.ref == 'refs/heads/trunk' && github.repository == 'JakeWharton/mosaic' }} | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
BRANCH: site | |
FOLDER: build/dokka/htmlMultiModule/ | |
TARGET_FOLDER: docs/latest/ | |
CLEAN: true |