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

Upgraded sbt to 1.6, scala.js to 1.8 and webpack to 5 #4

Merged
merged 1 commit into from
Nov 18, 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
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,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 @@ -53,9 +55,9 @@ jobs:
~/work/scommons-material-ui/scommons-material-ui/test/target/scala-2.13/scalajs-bundler/test/package-lock.json
~/work/scommons-material-ui/scommons-material-ui/showcase/target/scala-2.13/scalajs-bundler/test/node_modules
~/work/scommons-material-ui/scommons-material-ui/showcase/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: Run tests
run: sbt coverage test && sbt coverageAggregate coveralls
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
@@ -1,7 +1,7 @@

[![CI](https://github.com/scommons/scommons-material-ui/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/scommons/scommons-material-ui/actions/workflows/ci.yml?query=workflow%3Aci+branch%3Amaster)
[![Coverage Status](https://coveralls.io/repos/github/scommons/scommons-material-ui/badge.svg?branch=master)](https://coveralls.io/github/scommons/scommons-material-ui/?branch=master)
[![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 Material UI

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object ReactDocgen {
case TypeName.func => ReactDocgenType.Func
case TypeName.union =>
val types = pt.value.asInstanceOf[js.Array[raw.ReactDocgenNativeType]]
.toIterable.map(toReactDocgenType).toList
.toList.map(toReactDocgenType)
ReactDocgenType.Union(types: _*)
case t =>
ReactDocgenType.Any
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,10 +1,10 @@
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")
4 changes: 2 additions & 2 deletions project/src/main/scala/common/Libs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import scommons.sbtplugin.project.CommonLibs

object Libs extends CommonLibs {

val scommonsNodejsVersion = "0.9.0"
val scommonsReactVersion = "0.9.0"
val scommonsNodejsVersion = "1.0.0-SNAPSHOT"
val scommonsReactVersion = "1.0.0-SNAPSHOT"

lazy val scommonsNodejsCore = Def.setting("org.scommons.nodejs" %%% "scommons-nodejs-core" % scommonsNodejsVersion)
lazy val scommonsReactCore = Def.setting("org.scommons.react" %%% "scommons-react-core" % scommonsReactVersion)
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")
}
}
8 changes: 5 additions & 3 deletions project/src/main/scala/definitions/MaterialUiCore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ object MaterialUiCore extends ScalaJsModule {
.settings(
description := "Scala.js facades for material-ui core components and APIs",

coverageExcludedPackages := "scommons.materialui.raw",
coverageExcludedPackages :=
"scommons.materialui.raw" +
";scommons.materialui.styles", // avoid "Found a dangling UndefinedParam" during test with coverage

Compile / npmDependencies ++= Seq(
"@material-ui/core" -> "^4.12.3",
"@material-ui/icons" -> "^4.11.2"
),

Compile / npmDevDependencies ++= Seq(
"webpack-node-externals" -> "2.5.2",
"webpack-merge" -> "4.2.1"
"webpack-node-externals" -> "3.0.0",
"webpack-merge" -> "5.8.0"
)
)

Expand Down
3 changes: 3 additions & 0 deletions project/src/main/scala/definitions/MaterialUiModule.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package definitions

import common.Libs
import org.scoverage.coveralls.Imports.CoverallsKeys._
import sbt.Keys._
import sbt._
import scommons.sbtplugin.project.CommonModule
Expand All @@ -23,6 +24,8 @@ object MaterialUiModule {
val settings: Seq[Setting[_]] = Seq(
organization := "org.scommons.material-ui",

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

//
// publish/release related settings:
//
Expand Down
4 changes: 3 additions & 1 deletion project/src/main/scala/definitions/MaterialUiShowcase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ object MaterialUiShowcase extends ScalaJsModule {
publishLocal := ((): Unit),
publishM2 := ((): Unit),

coverageExcludedPackages := "scommons.materialui.showcase.ShowcaseMain",
coverageExcludedPackages :=
"scommons.materialui.showcase.ShowcaseMain" +
";scommons.materialui.showcase.button", // avoid "Found a dangling UndefinedParam" during test with coverage

scalaJSUseMainModuleInitializer := true,
webpackBundlingMode := BundlingMode.LibraryOnly(),
Expand Down
7 changes: 5 additions & 2 deletions showcase/client.webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const merge = require("webpack-merge")
const { merge } = require("webpack-merge")

const generatedConfig = require('./scalajs.webpack.config')
const commonConfig = require("./common.webpack.config.js")

module.exports = merge(generatedConfig, commonConfig)
module.exports = merge(generatedConfig, commonConfig, {

mode: 'production'
})