name: CI

on:
  push:
    branches: [ 'master', 'main', 'release/**' ]
  pull_request:
    branches: [ 'master' ]

jobs:
  # Oracle JDK (Linux, Mac)
  linux-oracle:
    strategy:
      matrix:
        os: [ 'ubuntu-latest', 'macos-latest' ]
        jdk_version: [ '17', '21' ]
        wolfssl_configure: [ '--enable-jni' ]
    name: ${{ matrix.os }} (Oracle JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure}})
    uses: ./.github/workflows/linux-common.yml
    with:
      os: ${{ matrix.os }}
      jdk_distro: "oracle"
      jdk_version: ${{ matrix.jdk_version }}
      wolfssl_configure: ${{ matrix.wolfssl_configure }}

  # Zulu JDK (Linux, Mac)
  linux-zulu:
    strategy:
      matrix:
        os: [ 'ubuntu-latest', 'macos-latest' ]
        jdk_version: [ '8', '11', '17', '21' ]
        wolfssl_configure: [ '--enable-jni' ]
    name: ${{ matrix.os }} (Zulu JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure}})
    uses: ./.github/workflows/linux-common.yml
    with:
      os: ${{ matrix.os }}
      jdk_distro: "zulu"
      jdk_version: ${{ matrix.jdk_version }}
      wolfssl_configure: ${{ matrix.wolfssl_configure }}

  # Corretto JDK (Linux, Mac)
  linux-corretto:
    strategy:
      matrix:
        os: [ 'ubuntu-latest', 'macos-latest' ]
        jdk_version: [ '8', '11', '17', '21' ]
        wolfssl_configure: [ '--enable-jni' ]
    name: ${{ matrix.os }} (Corretto JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure}})
    uses: ./.github/workflows/linux-common.yml
    with:
      os: ${{ matrix.os }}
      jdk_distro: "corretto"
      jdk_version: ${{ matrix.jdk_version }}
      wolfssl_configure: ${{ matrix.wolfssl_configure }}

  # Corretto JDK (Linux, Mac) Aarch64 with armasm
  linux-corretto-aarch64-armasm:
    strategy:
      matrix:
        os: [ 'ubuntu-24.04-arm' ]
        jdk_version: [ '8', '11', '17', '21' ]
        wolfssl_configure: [ '--enable-jni --enable-armasm' ]
    name: ${{ matrix.os }} (Corretto JDK Aarch64 armasm ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure}})
    uses: ./.github/workflows/linux-common.yml
    with:
      os: ${{ matrix.os }}
      jdk_distro: "corretto"
      jdk_version: ${{ matrix.jdk_version }}
      wolfssl_configure: ${{ matrix.wolfssl_configure }}

  # Temurin JDK (Linux, Mac)
  # JDK 8 seems to have been removed from Temurin macos, with 8 we see the error
  # Could not find satisfied version for SemVer '8'
  linux-temurin:
    strategy:
      matrix:
        os: [ 'ubuntu-latest', 'macos-latest' ]
        jdk_version: [ '11', '17', '21' ]
        wolfssl_configure: [ '--enable-jni' ]
    name: ${{ matrix.os }} (Temurin JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure}})
    uses: ./.github/workflows/linux-common.yml
    with:
      os: ${{ matrix.os }}
      jdk_distro: "temurin"
      jdk_version: ${{ matrix.jdk_version }}
      wolfssl_configure: ${{ matrix.wolfssl_configure }}

  # Microsoft JDK (Linux, Mac)
  linux-microsoft:
    strategy:
      matrix:
        os: [ 'ubuntu-latest', 'macos-latest' ]
        jdk_version: [ '11.0.19', '17.0.7', '21.0.0' ]
        wolfssl_configure: [ '--enable-jni' ]
    name: ${{ matrix.os }} (Microsoft JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure}})
    uses: ./.github/workflows/linux-common.yml
    with:
      os: ${{ matrix.os }}
      jdk_distro: "microsoft"
      jdk_version: ${{ matrix.jdk_version }}
      wolfssl_configure: ${{ matrix.wolfssl_configure }}

  # -------------------- enable-all sanity checks -----------------------
  # Only check one Linux and Mac JDK version with --enable-jni --enable-all
  # as sanity. Using Zulu, but this can be expanded if needed.
  linux-zulu-all:
    strategy:
      matrix:
        os: [ 'ubuntu-latest', 'macos-latest' ]
        jdk_version: [ '11' ]
        wolfssl_configure: [ '--enable-jni --enable-all' ]
    name: ${{ matrix.os }} (Zulu JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure}})
    uses: ./.github/workflows/linux-common.yml
    with:
      os: ${{ matrix.os }}
      jdk_distro: "zulu"
      jdk_version: ${{ matrix.jdk_version }}
      wolfssl_configure: ${{ matrix.wolfssl_configure }}

  # -------------------- session cache variant sanity checks -----------------------
  # Only check one Linux and Mac JDK version as a sanity check.
  # Using Zulu, but this can be expanded if needed.
  linux-zulu-sesscache:
    strategy:
      matrix:
        os: [ 'ubuntu-latest', 'macos-latest' ]
        jdk_version: [ '11' ]
        wolfssl_configure: [
            '--enable-jni CFLAGS=-DNO_SESSION_CACHE_REF',
        ]
    name: ${{ matrix.os }} (Zulu JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure}})
    uses: ./.github/workflows/linux-common.yml
    with:
      os: ${{ matrix.os }}
      jdk_distro: "zulu"
      jdk_version: ${{ matrix.jdk_version }}
      wolfssl_configure: ${{ matrix.wolfssl_configure }}

  # -------------------- WOLFJNI_USE_IO_SELECT sanity check --------------------
  # Only check one Linux and Mac JDK version as a sanity check.
  # Using Zulu, but this can be expanded if needed.
  linux-zulu-ioselect:
    strategy:
      matrix:
        os: [ 'ubuntu-latest', 'macos-latest' ]
        jdk_version: [ '11' ]
        wolfssl_configure: [
            '--enable-jni',
        ]
        javash_cflags: [ '-DWOLFJNI_USE_IO_SELECT' ]
    name: ${{ matrix.os }} (Zulu JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure}}, ${{ matrix.javash_cflags }})
    uses: ./.github/workflows/linux-common.yml
    with:
      os: ${{ matrix.os }}
      jdk_distro: "zulu"
      jdk_version: ${{ matrix.jdk_version }}
      wolfssl_configure: ${{ matrix.wolfssl_configure }}
      javash_cflags: ${{ matrix.javash_cflags }}

  # ------------------ Facebook Infer static analysis -------------------
  # Run Facebook infer over PR code, only running on Linux with one
  # JDK/version for now.
  fb-infer:
    strategy:
      matrix:
        os: [ 'ubuntu-latest' ]
        jdk_version: [ '11' ]
        wolfssl_configure: [ '--enable-jni --enable-all' ]
    name: Facebook Infer (${{ matrix.os }} Zulu JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure }})
    uses: ./.github/workflows/infer.yml
    with:
      os: ${{ matrix.os }}
      jdk_distro: "zulu"
      jdk_version: ${{ matrix.jdk_version }}
      wolfssl_configure: ${{ matrix.wolfssl_configure }}

  # ----------------------- Android Gradle build ------------------------
  # Run Android gradle build over PR code, only running on Linux with one
  # JDK/version for now.
  android-gradle:
    strategy:
      matrix:
        os: [ 'ubuntu-latest' ]
        jdk_version: [ '21' ]
    name: Android Gradle (${{ matrix.os }} Zulu JDK ${{ matrix.jdk_version }})
    uses: ./.github/workflows/android_gradle.yml
    with:
      os: ${{ matrix.os }}
      jdk_distro: "zulu"
      jdk_version: ${{ matrix.jdk_version }}

  # --------------------- Maven build - test pom.xml --------------------
  # Run Maven build over PR code, running on Linux and Mac with only one
  # JDK/version for now.
  maven-build:
    strategy:
      matrix:
        os: [ 'ubuntu-latest', 'macos-latest' ]
        jdk_version: [ '21' ]
        wolfssl_configure: [ '--enable-jni' ]
    name: Maven Build (${{ matrix.os }} Zulu JDK ${{ matrix.jdk_version }})
    uses: ./.github/workflows/maven.yml
    with:
      os: ${{ matrix.os }}
      jdk_distro: "zulu"
      jdk_version: ${{ matrix.jdk_version }}
      wolfssl_configure: ${{ matrix.wolfssl_configure }}

