Skip to content

Commit

Permalink
Code syntax to Scala 3 and Typelevel SBT plugin migration
Browse files Browse the repository at this point in the history
  • Loading branch information
gvonness committed Aug 13, 2023
1 parent 1fb72ed commit bad35ec
Show file tree
Hide file tree
Showing 104 changed files with 462 additions and 394 deletions.
166 changes: 113 additions & 53 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,111 +9,171 @@ name: Continuous Integration

on:
pull_request:
branches: ['**']
branches: ['**', '!update/**', '!pr/**']
push:
branches: ['**']
branches: ['**', '!update/**', '!pr/**']
tags: [v*]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}


concurrency:
group: ${{ github.workflow }} @ ${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build and Test
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.11]
java: [temurin@11]
scala: [2.13]
java: [temurin@8]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Java (temurin@11)
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v2
- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
java-version: 8
cache: sbt

- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
run: sbt +update

- name: Check that workflows are up to date
run: sbt ++${{ matrix.scala }} githubWorkflowCheck
run: sbt githubWorkflowCheck

- name: Check headers and formatting
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest'
run: sbt '++ ${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck

- name: Test
run: sbt '++ ${{ matrix.scala }}' test

- name: Check binary compatibility
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest'
run: sbt '++ ${{ matrix.scala }}' mimaReportBinaryIssues

- run: sbt ++${{ matrix.scala }} ci
- name: Generate API documentation
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest'
run: sbt '++ ${{ matrix.scala }}' doc

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: mkdir -p target project/target

- name: Compress target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: tar cf targets.tar target project/target

- name: Upload target directories
uses: actions/upload-artifact@v2
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
uses: actions/upload-artifact@v3
with:
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}
path: targets.tar

publish:
name: Publish Artifacts
needs: [build]
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.11]
java: [temurin@11]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Java (temurin@11)
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v2
- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
java-version: 8
cache: sbt

- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Download target directories (2.13.11)
uses: actions/download-artifact@v2
- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
run: sbt +update

- name: Download target directories (2.13)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-2.13.11-${{ matrix.java }}
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13

- name: Inflate target directories (2.13.11)
- name: Inflate target directories (2.13)
run: |
tar xf targets.tar
rm targets.tar
- name: Import signing key
run: echo $PGP_SECRET | base64 -d | gpg --import
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == ''
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
run: echo $PGP_SECRET | base64 -di | gpg --import

- name: Import signing key and strip passphrase
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != ''
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
run: |
echo "$PGP_SECRET" | base64 -di > /tmp/signing-key.gpg
echo "$PGP_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --import /tmp/signing-key.gpg
(echo "$PGP_PASSPHRASE"; echo; echo) | gpg --command-fd 0 --pinentry-mode loopback --change-passphrase $(gpg --list-secret-keys --with-colons 2> /dev/null | grep '^sec:' | cut --delimiter ':' --fields 5 | tail -n 1)
- name: Publish
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_CREDENTIAL_HOST: ${{ secrets.SONATYPE_CREDENTIAL_HOST }}
run: sbt tlCiRelease

dependency-submission:
name: Submit Dependencies
if: github.event_name != 'pull_request'
strategy:
matrix:
os: [ubuntu-latest]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v3
with:
fetch-depth: 0

- run: sbt ++${{ matrix.scala }} release
- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
run: sbt +update

- name: Submit Dependencies
uses: scalacenter/sbt-dependency-submission@v2
with:
configs-ignore: test scala-tool scala-doc-tool test-internal
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ spaces {
}

project.git = true
runner.dialect = scala213
runner.dialect = scala3
28 changes: 8 additions & 20 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
ThisBuild / baseVersion := "0.9.0"

ThisBuild / organization := "ai.entrolution"
ThisBuild / organizationName := "Greg von Nessi"
ThisBuild / publishGithubUser := "gvonness"
ThisBuild / publishFullName := "Greg von Nessi"

