|
| 1 | +name: Native CPU multi-arch build |
| 2 | + |
| 3 | +# Cross-arch CI for the FFM native kernel provider |
| 4 | +# (skainet-backends/skainet-backend-native-cpu). The local Gradle build |
| 5 | +# only produces a host-arch .so/.dylib/.dll; this workflow proves the |
| 6 | +# CMake + Kotlin pipeline works on every supported host so consumers |
| 7 | +# on Apple Silicon, ARM Linux, and Windows aren't silently broken when |
| 8 | +# they pull a published JAR built on x86_64 Linux. |
| 9 | +# |
| 10 | +# Each matrix job runs the native module's jvmTest end-to-end (CMake |
| 11 | +# configure + build + bundle into JAR resources + parity tests via |
| 12 | +# FFM downcall). The built shared library is uploaded as an artifact |
| 13 | +# so a later "fat-JAR" aggregation step (deferred to a follow-up PR) |
| 14 | +# can stage all four arches into one publishable artifact. |
| 15 | + |
| 16 | +on: |
| 17 | + push: |
| 18 | + branches: [main, develop] |
| 19 | + paths: |
| 20 | + - 'skainet-backends/skainet-backend-native-cpu/**' |
| 21 | + - 'skainet-backends/skainet-backend-api/src/jvmMain/kotlin/sk/ainet/backend/api/kernel/**' |
| 22 | + - '.github/workflows/native-cpu-multiarch.yml' |
| 23 | + pull_request: |
| 24 | + paths: |
| 25 | + - 'skainet-backends/skainet-backend-native-cpu/**' |
| 26 | + - 'skainet-backends/skainet-backend-api/src/jvmMain/kotlin/sk/ainet/backend/api/kernel/**' |
| 27 | + - '.github/workflows/native-cpu-multiarch.yml' |
| 28 | + |
| 29 | +concurrency: |
| 30 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 31 | + cancel-in-progress: true |
| 32 | + |
| 33 | +jobs: |
| 34 | + native-build-test: |
| 35 | + name: ${{ matrix.arch_label }} |
| 36 | + strategy: |
| 37 | + fail-fast: false |
| 38 | + matrix: |
| 39 | + include: |
| 40 | + - os: ubuntu-latest |
| 41 | + arch_label: linux-x86_64 |
| 42 | + lib_name: libskainet_kernels.so |
| 43 | + - os: ubuntu-24.04-arm |
| 44 | + arch_label: linux-arm64 |
| 45 | + lib_name: libskainet_kernels.so |
| 46 | + - os: macos-14 |
| 47 | + arch_label: macos-arm64 |
| 48 | + lib_name: libskainet_kernels.dylib |
| 49 | + - os: windows-latest |
| 50 | + arch_label: windows-x86_64 |
| 51 | + lib_name: skainet_kernels.dll |
| 52 | + runs-on: ${{ matrix.os }} |
| 53 | + timeout-minutes: 30 |
| 54 | + |
| 55 | + steps: |
| 56 | + - name: Checkout |
| 57 | + uses: actions/checkout@v6 |
| 58 | + |
| 59 | + - name: Copy CI gradle.properties (Unix) |
| 60 | + if: runner.os != 'Windows' |
| 61 | + run: | |
| 62 | + mkdir -p ~/.gradle |
| 63 | + cp .github/ci-gradle.properties ~/.gradle/gradle.properties |
| 64 | +
|
| 65 | + - name: Copy CI gradle.properties (Windows) |
| 66 | + if: runner.os == 'Windows' |
| 67 | + shell: pwsh |
| 68 | + run: | |
| 69 | + New-Item -ItemType Directory -Force -Path "$HOME\.gradle" | Out-Null |
| 70 | + Copy-Item .github\ci-gradle.properties "$HOME\.gradle\gradle.properties" |
| 71 | +
|
| 72 | + - name: Set up JDK 25 |
| 73 | + uses: actions/setup-java@v5 |
| 74 | + with: |
| 75 | + distribution: 'zulu' |
| 76 | + java-version: 25 |
| 77 | + |
| 78 | + - name: Verify cmake |
| 79 | + run: cmake --version |
| 80 | + |
| 81 | + - name: Build + test native module (Unix) |
| 82 | + if: runner.os != 'Windows' |
| 83 | + env: |
| 84 | + GRADLE_OPTS: -Dorg.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8 |
| 85 | + run: | |
| 86 | + ./gradlew --no-daemon --stacktrace \ |
| 87 | + :skainet-backends:skainet-backend-native-cpu:jvmTest \ |
| 88 | + :skainet-backends:skainet-backend-native-cpu:jvmJar |
| 89 | +
|
| 90 | + - name: Build + test native module (Windows) |
| 91 | + if: runner.os == 'Windows' |
| 92 | + shell: pwsh |
| 93 | + env: |
| 94 | + GRADLE_OPTS: -Dorg.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8 |
| 95 | + run: | |
| 96 | + .\gradlew.bat --no-daemon --stacktrace ` |
| 97 | + :skainet-backends:skainet-backend-native-cpu:jvmTest ` |
| 98 | + :skainet-backends:skainet-backend-native-cpu:jvmJar |
| 99 | +
|
| 100 | + - name: Upload native library |
| 101 | + if: success() |
| 102 | + uses: actions/upload-artifact@v7 |
| 103 | + with: |
| 104 | + name: libskainet_kernels-${{ matrix.arch_label }} |
| 105 | + path: skainet-backends/skainet-backend-native-cpu/build/native/resources/native/${{ matrix.arch_label }}/${{ matrix.lib_name }} |
| 106 | + if-no-files-found: error |
| 107 | + retention-days: 14 |
| 108 | + |
| 109 | + - name: Upload test reports |
| 110 | + if: always() |
| 111 | + uses: actions/upload-artifact@v7 |
| 112 | + with: |
| 113 | + name: native-cpu-test-reports-${{ matrix.arch_label }} |
| 114 | + path: | |
| 115 | + skainet-backends/skainet-backend-native-cpu/build/reports/tests/** |
| 116 | + skainet-backends/skainet-backend-native-cpu/build/test-results/** |
| 117 | + retention-days: 14 |
0 commit comments