Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to sbt-typelevel #35

Merged
merged 1 commit into from
Mar 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 112 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ on:
tags: [v*]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
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 }}

jobs:
build:
Expand All @@ -27,18 +29,30 @@ jobs:
matrix:
os: [ubuntu-latest]
scala: [2.12.15, 2.13.8, 3.1.1]
java: [adopt@1.8]
java: [temurin@8]
project: [rootJS, rootJVM]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Java and Scala
uses: olafurpg/setup-scala@v13
- name: Download Java (temurin@8)
id: download-java-temurin-8
if: matrix.java == 'temurin@8'
uses: typelevel/download-java@v1
with:
java-version: ${{ matrix.java }}
distribution: temurin
java-version: 8

- name: Setup Java (temurin@8)
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v2
with:
distribution: jdkfile
java-version: 8
jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }}

- name: Cache sbt
uses: actions/cache@v2
Expand All @@ -53,17 +67,40 @@ jobs:
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

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

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

- name: scalaJSLink
if: matrix.project == 'rootJS'
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/scalaJSLinkerResult

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

- run: sbt ++${{ matrix.scala }} ci
- name: Check binary compatibility
if: matrix.java == 'temurin@8'
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' mimaReportBinaryIssues

- name: Generate API documentation
if: matrix.java == 'temurin@8'
run: sbt 'project ${{ matrix.project }}' '++${{ 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 .js/target core/js/target core/jvm/target tests/js/target .jvm/target .native/target tests/jvm/target project/target

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

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

publish:
Expand All @@ -74,18 +111,29 @@ jobs:
matrix:
os: [ubuntu-latest]
scala: [3.1.1]
java: [adopt@1.8]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Java and Scala
uses: olafurpg/setup-scala@v13
- name: Download Java (temurin@8)
id: download-java-temurin-8
if: matrix.java == 'temurin@8'
uses: typelevel/download-java@v1
with:
java-version: ${{ matrix.java }}
distribution: temurin
java-version: 8

- name: Setup Java (temurin@8)
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v2
with:
distribution: jdkfile
java-version: 8
jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }}

- name: Cache sbt
uses: actions/cache@v2
Expand All @@ -99,37 +147,76 @@ jobs:
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Download target directories (2.12.15)
- name: Download target directories (2.12.15, rootJS)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJS

- name: Inflate target directories (2.12.15, rootJS)
run: |
tar xf targets.tar
rm targets.tar

- name: Download target directories (2.12.15, rootJVM)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJVM

- name: Inflate target directories (2.12.15, rootJVM)
run: |
tar xf targets.tar
rm targets.tar

- name: Download target directories (2.13.8, rootJS)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-2.12.15-${{ matrix.java }}
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJS

- name: Inflate target directories (2.12.15)
- name: Inflate target directories (2.13.8, rootJS)
run: |
tar xf targets.tar
rm targets.tar

- name: Download target directories (2.13.8)
- name: Download target directories (2.13.8, rootJVM)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-2.13.8-${{ matrix.java }}
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJVM

- name: Inflate target directories (2.13.8)
- name: Inflate target directories (2.13.8, rootJVM)
run: |
tar xf targets.tar
rm targets.tar

- name: Download target directories (3.1.1)
- name: Download target directories (3.1.1, rootJS)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-3.1.1-${{ matrix.java }}
name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.1-rootJS

- name: Inflate target directories (3.1.1)
- name: Inflate target directories (3.1.1, rootJS)
run: |
tar xf targets.tar
rm targets.tar

- name: Download target directories (3.1.1, rootJVM)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.1-rootJVM

- name: Inflate target directories (3.1.1, rootJVM)
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 == ''
run: echo $PGP_SECRET | base64 -di | gpg --import

- name: Import signing key and strip passphrase
if: env.PGP_SECRET != '' && env.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)

