Skip to content

Commit

Permalink
Close #170 - Build for Dotty
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-lee committed Aug 8, 2020
1 parent 0f785fa commit 24669d7
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 73 deletions.
48 changes: 39 additions & 9 deletions .github/workflows/build.yml
@@ -1,6 +1,14 @@
name: Build All
name: Build-All

on:
push:
branches:
- "**"

pull_request:
branches:
- main

on: [push]

jobs:

Expand All @@ -10,12 +18,16 @@ jobs:
strategy:
matrix:
scala:
- { version: "2.10.7", binary-version: "2.10" }
- { version: "2.11.12", binary-version: "2.11" }
- { version: "2.12.10", binary-version: "2.12" }
- { version: "2.11.12", binary-version: "2.11", java-version: "8" }
- { version: "2.12.12", binary-version: "2.12", java-version: "11" }
- { version: "2.13.3", binary-version: "2.13", java-version: "11" }
- { version: "0.26.0-RC1", binary-version: "0.26", java-version: "11" }

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: ${{ matrix.scala.java-version }}

- name: Cache Coursier
uses: actions/cache@v1
Expand All @@ -33,8 +45,25 @@ jobs:
restore-keys: |
${{ runner.os }}-ivy-scala-${{ matrix.scala.binary-version }}-
- name: Build for Scala ${{ matrix.scala.version }}
run: .github/workflows/sbt-build-simple.sh core ${{ matrix.scala.version }}
- name: "[Push] Build All for Scala ${{ matrix.scala.version }}"
if: github.event_name == 'push'
env:
CURRENT_BRANCH_NAME: ${{ github.ref }}
run: |
echo "[BEFORE]CURRENT_BRANCH_NAME=${CURRENT_BRANCH_NAME}"
export CURRENT_BRANCH_NAME="${CURRENT_BRANCH_NAME#refs/heads/}"
echo " [AFTER]CURRENT_BRANCH_NAME=${CURRENT_BRANCH_NAME}"
java -version
.github/workflows/sbt-build-all.sh ${{ matrix.scala.version }}
- name: "[PR] Build All for Scala ${{ matrix.scala.version }}"
if: github.event_name == 'pull_request'
env:
CURRENT_BRANCH_NAME: ${{ github.base_ref }}
run: |
echo "Rull request to the '${CURRENT_BRANCH_NAME}' branch"
java -version
.github/workflows/sbt-build-all.sh ${{ matrix.scala.version }}
build_scala2_13:
runs-on: ubuntu-latest
Expand All @@ -60,4 +89,5 @@ jobs:
- name: Build for Scala 2.13
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: .github/workflows/sbt-build.sh core 2.13.0
CURRENT_BRANCH_NAME: ${{ github.ref }}
run: .github/workflows/sbt-build.sh core 2.13.3
5 changes: 4 additions & 1 deletion .github/workflows/publish-github-pages.yml
Expand Up @@ -55,7 +55,10 @@ jobs:
ALGOLIA_INDEX_NAME: ${{ secrets.ALGOLIA_INDEX_NAME }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sbt clean \
sbt \
-J-Xmx2048m \
++${{ matrix.scala.version }}! \
clean \
docs/mdoc \
docs/docusaurGenerateAlgoliaConfigFile \
docs/docusaurInstall \
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/sbt-build-all.sh
@@ -0,0 +1,47 @@
#!/bin/bash -e

set -x

if [ -z "$1" ]
then
echo "Missing parameters. Please enter the [Scala version]."
echo "sbt-build.sh 2.13.3"
exit 1
else
: ${CURRENT_BRANCH_NAME:?"CURRENT_BRANCH_NAME is missing."}

scala_version=$1
echo "============================================"
echo "Build projects"
echo "--------------------------------------------"
echo ""

if [[ "$CURRENT_BRANCH_NAME" == "main" || "$CURRENT_BRANCH_NAME" == "release" ]]
then
# sbt -J-Xmx2048m ++${scala_version}! -v clean; coverage; test; coverageReport; coverageAggregate
# sbt -J-Xmx2048m ++${scala_version}! -v coveralls
# sbt -J-Xmx2048m ++${scala_version}! -v clean; packagedArtifacts
sbt \
-J-Xmx2048m \
++${scala_version}! \
-v \
clean \
test \
packagedArtifacts
else
# sbt -J-Xmx2048m ++${scala_version}! -v clean coverage test coverageReport coverageAggregate package
# sbt -J-Xmx2048m ++${scala_version}! -v coveralls
sbt \
-J-Xmx2048m \
++${scala_version}! \
-v \
clean \
test \
package
fi


echo "============================================"
echo "Building projects: Done"
echo "============================================"
fi
28 changes: 0 additions & 28 deletions .github/workflows/sbt-build-simple.sh

This file was deleted.

15 changes: 8 additions & 7 deletions .github/workflows/sbt-build.sh
Expand Up @@ -8,21 +8,22 @@ if [ -z "$2" ]
echo "sbt-build.sh core 2.12.10"
exit 1
else
: ${CURRENT_BRANCH_NAME:?"CURRENT_BRANCH_NAME is missing."}

project_name=$1
scala_version=$2
echo "============================================"
echo "Build projects"
echo "--------------------------------------------"
echo ""
export CI_BRANCH="${GITHUB_REF#refs/heads/}"
if [[ "$CI_BRANCH" == "main" || "$CI_BRANCH" == "release" ]]
if [[ "$CURRENT_BRANCH_NAME" == "main" || "$CURRENT_BRANCH_NAME" == "release" ]]
then
sbt -J-Xmx2048m "; project ${project_name}; ++ ${scala_version}!; clean; coverage; test; coverageReport; coverageAggregate"
sbt -J-Xmx2048m "; project ${project_name}; ++ ${scala_version}!; coveralls"
sbt -J-Xmx2048m "; project ${project_name}; ++ ${scala_version}!; clean; packagedArtifacts"
sbt -J-Xmx2048m "project ${project_name}" ++${scala_version}! clean coverage test coverageReport coverageAggregate
sbt -J-Xmx2048m "project ${project_name}" ++${scala_version}! coveralls
sbt -J-Xmx2048m "project ${project_name}" ++${scala_version}! clean packagedArtifacts
else
sbt -J-Xmx2048m "; project ${project_name}; ++ ${scala_version}!; clean; coverage; test; coverageReport; coverageAggregate; package"
sbt -J-Xmx2048m "; project ${project_name}; ++ ${scala_version}!; coveralls"
sbt -J-Xmx2048m "project ${project_name}" ++${scala_version}! clean coverage test coverageReport coverageAggregate package
sbt -J-Xmx2048m "project ${project_name}" ++${scala_version}! coveralls
fi


Expand Down
2 changes: 1 addition & 1 deletion README.md
@@ -1,6 +1,6 @@
# just-fp

[![Build Status](https://github.com/Kevin-Lee/just-fp/workflows/Build%20All/badge.svg)](https://github.com/Kevin-Lee/just-fp/actions?workflow=Build+All)
[![Build Status](https://github.com/Kevin-Lee/just-fp/workflows/Build-All/badge.svg)](https://github.com/Kevin-Lee/just-fp/actions?workflow=Build-All)
[![Release Status](https://github.com/Kevin-Lee/just-fp/workflows/Release/badge.svg)](https://github.com/Kevin-Lee/just-fp/actions?workflow=Release)
[![Coverage Status](https://coveralls.io/repos/github/Kevin-Lee/just-fp/badge.svg?branch=main)](https://coveralls.io/github/Kevin-Lee/just-fp?branch=main)

Expand Down
100 changes: 75 additions & 25 deletions build.sbt
Expand Up @@ -4,24 +4,36 @@ import just.semver.SemVer
import SemVer.{Major, Minor}
import microsites.ConfigYml

val ProjectScalaVersion: String = "2.13.1"
val CrossScalaVersions: Seq[String] = Seq("2.10.7", "2.11.12", "2.12.11", ProjectScalaVersion)
val DottyVersion = "0.26.0-RC1"
val ProjectScalaVersion = DottyVersion

val removeDottyIncompatible: ModuleID => Boolean =
m =>
m.name == "wartremover" ||
m.name == "ammonite" ||
m.name == "kind-projector" ||
m.name == "mdoc"

//val ProjectScalaVersion: String = "2.13.1"
val CrossScalaVersions: Seq[String] = Seq("2.10.7", "2.11.12", "2.12.12", "2.13.3", ProjectScalaVersion).distinct

val GitHubUsername = "Kevin-Lee"
val RepoName = "just-fp"
val ProjectName = RepoName

def prefixedProjectName(name: String) = s"$ProjectName${if (name.isEmpty) "" else s"-$name"}"

lazy val noPublish = Seq(
lazy val noPublish: SettingsDefinition = Seq(
publish := {},
publishLocal := {},
publishArtifact := false,
skip in sbt.Keys.`package` := true,
skip in packagedArtifacts := true,
skip in publish := true
)

val hedgehogVersionFor2_10 = "7bd29241fababd9a3e954fd38083ed280fc9e4e8"
val hedgehogVersion = "1bdfed24d9a58914fb78c1f4bea19bf8886d163f"
val hedgehogVersion = "0.4.2"
val hedgehogRepo: MavenRepository =
"bintray-scala-hedgehog" at "https://dl.bintray.com/hedgehogqa/scala-hedgehog"

Expand All @@ -44,23 +56,55 @@ ThisBuild / scmInfo :=
, s"git@github.com:$GitHubUsername/$RepoName.git"
))

libraryDependencies := (
if (isDotty.value)
libraryDependencies.value
.filterNot(removeDottyIncompatible)
else
libraryDependencies.value
)
libraryDependencies := libraryDependencies.value.map(_.withDottyCompat(scalaVersion.value))

lazy val core = (project in file("core"))
.enablePlugins(DevOopsGitReleasePlugin)
// .disablePlugins((if (isDotty.value) Seq(WartRemover) else Seq.empty[AutoPlugin]):_*)
.settings(
name := prefixedProjectName("core")
, description := "Just FP Lib - Core"
, crossScalaVersions := CrossScalaVersions
, unmanagedSourceDirectories in Compile ++= {
val sharedSourceDir = baseDirectory.value / "src/main"
if (scalaVersion.value.startsWith("2.13") || scalaVersion.value.startsWith("2.12"))
Seq(sharedSourceDir / "scala-2.12_2.13")
else
if (scalaVersion.value.startsWith("2.10") || scalaVersion.value.startsWith("2.11"))
Seq(sharedSourceDir / "scala-2.10_2.11")
else
Seq(sharedSourceDir / "scala-2.12_2.13")
}
, scalacOptions :=
( if (isDotty.value)
Seq(
"-source:3.0-migration", "-language:dynamics,existentials,higherKinds,reflectiveCalls,experimental.macros,implicitConversions", "-Ykind-projector"
)
else
Nil
)
, resolvers ++= Seq(
hedgehogRepo
)
, addCompilerPlugin("org.typelevel" % "kind-projector" % "0.11.0" cross CrossVersion.full)
/* Ammonite-REPL { */
, libraryDependencies ++=
(scalaBinaryVersion.value match {
case "2.10" =>
Seq.empty[ModuleID]
case "2.11" =>
Seq("com.lihaoyi" % "ammonite" % "1.6.7" % Test cross CrossVersion.full)
case "2.12" =>
Seq("com.lihaoyi" % "ammonite" % "2.2.0" % Test cross CrossVersion.full)
case "2.13" =>
Seq("com.lihaoyi" % "ammonite" % "2.2.0" % Test cross CrossVersion.full)
case _ =>
Seq.empty[ModuleID]
})
, libraryDependencies :=
crossVersionProps(List.empty, SemVer.parseUnsafe(scalaVersion.value)) {
case (Major(2), Minor(10)) =>
Expand All @@ -72,39 +116,36 @@ lazy val core = (project in file("core"))
hedgehogLibs(hedgehogVersion) ++
libraryDependencies.value
}
/* Ammonite-REPL { */
, libraryDependencies ++=
(scalaBinaryVersion.value match {
case "2.10" =>
Seq.empty[ModuleID]
case "2.11" =>
Seq("com.lihaoyi" % "ammonite" % "1.6.7" % Test cross CrossVersion.full)
case "2.12" =>
Seq.empty[ModuleID] // TODO: add ammonite when it supports Scala 2.12.11
case _ =>
Seq("com.lihaoyi" % "ammonite" % "2.0.4" % Test cross CrossVersion.full)
})
, libraryDependencies := (
if (isDotty.value) {
libraryDependencies.value
.filterNot(removeDottyIncompatible)
}
else
(libraryDependencies).value
)
, libraryDependencies := libraryDependencies.value.map(_.withDottyCompat(scalaVersion.value))
, sourceGenerators in Test +=
(scalaBinaryVersion.value match {
case "2.10" =>
task(Seq.empty[File])
case "2.12" =>
task(Seq.empty[File]) // TODO: add ammonite when it supports Scala 2.12.11
case _ =>
case "2.12" | "2.13" =>
task {
val file = (sourceManaged in Test).value / "amm.scala"
IO.write(file, """object amm extends App { ammonite.Main.main(args) }""")
Seq(file)
}
case _ =>
task(Seq.empty[File])
})
/* } Ammonite-REPL */
// , wartremoverErrors in (Compile, compile) ++= commonWarts((scalaBinaryVersion in update).value)
// , wartremoverErrors in (Test, compile) ++= commonWarts((scalaBinaryVersion in update).value)
, wartremoverErrors ++= commonWarts((scalaBinaryVersion in update).value)
// , wartremoverErrors ++= commonWarts((scalaBinaryVersion in update).value)
// , wartremoverErrors ++= Warts.all
, Compile / console / wartremoverErrors := List.empty
// , Compile / console / wartremoverErrors := List.empty
, Compile / console / scalacOptions := (console / scalacOptions).value.filterNot(_.contains("wartremover"))
, Test / console / wartremoverErrors := List.empty
// , Test / console / wartremoverErrors := List.empty
, Test / console / scalacOptions := (console / scalacOptions).value.filterNot(_.contains("wartremover"))
, testFrameworks ++= Seq(TestFramework("hedgehog.sbt.Framework"))
/* Bintray { */
Expand Down Expand Up @@ -179,6 +220,15 @@ lazy val docs = (project in file("generated-docs"))

, gitHubPagesOrgName := GitHubUsername
, gitHubPagesRepoName := RepoName

, libraryDependencies := (
if (isDotty.value)
libraryDependencies.value
.filterNot(removeDottyIncompatible)
else
libraryDependencies.value
)
, libraryDependencies := libraryDependencies.value.map(_.withDottyCompat(scalaVersion.value))
)
.settings(noPublish)
.dependsOn(core)
Expand Down
6 changes: 4 additions & 2 deletions project/plugins.sbt
Expand Up @@ -2,9 +2,9 @@ logLevel := sbt.Level.Warn

addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.5")

addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.4.5")
addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.4.10")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")

Expand All @@ -13,3 +13,5 @@ addSbtPlugin("io.kevinlee" % "sbt-devoops" % "1.0.3")
addSbtPlugin("com.47deg" % "sbt-microsites" % "1.1.4")

addSbtPlugin("io.kevinlee" % "sbt-docusaur" % "0.1.3")

addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.1")

0 comments on commit 24669d7

Please sign in to comment.