Skip to content

Commit

Permalink
Upgraded sbt to 1.6, scala.js to 1.8 and webpack to 5 (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
viktor-podzigun committed Nov 15, 2022
1 parent 91fd2ac commit b340d83
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 33 deletions.
44 changes: 23 additions & 21 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,34 +15,34 @@ 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
Expand All @@ -57,24 +59,24 @@ jobs:
~/work/scommons-react/scommons-react/test/target/scala-2.13/scalajs-bundler/test/package-lock.json
~/work/scommons-react/scommons-react/test-dom/target/scala-2.13/scalajs-bundler/test/node_modules
~/work/scommons-react/scommons-react/test-dom/target/scala-2.13/scalajs-bundler/test/package-lock.json
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
if: ${{ startsWith(github.ref, 'refs/tags') }}

- name: Run tests
run: |
sbt -mem 2048 coverage test
sbt coverage test
sbt coverageAggregate coveralls
if: ${{ env.TAG_NAME == '' }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

- name: Publish SNAPSHOT
run: sbt -mem 2048 clean publish
run: sbt clean publish
if: ${{ !github.event.pull_request && env.TAG_NAME == '' }}
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
Expand All @@ -87,7 +89,7 @@ jobs:
echo $PGP_SECRET | base64 --decode > ./keys/secring.gpg
VERSION="$(echo "$TAG_NAME" | cut -d'v' -f 2)"
echo "Publish a release version=$VERSION for tag $TAG_NAME"
version=$VERSION sbt -mem 2048 clean publishSigned sonatypeBundleRelease
version=$VERSION sbt clean publishSigned sonatypeBundleRelease
if: ${{ env.TAG_NAME != '' }}
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
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-react/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/scommons/scommons-react/actions/workflows/ci.yml?query=workflow%3Aci+branch%3Amaster)
[![Coverage Status](https://coveralls.io/repos/github/scommons/scommons-react/badge.svg?branch=master)](https://coveralls.io/github/scommons/scommons-react?branch=master)
[![scala-index](https://index.scala-lang.org/scommons/scommons-react/scommons-react-core/latest.svg)](https://index.scala-lang.org/scommons/scommons-react/scommons-react-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)

## Scala Commons React
[Scala.js](https://www.scala-js.org) facades for common [React.js](https://reactjs.org) utilities and 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")
2 changes: 1 addition & 1 deletion project/src/main/scala/common/Libs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import scommons.sbtplugin.project.CommonLibs

object Libs extends CommonLibs {

val scommonsNodejsVersion = "0.9.0"
val scommonsNodejsVersion = "1.0.0-SNAPSHOT"
private val sjsReactJsVer = "1.0.0"

lazy val sjsReactJsCore = Def.setting("org.scommons.shogowada" %%% "scalajs-reactjs-core" % sjsReactJsVer)
Expand Down
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")
}
}
3 changes: 2 additions & 1 deletion project/src/main/scala/definitions/ReactCore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ object ReactCore extends ScalaJsModule {

override val testDependencies: Def.Initialize[Seq[ModuleID]] = Def.setting(Seq(
TestLibs.scalaTestJs.value,
TestLibs.scalaMockJs.value
TestLibs.scalaMockJs.value,
Libs.scalaJsJavaSecureRandom.value
).map(_ % "test"))
}
3 changes: 2 additions & 1 deletion project/src/main/scala/definitions/ReactDom.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ object ReactDom extends ScalaJsModule {

override val testDependencies: Def.Initialize[Seq[ModuleID]] = Def.setting(Seq(
TestLibs.scalaTestJs.value,
TestLibs.scalaMockJs.value
TestLibs.scalaMockJs.value,
Libs.scalaJsJavaSecureRandom.value
).map(_ % "test"))
}
3 changes: 3 additions & 0 deletions project/src/main/scala/definitions/ReactModule.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 ReactModule {
val settings: Seq[Setting[_]] = Seq(
organization := "org.scommons.react",

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

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

import common.TestLibs
import common.{Libs, TestLibs}
import sbt.Keys._
import sbt._
import scoverage.ScoverageKeys.coverageExcludedPackages

import scalajsbundler.sbtplugin.ScalaJSBundlerPlugin.autoImport._

object ReactTest extends ScalaJsModule {
Expand All @@ -29,7 +28,8 @@ object ReactTest extends ScalaJsModule {

override val runtimeDependencies: Def.Initialize[Seq[ModuleID]] = Def.setting(Seq(
TestLibs.scalaTestJs.value,
TestLibs.scalaMockJs.value
TestLibs.scalaMockJs.value,
Libs.scalaJsJavaSecureRandom.value
))

override val testDependencies: Def.Initialize[Seq[ModuleID]] = Def.setting(Nil)
Expand Down

0 comments on commit b340d83

Please sign in to comment.