Skip to content

Commit

Permalink
Upgraded sbt to 1.6, scala.js to 1.8 and webpack to 5
Browse files Browse the repository at this point in the history
  • Loading branch information
viktor-podzigun committed Nov 15, 2022
1 parent 1bf965e commit e786647
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 30 deletions.
38 changes: 20 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: CI

on:
push:
paths-ignore:
- '*.md'
branches: [ master ]
tags:
- '*'
Expand All @@ -13,41 +15,41 @@ jobs:
runs-on: ubuntu-latest
steps:

- name: Git checkout
uses: actions/checkout@v2
- name: Git checkout (merge)
uses: actions/checkout@v3
if: github.event_name != 'pull_request'
with:
fetch-depth: 0

- name: Git checkout (PR)
uses: actions/checkout@v3
if: github.event_name == 'pull_request'
with:
fetch-depth: 0
# see: https://frontside.com/blog/2020-05-26-github-actions-pull_request/#how-does-pull_request-affect-actionscheckout
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '12'
node-version: '16'

- name: Set up JDK 8
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt'

- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt', 'project/**/*.scala') }}
cache: 'sbt'

- name: Cache node_modules
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.npm
~/.nvm
key: ${{ runner.os }}-node_modules-cache-v2-${{ hashFiles('**/package-lock.json') }}
key: ${{ runner.os }}-node_modules-cache-v3-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node_modules-cache-v2-
${{ runner.os }}-node_modules-cache-v3-
- name: Extract Tag Name
run: echo "TAG_NAME=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.class
*.log
package-lock.json

