Skip to content

Commit

Permalink
Merge pull request #54 from softinio/upgrade-to-scala3
Browse files Browse the repository at this point in the history
Upgrade to Scala 3
  • Loading branch information
softinio authored Apr 27, 2024
2 parents 3c809e9 + 1739e95 commit e04bcce
Show file tree
Hide file tree
Showing 22 changed files with 475 additions and 317 deletions.
113 changes: 58 additions & 55 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,123 +15,126 @@ on:
tags: [v*]

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


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

jobs:
build:
name: Build and Test
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.12]
scala: [3]
java: [corretto@21]
project: [rootJVM]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download Java (corretto@21)
id: download-java-corretto-21
if: matrix.java == 'corretto@21'
uses: typelevel/download-java@v1
with:
distribution: corretto
java-version: 21

- name: Setup Java (corretto@21)
id: setup-java-corretto-21
if: matrix.java == 'corretto@21'
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: jdkfile
distribution: corretto
java-version: 21
jdkFile: ${{ steps.download-java-corretto-21.outputs.jdkFile }}
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 == 'corretto@21' && steps.setup-java-corretto-21.outputs.cache-hit == 'false'
run: sbt +update

- name: Check that workflows are up to date
run: sbt githubWorkflowCheck

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

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

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

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

site:
name: Generate Site
dependency-submission:
name: Submit Dependencies
if: github.event_name != 'pull_request'
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.12]
java: [corretto@21]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download Java (corretto@21)
id: download-java-corretto-21
- name: Setup Java (corretto@21)
id: setup-java-corretto-21
if: matrix.java == 'corretto@21'
uses: typelevel/download-java@v1
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 21
cache: sbt

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

- name: Submit Dependencies
uses: scalacenter/sbt-dependency-submission@v2
with:
modules-ignore: rootjs_3 docs_3 rootjvm_3 rootnative_3
configs-ignore: test scala-tool scala-doc-tool test-internal

site:
name: Generate Site
strategy:
matrix:
os: [ubuntu-latest]
java: [corretto@21]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (corretto@21)
id: setup-java-corretto-21
if: matrix.java == 'corretto@21'
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: jdkfile
distribution: corretto
java-version: 21
jdkFile: ${{ steps.download-java-corretto-21.outputs.jdkFile }}
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 == 'corretto@21' && steps.setup-java-corretto-21.outputs.cache-hit == 'false'
run: sbt +update

- name: Generate site
run: sbt '++ ${{ matrix.scala }}' docs/tlSite
run: sbt docs/tlSite

- name: Publish site
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v3.8.0
uses: peaceiris/actions-gh-pages@v3.9.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: site/target/docs/site
Expand Down
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = 3.4.3
runner.dialect = scala213
runner.dialect = scala3
64 changes: 27 additions & 37 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import laika.ast._
import laika.ast.Path._
import laika.ast.InternalTarget
import laika.helium.Helium
import laika.ast.Path.*

import laika.helium.config.Favicon
import laika.helium.config.HeliumIcon
import laika.helium.config.IconLink

Global / excludeLintKeys += ThisBuild / nativeImageJvm
Global / excludeLintKeys += ThisBuild / nativeImageVersion

// https://typelevel.org/sbt-typelevel/faq.html#what-is-a-base-version-anyway
ThisBuild / tlBaseVersion := "0.1" // your current series x.y

ThisBuild / organization := "com.softinio"
ThisBuild / organizationName := "Salar Rahmanian"
ThisBuild / startYear := Some(2023)
ThisBuild / startYear := Some(2024)
ThisBuild / licenses := Seq(License.Apache2)
ThisBuild / developers := List(
// your GitHub handle and name
Expand All @@ -25,11 +26,9 @@ ThisBuild / tlSitePublishBranch := Some("main")

ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.corretto("21"))

val Scala213 = "2.13.12"
ThisBuild / crossScalaVersions := Seq(Scala213)
ThisBuild / scalaVersion := Scala213 // the default Scala

addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.0")
val Scala3 = "3.3.3"
ThisBuild / crossScalaVersions := Seq(Scala3)
ThisBuild / scalaVersion := Scala3 // the default Scala

lazy val root = tlCrossRootProject.aggregate(core)

