Build & Test #163
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
| # This workflow builds, tests, and optionally releases the project. | |
| # Release jobs run only on the luhenry repository when a v* tag is pushed. | |
| name: Build & Test | |
| on: | |
| push: | |
| branches: [ master ] | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: [ master ] | |
| workflow_dispatch: | |
| jobs: | |
| build-macos-natives: | |
| name: "Build: macOS Natives" | |
| runs-on: macos-26 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache M2 local repository | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2/repository | |
| key: m2 | |
| - name: Set up JDK 25 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 25 | |
| distribution: temurin | |
| - name: Build | |
| run: mvn --batch-mode --no-transfer-progress compile | |
| - name: Upload macOS natives | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: macos-natives | |
| path: | | |
| */target/native/macos-*/ | |
| if-no-files-found: error | |
| build-windows-natives: | |
| name: "Build: Windows Natives" | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache M2 local repository | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2/repository | |
| key: m2 | |
| - name: Set up JDK 25 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 25 | |
| distribution: temurin | |
| - name: Set up MSYS2 (UCRT64) | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: UCRT64 | |
| update: false | |
| install: >- | |
| mingw-w64-ucrt-x86_64-gcc | |
| mingw-w64-ucrt-x86_64-dlfcn | |
| make | |
| - name: Add MSYS2 UCRT64 to PATH | |
| shell: msys2 {0} | |
| run: echo "$(cygpath -w /ucrt64/bin)" >> $GITHUB_PATH | |
| - name: Build | |
| run: mvn --batch-mode --no-transfer-progress compile | |
| - name: Upload Windows natives | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-natives | |
| path: | | |
| */target/native/windows-*/ | |
| if-no-files-found: error | |
| build-jar: | |
| name: "Build: Packaging JARs" | |
| runs-on: ubuntu-latest | |
| needs: [build-macos-natives, build-windows-natives] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache M2 local repository | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2/repository | |
| key: m2 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get -y update | |
| sudo apt-get -y install gcc-aarch64-linux-gnu gcc-riscv64-linux-gnu gcc-x86-64-linux-gnu | |
| - name: Set up JDK 25 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 25 | |
| distribution: temurin | |
| - name: Download macOS natives | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: macos-natives | |
| path: . | |
| - name: Download Windows natives | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: windows-natives | |
| path: . | |
| - name: Build | |
| run: mvn --batch-mode --no-transfer-progress package -DskipTests | |
| - name: Log content of jar files | |
| run: | | |
| for module in blas lapack arpack; do | |
| echo "=== Contents of ${module}/target/${module}-*.jar:" | |
| jar tf ${module}/target/${module}-*.jar | |
| done | |
| - name: Upload target folder | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: target-dir | |
| path: | | |
| */target/ | |
| if-no-files-found: error | |
| test-linux: | |
| name: "Test: runs-on: ${{ matrix.runs-on }}, jdk: ${{ matrix.jdk }}" | |
| runs-on: ${{ matrix.runs-on }} | |
| needs: [build-jar] | |
| strategy: | |
| matrix: | |
| jdk: [8, 11, 17, 21, 25] | |
| runs-on: [ubuntu-24.04, ubuntu-24.04-arm, ubuntu-24.04-riscv] | |
| exclude: | |
| # Java 8 and 11 are not available on RISC-V | |
| - runs-on: ubuntu-24.04-riscv | |
| jdk: 8 | |
| - runs-on: ubuntu-24.04-riscv | |
| jdk: 11 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache M2 local repository | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2/repository | |
| key: m2 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get -y update | |
| sudo apt-get -y install libopenblas-dev libarpack2-dev | |
| - name: Download target folder | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: target-dir | |
| path: . | |
| - name: Set up JDK ${{ matrix.jdk }} | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: ${{ matrix.jdk }} | |
| distribution: temurin | |
| - name: Test | |
| run: mvn --batch-mode --no-transfer-progress --projects test-utils,blas,lapack,arpack test --fail-at-end -Dmaven.main.skip=true -Dmaven.antrun.skip=true | |
| test-macos: | |
| name: "Test: runs-on: ${{ matrix.runs-on }}, jdk: ${{ matrix.jdk }}" | |
| runs-on: ${{ matrix.runs-on }} | |
| needs: [build-jar] | |
| strategy: | |
| matrix: | |
| jdk: [11, 17, 21, 25] | |
| runs-on: [macos-15-intel, macos-26] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache M2 local repository | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2/repository | |
| key: m2 | |
| - name: Install dependencies | |
| run: brew install arpack | |
| - name: Download target folder | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: target-dir | |
| path: . | |
| - name: Set up JDK ${{ matrix.jdk }} | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: ${{ matrix.jdk }} | |
| distribution: temurin | |
| - name: Test | |
| run: mvn --batch-mode --no-transfer-progress --projects test-utils,blas,lapack,arpack test --fail-at-end -Dmaven.main.skip=true -Dmaven.antrun.skip=true | |
| test-windows: | |
| name: "Test: runs-on: windows-latest, jdk: ${{ matrix.jdk }}" | |
| runs-on: windows-latest | |
| needs: [build-jar] | |
| strategy: | |
| matrix: | |
| jdk: [11, 17, 21, 25] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache M2 local repository | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2/repository | |
| key: m2 | |
| - name: Set up MSYS2 (UCRT64) with OpenBLAS | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: UCRT64 | |
| update: false | |
| install: mingw-w64-ucrt-x86_64-openblas | |
| - name: Add MSYS2 ucrt64 bin to PATH | |
| shell: msys2 {0} | |
| run: echo "$(cygpath -w /ucrt64/bin)" >> $GITHUB_PATH | |
| - name: Download target folder | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: target-dir | |
| path: . | |
| - name: Set up JDK ${{ matrix.jdk }} | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: ${{ matrix.jdk }} | |
| distribution: temurin | |
| - name: Test | |
| run: mvn --batch-mode --no-transfer-progress --projects test-utils,blas test --fail-at-end "-Dmaven.main.skip=true" "-Dmaven.antrun.skip=true" | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| needs: [build-jar, test-linux, test-macos, test-windows] | |
| if: github.repository == 'luhenry/netlib' && startsWith(github.ref, 'refs/tags/v') | |
| outputs: | |
| release_upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache M2 local repository | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2/repository | |
| key: m2 | |
| - name: Download target folder | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: target-dir | |
| path: . | |
| - name: Set up JDK 25 | |
| uses: actions/setup-java@v4 | |
| with: # running setup-java again overwrites the settings.xml | |
| java-version: 25 | |
| distribution: temurin | |
| server-id: central | |
| server-username: MAVEN_USERNAME | |
| server-password: MAVEN_PASSWORD | |
| gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | |
| - name: Publish to Sonatype OSSRH | |
| run: mvn --batch-mode --no-transfer-progress -DskipTests -Dmaven.main.skip=true -Dmaven.antrun.skip=true -Dmaven.install.skip deploy | |
| env: | |
| MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
| MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | |
| - name: Create Release | |
| id: create_release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref }} | |
| name: ${{ github.ref }} | |
| draft: true | |
| benchmark: | |
| name: Run benchmarks | |
| runs-on: [self-hosted, linux, x64] | |
| needs: [release, build-jar] | |
| if: github.repository == 'luhenry/netlib' && startsWith(github.ref, 'refs/tags/v') | |
| strategy: | |
| matrix: | |
| jdk: [8, 11, 17] | |
| implementation: ["java", "native"] | |
| filter: ["dev.ludovic.netlib.benchmarks.blas.l1", "dev.ludovic.netlib.benchmarks.blas.l2", "dev.ludovic.netlib.benchmarks.blas.l3"] | |
| include: | |
| - jdk: 17 | |
| implementation: "java" | |
| filter: "dev.ludovic.netlib.benchmarks.blas.l1" | |
| jvmArgs: "--add-modules=jdk.incubator.vector,jdk.incubator.foreign -Dforeign.restricted=permit" | |
| - jdk: 17 | |
| implementation: "java" | |
| filter: "dev.ludovic.netlib.benchmarks.blas.l2" | |
| jvmArgs: "--add-modules=jdk.incubator.vector,jdk.incubator.foreign -Dforeign.restricted=permit" | |
| - jdk: 17 | |
| implementation: "java" | |
| filter: "dev.ludovic.netlib.benchmarks.blas.l3" | |
| jvmArgs: "--add-modules=jdk.incubator.vector,jdk.incubator.foreign -Dforeign.restricted=permit" | |
| steps: | |
| - name: Set up JDK ${{ matrix.jdk }} | |
| uses: actions/setup-java@v1 | |
| with: | |
| java-version: ${{ matrix.jdk }} | |
| - name: Download Benchmarks | |
| id: download_benchmarks | |
| uses: actions/download-artifact@v2 | |
| with: | |
| name: benchmarks | |
| - name: Run benchmark | |
| run: java -jar "${{steps.download_benchmarks.outputs.download-path}}/netlib-benchmarks.jar" "${{ matrix.filter }}" -p "implementation=${{ matrix.implementation }}" -jvmArgs "${{ matrix.jvmArgs }}" -rf json -rff "jmh-results-jdk${{ matrix.jdk }}-${{ matrix.filter }}-${{ matrix.implementation }}.json" | |
| - name: Upload JMH results | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ needs.release.outputs.release_upload_url }} | |
| asset_path: jmh-results-jdk${{ matrix.jdk }}-${{ matrix.filter }}-${{ matrix.implementation }}.json | |
| asset_name: jmh-results-jdk${{ matrix.jdk }}-${{ matrix.filter }}-${{ matrix.implementation }}.json | |
| asset_content_type: application/json |