- run: sbt ++${{ matrix.scala }} release
- name: Publish
run: sbt '++${{ matrix.scala }}' tlRelease
3 changes: 3 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version = "3.4.3"
runner.dialect = scala213Source3
project.includePaths = [] # disables formatting
71 changes: 7 additions & 64 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,58 +1,19 @@
import sbtcrossproject.CrossPlugin.autoImport.crossProject
import sbtcrossproject.CrossPlugin.autoImport.CrossType
ThisBuild / tlBaseVersion := "1.0"

ThisBuild / baseVersion := "1.0"

ThisBuild / organization := "org.typelevel"
ThisBuild / organizationName := "Typelevel"

ThisBuild / publishGithubUser := "mpilquist"
ThisBuild / publishFullName := "Michael Pilquist"
ThisBuild / developers += tlGitHubDev("mpilquist", "Michael Pilquist")
ThisBuild / startYear := Some(2021)

ThisBuild / crossScalaVersions := List("2.12.15", "2.13.8", "3.1.1")
ThisBuild / tlVersionIntroduced := Map("3" -> "1.0.2")

ThisBuild / spiewakCiReleaseSnapshots := true

ThisBuild / spiewakMainBranches := List("main")

ThisBuild / homepage := Some(url("https://github.com/typelevel/literally"))

ThisBuild / licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0"))

ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/typelevel/literally"),
"git@github.com:typelevel/literally.git"
)
)

ThisBuild / testFrameworks += new TestFramework("munit.Framework")

lazy val root = project
.in(file("."))
.aggregate(core.jvm, core.js, tests.jvm, tests.js)
.enablePlugins(NoPublishPlugin, SonatypeCiReleasePlugin)
lazy val root = tlCrossRootProject.aggregate(core, tests)

lazy val core = crossProject(JSPlatform, JVMPlatform)
.settings(
name := "literally",
scalacOptions := scalacOptions.value.filterNot(_ == "-source:3.0-migration"),
Compile / unmanagedSourceDirectories ++= {
val major = if (isDotty.value) "-3" else "-2"
List(CrossType.Pure, CrossType.Full).flatMap(
_.sharedSrcDir(baseDirectory.value, "main").toList.map(f => file(f.getPath + major))
)
},
Test / unmanagedSourceDirectories ++= {
val major = if (isDotty.value) "-3" else "-2"
List(CrossType.Pure, CrossType.Full).flatMap(
_.sharedSrcDir(baseDirectory.value, "test").toList.map(f => file(f.getPath + major))
)
}
)
.settings(
libraryDependencies ++= {
if (isDotty.value) Nil else List("org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided")
if (tlIsScala3.value) Nil else List("org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided)
}
)

Expand All @@ -62,26 +23,8 @@ lazy val tests = crossProject(JSPlatform, JVMPlatform)
.settings(
name := "tests",
scalacOptions := scalacOptions.value.filterNot(_ == "-source:3.0-migration"),
Compile / unmanagedSourceDirectories ++= {
val major = if (isDotty.value) "-3" else "-2"
List(CrossType.Pure, CrossType.Full).flatMap(
_.sharedSrcDir(baseDirectory.value, "main").toList.map(f => file(f.getPath + major))
)
},
Test / unmanagedSourceDirectories ++= {
val major = if (isDotty.value) "-3" else "-2"
List(CrossType.Pure, CrossType.Full).flatMap(
_.sharedSrcDir(baseDirectory.value, "test").toList.map(f => file(f.getPath + major))
)
},
githubWorkflowArtifactUpload := false
)
.settings(
libraryDependencies += "org.scalameta" %%% "munit" % "0.7.29" % Test,
libraryDependencies ++= {
if (isDotty.value) Nil else List("org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided")
if (tlIsScala3.value) Nil else List("org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided)
}
)
.jsSettings(
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule))
)
3 changes: 1 addition & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.9.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0")
addSbtPlugin("com.codecommit" % "sbt-spiewak-sonatype" % "0.22.1")
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.4.6")