Expand All @@ -40,59 +39,50 @@ lazy val core = crossProject(JVMPlatform)
name := "scalanews",
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % "2.10.0",
"org.typelevel" %% "cats-effect" % "3.5.2",
"io.github.akiomik" %% "cats-nio-file" % "1.10.0",
"org.typelevel" %% "cats-effect" % "3.5.4",
"com.monovore" %% "decline-effect" % "2.4.1",
"com.github.pureconfig" %% "pureconfig" % "0.17.4",
"com.github.pureconfig" %% "pureconfig-cats-effect" % "0.17.4",
"org.http4s" %% "http4s-ember-client" % "0.23.24",
"org.http4s" %% "http4s-dsl" % "0.23.24",
"com.github.pureconfig" %% "pureconfig-core" % "0.17.6",
"com.github.pureconfig" %% "pureconfig-cats-effect" % "0.17.6",
"org.http4s" %% "http4s-ember-client" % "0.23.26",
"org.http4s" %% "http4s-dsl" % "0.23.26",
"co.fs2" %% "fs2-core" % "3.10.2",
"co.fs2" %% "fs2-io" % "3.10.2",
"com.rometools" % "rome" % "2.1.0",
"org.scalameta" %% "munit" % "0.7.29" % Test,
"org.typelevel" %% "munit-cats-effect-3" % "1.0.7" % Test
"org.scalameta" %% "munit" % "1.0.0-RC1" % Test,
"org.typelevel" %% "munit-cats-effect" % "2.0.0-M5" % Test
),
Compile / mainClass := Some("com.softinio.scalanews.Main"),
nativeImageVersion := "21.0.1",
nativeImageVersion := "21.0.2",
nativeImageJvm := "graalvm-java21",
nativeImageOptions += "--no-fallback",
nativeImageOptions += "--enable-url-protocols=http",
nativeImageOptions += "--enable-url-protocols=https",
nativeImageOutput := file(".") / "scalanews",
nativeImageReady := { () => println("SBT Finished creating image.") },
resolvers +=
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
nativeImageReady := { () => println("SBT Finished creating image.") }
)
.enablePlugins(NativeImagePlugin)

lazy val docs = project
.in(file("site"))
.settings(
tlSiteRelatedProjects := Seq(
TypelevelProject.CatsEffect,
"sbt-typelevel" -> url("https://github.com/typelevel/sbt-typelevel"),
"decline" -> url("https://ben.kirw.in/decline/"),
"Laika" -> url("https://planet42.github.io/Laika/")
),
tlSiteHeliumConfig := {
tlSiteHeliumConfig.value.all
tlSiteHelium := {
tlSiteHelium.value.all
.metadata(
title = Some("Scala News"),
language = Some("en")
)
.site
.topNavigationBar(
homeLink = IconLink.internal(Root / "index.md", HeliumIcon.home),
navLinks = Seq(
IconLink.external(
"https://github.com/softinio/scalanews",
HeliumIcon.github
)
)
homeLink = IconLink.internal(Root / "index.md", HeliumIcon.home)
)
.site
.favIcons(
Favicon.internal(Root / "img/favicon-32x32.png", sizes = "32x32")
)
.site
.footer(
"<br/>\n Created by <a href=\"https://www.softinio.com\">Salar Rahmanian</a> and Contributors.\n <br/>\n <a rel=\"license\" href=\"http://creativecommons.org/licenses/by/4.0/\"><img alt=\"Creative Commons License\" style=\"border-width:0\" src=\"https://i.creativecommons.org/l/by/4.0/80x15.png\" /></a><br />The content on this site by <span xmlns:cc=\"http://creativecommons.org/ns#\" property=\"cc:attributionName\">Salar Rahmanian and contributors</span> is licensed under a <a rel=\"license\" href=\"http://creativecommons.org/licenses/by/4.0/\">Creative Commons Attribution 4.0 International License</a>.<br/> \n Made with ❤\uFE0F in San Francisco using: | <a href=\"https://typelevel.org/cats-effect/\">cats-effect</a> | | <a href=\"https://github.com/typelevel/sbt-typelevel\">sbt-typelevel</a> | | <a href=\"https://ben.kirw.in/decline/\">decline</a> | | <a href=\"https://planet42.github.io/Laika/\">Laika</a> | "
)
}
)
.enablePlugins(TypelevelSitePlugin)
Loading

0 comments on commit e04bcce

Please sign in to comment.