diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e3d78b..d5993f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: name: Build and Test strategy: matrix: - os: [ubuntu-latest] + os: [ubuntu-latest, macos-12, macos-14] scala: [3, 2.13] java: [temurin@21, temurin@17] project: [rootJVM, rootNative] @@ -36,9 +36,17 @@ jobs: java: temurin@17 - project: rootNative java: temurin@17 + - os: macos-12 + project: rootJVM + - os: macos-14 + project: rootJVM runs-on: ${{ matrix.os }} timeout-minutes: 60 steps: + - name: Install sbt + if: contains(runner.os, 'macos') + run: brew install sbt + - name: Checkout current branch (full) uses: actions/checkout@v4 with: @@ -71,18 +79,33 @@ jobs: run: sbt +update - name: Start up Postgres + if: startsWith(matrix.os, 'ubuntu') run: docker-compose up -d - name: Install native dependencies (ubuntu) if: (matrix.project == 'rootNative') && startsWith(matrix.os, 'ubuntu') - run: sudo apt-get update && sudo apt-get install clang && /home/linuxbrew/.linuxbrew/bin/brew install s2n utf8proc + run: | + /home/linuxbrew/.linuxbrew/bin/brew install llvm@17 s2n utf8proc + echo "LLVM_BIN=/home/linuxbrew/.linuxbrew/opt/llvm@17/bin" >> $GITHUB_ENV + + - name: Install native dependencies (macos-12) + if: (matrix.project == 'rootNative') && matrix.os == 'macos-12' + run: | + brew install llvm@17 s2n utf8proc + echo "LLVM_BIN=/usr/local/opt/llvm@17/bin" >> $GITHUB_ENV + + - name: Install native dependencies (macos-14) + if: (matrix.project == 'rootNative') && matrix.os == 'macos-14' + run: | + brew install llvm@17 s2n utf8proc + echo "LLVM_BIN=/opt/homebrew/opt/llvm@17/bin" >> $GITHUB_ENV - name: Check that workflows are up to date run: sbt githubWorkflowCheck - - name: Check scalafix lints - if: matrix.java == 'temurin@21' && (matrix.scala == '3') - run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' 'Test/copyResources; scalafixAll --check' + - name: Check scalafix/scalafmt lints + if: matrix.java == 'temurin@21' && (matrix.scala == '3') && matrix.project == 'rootJVM' && startsWith(matrix.os, 'ubuntu') + run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' 'Test/copyResources; check' - name: Check headers and formatting if: matrix.java == 'temurin@21' && matrix.os == 'ubuntu-latest' @@ -93,6 +116,7 @@ jobs: run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' Test/nativeLink - name: Test + if: startsWith(matrix.os, 'ubuntu') run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' test - name: Check binary compatibility @@ -107,13 +131,19 @@ jobs: if: matrix.project == 'rootNative' && (matrix.scala == '3') run: sbt cliNative/test - - name: Generate CLI native binary - if: matrix.project == 'rootNative' && (matrix.scala == '3') + - name: Generate CLI native binary (ubuntu) + if: matrix.project == 'rootNative' && (matrix.scala == '3') && startsWith(matrix.os, 'ubuntu') env: SCALANATIVE_MODE: release-fast SCALANATIVE_LTO: thin run: sbt buildCliBinary + - name: Generate CLI native binary (macos) + if: matrix.project == 'rootNative' && (matrix.scala == '3') && startsWith(matrix.os, 'macos') + env: + SCALANATIVE_MODE: release-fast + run: sbt buildCliBinary + - name: Run example (covers reading resources from a jar) if: matrix.project == 'rootJVM' run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' example/run @@ -143,6 +173,10 @@ jobs: java: [temurin@21] runs-on: ${{ matrix.os }} steps: + - name: Install sbt + if: contains(runner.os, 'macos') + run: brew install sbt + - name: Checkout current branch (full) uses: actions/checkout@v4 with: @@ -175,6 +209,7 @@ jobs: run: sbt +update - name: Start up Postgres + if: startsWith(matrix.os, 'ubuntu') run: docker-compose up -d - name: Download target directories (3, rootJVM) @@ -269,6 +304,10 @@ jobs: java: [temurin@21] runs-on: ${{ matrix.os }} steps: + - name: Install sbt + if: contains(runner.os, 'macos') + run: brew install sbt + - name: Checkout current branch (full) uses: actions/checkout@v4 with: @@ -301,6 +340,7 @@ jobs: run: sbt +update - name: Start up Postgres + if: startsWith(matrix.os, 'ubuntu') run: docker-compose up -d - name: Submit Dependencies diff --git a/build.sbt b/build.sbt index 96bd385..6b3dbbc 100644 --- a/build.sbt +++ b/build.sbt @@ -23,50 +23,88 @@ ThisBuild / semanticdbEnabled := true ThisBuild / semanticdbVersion := scalafixSemanticdb.revision // use Scalafix compatible version // githubWorkflow +ThisBuild / githubWorkflowOSes ++= Seq("macos-12", "macos-14") +ThisBuild / githubWorkflowBuildMatrixExclusions ++= Seq( + MatrixExclude(Map("os" -> "macos-12", "project" -> "rootJVM")), + MatrixExclude(Map("os" -> "macos-14", "project" -> "rootJVM")), +) ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("21"), JavaSpec.temurin("17")) ThisBuild / tlCiHeaderCheck := true ThisBuild / tlCiScalafixCheck := false +lazy val llvmVersion = "17" lazy val brewFormulas = Set("s2n", "utf8proc") ThisBuild / githubWorkflowBuildPreamble ++= Seq( WorkflowStep.Run( commands = List( - s"sudo apt-get update && sudo apt-get install clang && /home/linuxbrew/.linuxbrew/bin/brew install ${brewFormulas.mkString(" ")}" + s"/home/linuxbrew/.linuxbrew/bin/brew install llvm@$llvmVersion ${brewFormulas.mkString(" ")}", + s"""echo "LLVM_BIN=/home/linuxbrew/.linuxbrew/opt/llvm@$llvmVersion/bin" >> $$GITHUB_ENV""", ), cond = Some("(matrix.project == 'rootNative') && startsWith(matrix.os, 'ubuntu')"), name = Some("Install native dependencies (ubuntu)"), ) ) +ThisBuild / githubWorkflowBuildPreamble ++= List( + "macos-12" -> "/usr/local/opt", + "macos-14" -> "/opt/homebrew/opt", +).map { case (os, llvmBase) => + WorkflowStep.Run( + commands = List( + s"brew install llvm@$llvmVersion ${brewFormulas.mkString(" ")}", + s"""echo "LLVM_BIN=$llvmBase/llvm@$llvmVersion/bin" >> $$GITHUB_ENV""", + ), + cond = Some(s"(matrix.project == 'rootNative') && matrix.os == '$os'"), + name = Some(s"Install native dependencies ($os)"), + ) +} ThisBuild / githubWorkflowJobSetup ++= Seq( WorkflowStep.Run( commands = List("docker-compose up -d"), name = Some("Start up Postgres"), + cond = Some("startsWith(matrix.os, 'ubuntu')"), ) ) ThisBuild / githubWorkflowBuild := { WorkflowStep.Sbt( - List("Test/copyResources; scalafixAll --check"), - name = Some("Check scalafix lints"), - cond = Some("matrix.java == 'temurin@21' && (matrix.scala == '3')"), + List("Test/copyResources; check"), + name = Some("Check scalafix/scalafmt lints"), + cond = Some( + "matrix.java == 'temurin@21' && (matrix.scala == '3') && matrix.project == 'rootJVM' && startsWith(matrix.os, 'ubuntu')" + ), ) +: (ThisBuild / githubWorkflowBuild).value } +// override Test step to run on ubuntu only due to requirement of docker +ThisBuild / githubWorkflowBuild := { + (ThisBuild / githubWorkflowBuild).value.map { + case s if s.name.contains("Test") => + WorkflowStep.Sbt( + List("test"), + name = Some("Test"), + cond = Some("startsWith(matrix.os, 'ubuntu')"), + ) + case s => s + } +} + ThisBuild / githubWorkflowBuild += WorkflowStep.Run( commands = List("sbt cliNative/test"), name = Some("CLI test"), cond = Some("matrix.project == 'rootNative' && (matrix.scala == '3')"), ) -ThisBuild / githubWorkflowBuild += WorkflowStep.Run( - commands = List("sbt buildCliBinary"), - name = Some("Generate CLI native binary"), - cond = Some("matrix.project == 'rootNative' && (matrix.scala == '3')"), - env = Map( - "SCALANATIVE_MODE" -> Mode.releaseFast.toString(), - "SCALANATIVE_LTO" -> LTO.thin.toString(), - ), -) +ThisBuild / githubWorkflowBuild ++= List( + "ubuntu" -> Map("SCALANATIVE_LTO" -> LTO.thin.toString()), + "macos" -> Map.empty, +).map { case (os, envs) => + WorkflowStep.Run( + commands = List("sbt buildCliBinary"), + name = Some(s"Generate CLI native binary ($os)"), + cond = Some(s"matrix.project == 'rootNative' && (matrix.scala == '3') && startsWith(matrix.os, '$os')"), + env = Map("SCALANATIVE_MODE" -> Mode.releaseFast.toString()) ++ envs, + ) +} ThisBuild / githubWorkflowPublish += WorkflowStep.Use( ref = UseRef.Public("softprops", "action-gh-release", "v1"), diff --git a/project/plugins.sbt b/project/plugins.sbt index e0c5fac..0ac8f34 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -6,12 +6,12 @@ addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2") addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.0") -lazy val sbtTlVersion = "0.6.7" +lazy val sbtTlVersion = "0.7.0" addSbtPlugin("org.typelevel" % "sbt-typelevel-ci-release" % sbtTlVersion) addSbtPlugin("org.typelevel" % "sbt-typelevel" % sbtTlVersion) -addSbtPlugin("com.armanbilge" % "sbt-scala-native-config-brew" % "0.2.0-RC1") +addSbtPlugin("com.armanbilge" % "sbt-scala-native-config-brew" % "0.3.0") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")