# sbt specific
.cache
Expand Down
2 changes: 2 additions & 0 deletions .sbtopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-J-Xmx2G
-J-XX:+UseG1GC
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![CI](https://github.com/scommons/scommons-api/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/scommons/scommons-api/actions/workflows/ci.yml?query=workflow%3Aci+branch%3Amaster)
[![Coverage Status](https://coveralls.io/repos/github/scommons/scommons-api/badge.svg?branch=master)](https://coveralls.io/github/scommons/scommons-api?branch=master)
[![scala-index](https://index.scala-lang.org/scommons/scommons-api/scommons-api-core/latest.svg)](https://index.scala-lang.org/scommons/scommons-api/scommons-api-core)
[![Scala.js](https://www.scala-js.org/assets/badges/scalajs-1.5.0.svg)](https://www.scala-js.org)
[![Scala.js](https://www.scala-js.org/assets/badges/scalajs-1.8.0.svg)](https://www.scala-js.org)

## scommons-api
Common REST API Scala/Scala.js components
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 1.5.2
sbt.version = 1.6.2
8 changes: 4 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"
resolvers += "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"

//addSbtPlugin(("org.scommons.sbt" % "sbt-scommons-plugin" % "0.9.0-SNAPSHOT").changing())
addSbtPlugin("org.scommons.sbt" % "sbt-scommons-plugin" % "0.9.0")
addSbtPlugin(("org.scommons.sbt" % "sbt-scommons-plugin" % "1.0.0-SNAPSHOT").changing())
//addSbtPlugin("org.scommons.sbt" % "sbt-scommons-plugin" % "0.9.0")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.5")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.7.3")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.2")
8 changes: 6 additions & 2 deletions project/src/main/scala/definitions/ApiAdmin.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package definitions

import common.TestLibs
import common.{Libs, TestLibs}
import sbt.Keys._
import sbt._
import sbtcrossproject.CrossPlugin.autoImport._
Expand Down Expand Up @@ -29,7 +29,11 @@ object ApiAdmin {
// Add JVM-specific settings here
).jsSettings(
// Add JS-specific settings here
ScalaJsModule.settings: _*
ScalaJsModule.settings ++ Seq(
libraryDependencies ++= Seq(
Libs.scalaJsJavaSecureRandom.value % "test"
)
): _*
)

lazy val jvm: Project = `scommons-api-admin`.jvm
Expand Down
6 changes: 5 additions & 1 deletion project/src/main/scala/definitions/ApiCore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ object ApiCore {
Libs.jodaTime.value
)
).jsSettings(
ScalaJsModule.settings: _*
ScalaJsModule.settings ++ Seq(
libraryDependencies ++= Seq(
Libs.scalaJsJavaSecureRandom.value % "test"
)
): _*
)

lazy val jvm: Project = `scommons-api-core`.jvm
Expand Down
6 changes: 5 additions & 1 deletion project/src/main/scala/definitions/ApiJodaTime.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ object ApiJodaTime {
Libs.jodaTime.value
)
).jsSettings(
ScalaJsModule.settings: _*
ScalaJsModule.settings ++ Seq(
libraryDependencies ++= Seq(
Libs.scalaJsJavaSecureRandom.value % "test"
)
): _*
)

lazy val jvm: Project = `scommons-api-joda-time`.jvm
Expand Down
3 changes: 3 additions & 0 deletions project/src/main/scala/definitions/ApiModule.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package definitions

import org.scoverage.coveralls.Imports.CoverallsKeys._
import sbt.Keys._
import sbt._
import scommons.sbtplugin.project.CommonModule
Expand All @@ -20,6 +21,8 @@ object ApiModule {
val settings: Seq[Setting[_]] = Seq(
organization := "org.scommons.api",

coverallsService := GitHubActionsCI.jobId.map(_ => GitHubActionsCI),

//
// publish/release related settings:
//
Expand Down
5 changes: 3 additions & 2 deletions project/src/main/scala/definitions/ApiXhr.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package definitions

import common.TestLibs
import common.{Libs, TestLibs}
import org.scalajs.sbtplugin.ScalaJSPlugin
import sbt.Keys._
import sbt._
Expand Down Expand Up @@ -34,6 +34,7 @@ object ApiXhr extends ApiModule {

override val testDependencies: Def.Initialize[Seq[ModuleID]] = Def.setting(Seq(
TestLibs.scalaTestJs.value,
TestLibs.scalaMockJs.value
TestLibs.scalaMockJs.value,
Libs.scalaJsJavaSecureRandom.value
).map(_ % "test"))
}
27 changes: 27 additions & 0 deletions project/src/main/scala/definitions/GitHubActionsCI.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package definitions

import org.scoverage.coveralls.CIService

import scala.io.Source
import scala.util.parsing.json.{JSON, JSONObject}

case object GitHubActionsCI extends CIService {
val name = ""
val jobId: Option[String] = sys.env.get("GITHUB_RUN_ID")

// https://github.com/coverallsapp/github-action/blob/master/src/run.ts#L31-L40
val pullRequest: Option[String] = for {
eventName <- sys.env.get("GITHUB_EVENT_NAME") if eventName.startsWith("pull_request")
payloadPath <- sys.env.get("GITHUB_EVENT_PATH")
source = Source.fromFile(payloadPath, "utf-8")
lines = try source.mkString finally source.close()
payload <- JSON.parseRaw(lines)
prNumber <- payload.asInstanceOf[JSONObject].obj.get("number")
} yield prNumber.toString.stripSuffix(".0")

// https://docs.github.com/en/actions/learn-github-actions/environment-variables
val currentBranch: Option[String] = pullRequest match {
case Some(_) => sys.env.get("GITHUB_HEAD_REF")
case None => sys.env.get("GITHUB_REF_NAME")
}
}
7 changes: 7 additions & 0 deletions project/src/main/scala/definitions/ScalaJsModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ package definitions

import org.scalajs.jsenv.nodejs.NodeJSEnv
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
import sbt.Keys._
import sbt._

object ScalaJsModule {

val settings: Seq[Setting[_]] = Seq(
scalacOptions ++= Seq(
//see:
// http://www.scala-js.org/news/2021/12/10/announcing-scalajs-1.8.0/
"-P:scalajs:nowarnGlobalExecutionContext"
),

// required for node.js >= v12.12.0
// see:
// https://github.com/nodejs/node/pull/29919
Expand Down

0 comments on commit e786647

Please sign in to comment.