ThisBuild / homepage := Some(url("https://github.com/gvonness/thylacine"))
ThisBuild / scmInfo := Some(
ScmInfo(url("https://github.com/gvonness/thylacine"), "git@github.com:gvonness/thylacine.git")
ThisBuild / tlBaseVersion := "0.10"

ThisBuild / organization := "ai.entrolution"
ThisBuild / organizationName := "Greg von Nessi"
ThisBuild / startYear := Some(2023)
ThisBuild / licenses := Seq(License.Apache2)
ThisBuild / developers ++= List(
tlGitHubDev("gvonness", "Greg von Nessi")
)

ThisBuild / startYear := Some(2020)
ThisBuild / endYear := Some(2022)

ThisBuild / spiewakCiReleaseSnapshots := false
ThisBuild / spiewakMainBranches := Seq("main")

ThisBuild / sonatypeCredentialHost := "s01.oss.sonatype.org"
ThisBuild / sonatypeRepository := "https://s01.oss.sonatype.org/service/local"

scalaVersion := DependencyVersions.scala2p13Version
ThisBuild / crossScalaVersions := Seq(DependencyVersions.scala2p13Version)

Expand All @@ -41,7 +30,6 @@ lazy val commonSettings = Seq(
)

lazy val thylacine = (project in file("."))
.enablePlugins(SonatypeCiReleasePlugin)
.settings(
commonSettings,
name := "thylacine",
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import sbt.*
object DependencyVersions {
val scala2p13Version = "2.13.11"

val bengalStmVersion = "0.9.4"
val bengalStmVersion = "0.9.5"
val bigMathVersion = "2.3.2"
val breezeVersion = "2.1.0"
val catsEffectVersion = "3.4.8"
Expand Down
7 changes: 2 additions & 5 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
addSbtPlugin("org.jetbrains" % "sbt-ide-settings" % "1.1.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.34")
addSbtPlugin("com.codecommit" % "sbt-spiewak-sonatype" % "0.23.0")
addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1" % "test")
addSbtPlugin("org.jetbrains" % "sbt-ide-settings" % "1.1.0")
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.5.0-RC11")
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2022 Greg von Nessi
* Copyright 2023 Greg von Nessi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2022 Greg von Nessi
* Copyright 2023 Greg von Nessi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/thylacine/config/HmcmcConfig.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2022 Greg von Nessi
* Copyright 2023 Greg von Nessi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/thylacine/config/HookeAndJeevesConfig.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2022 Greg von Nessi
* Copyright 2023 Greg von Nessi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/thylacine/config/LeapfrogMcmcConfig.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2022 Greg von Nessi
* Copyright 2023 Greg von Nessi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/thylacine/config/MdsConfig.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2022 Greg von Nessi
* Copyright 2023 Greg von Nessi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/thylacine/config/SlqConfig.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2022 Greg von Nessi
* Copyright 2023 Greg von Nessi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2022 Greg von Nessi
* Copyright 2023 Greg von Nessi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,12 +17,12 @@
package ai.entrolution
package thylacine.model.components.forwardmodel

import thylacine.model.core._
import thylacine.model.core.values._
import thylacine.model.core.*
import thylacine.model.core.values.*

import cats.syntax.all._
import cats.syntax.all.*

private[thylacine] trait ForwardModel[F[_]] extends GenericMapping with CanValidate[ForwardModel[F]] {
trait ForwardModel[F[_]] extends GenericMapping with CanValidate[ForwardModel[F]] {
this: AsyncImplicits[F] =>

// Note that input validation should be done within
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2022 Greg von Nessi
* Copyright 2023 Greg von Nessi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2022 Greg von Nessi
* Copyright 2023 Greg von Nessi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,15 +18,15 @@ package ai.entrolution
package thylacine.model.components.forwardmodel

import bengal.stm.STM
import thylacine.model.core.GenericIdentifier._
import thylacine.model.core._
import thylacine.model.core.GenericIdentifier.*
import thylacine.model.core.*
import thylacine.model.core.computation.CachedComputation
import thylacine.model.core.values._
import thylacine.model.core.values.*
import thylacine.model.core.values.modelparameters.ModelParameterContext

import breeze.linalg.{ DenseMatrix, DenseVector }
import cats.effect.kernel.Async
import cats.syntax.all._
import cats.syntax.all.*

import scala.annotation.unused

Expand Down
Loading

0 comments on commit bad35ec

Please sign in to comment.