Skip to content
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
11 changes: 8 additions & 3 deletions .devcontainer/features/mill/install.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
#!/bin/sh

set -e

# Extract Mill version from build.mill
MILL_VERSION=$(head -1 build.mill | grep -oP '(?<=mill-version:\s)\d+\.\d+\.\d+')

# Extract Playwright version from playwrightVersion.mill
PLAYWRIGHT_VERSION=$(head -1 playwrightVersion.mill | grep -oP '(?<=val version\s=\s")\d+\.\d+\.\d+')

# Put millw on the path, so we can call 'mill' from the command line.
curl -L -o /usr/local/bin/mill https://repo1.maven.org/maven2/com/lihaoyi/mill-dist/1.0.3/mill-dist-1.0.3-mill.sh && chmod +x /usr/local/bin/mill
curl -L -o /usr/local/bin/mill https://repo1.maven.org/maven2/com/lihaoyi/mill-dist/${MILL_VERSION}/mill-dist-${MILL_VERSION}-mill.sh && chmod +x /usr/local/bin/mill

# Install Coursier - can call cs from command line
curl -fL "https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz" | gzip -d > /usr/local/bin/cs && chmod +x /usr/local/bin/cs

# Install metals - should prevent dependancy downloads on container start
cs install metals
cs launch com.microsoft.playwright:playwright:1.51.0 -M "com.microsoft.playwright.CLI" -- install --with-deps
cs launch com.microsoft.playwright:playwright:${PLAYWRIGHT_VERSION} -M "com.microsoft.playwright.CLI" -- install --with-deps
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

FORCE_COLOR: '1'

concurrency:
group: ${{ github.workflow }} @ ${{ github.ref }}
Expand Down
53 changes: 21 additions & 32 deletions build.mill
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//| mill-version: 1.1.2
//| mill-jvm-version: 21
//| mill-version: 1.0.5
//| mvnDeps:
//| - com.lihaoyi::mill-contrib-buildinfo:$MILL_VERSION
//| - com.goyeau::mill-scalafix::0.6.0
//| - io.github.quafadas:millSite_mill1_3.7:0.0.50
//| - io.github.quafadas:millSite_mill1_3.8:0.0.57

import os.copy.over
// import io.github.quafadas.millSite._
import mill._, scalalib._, publish._, scalanativelib._
import mill.*, scalalib.*, publish.*, scalanativelib.*
import mill.scalalib.scalafmt.ScalafmtModule
import mill.util.*
import mill.util.BuildInfo.millVersion
Expand All @@ -17,24 +17,22 @@ import java.text.Format
import io.github.quafadas.millSite.SiteModule
import mill.util.VcsVersion


object V{
object V:
val scalaLts = "3.3.6"
val pwV = build.pwV
val http4sVersion = "0.23.30"
val circeVersion = "0.14.10"
val scalaVersion = "3.7.2"
val scalaVersion = "3.8.2"
val laminar = "17.2.1"
val scalaJsDom = "2.8.1"
val scalaJs = "1.19.0"
val scalaJs = "1.20.1"
val fs2 = "3.11.0"
val millLibs = mvn"com.lihaoyi::mill-libs:$millVersion"
}
end V

trait FormatFix extends ScalafmtModule with ScalafixModule with ScalaModule


trait FormatFixPublish extends ScalaModule with FormatFix with PublishModule{
trait FormatFixPublish extends ScalaModule with FormatFix with PublishModule:
override def scalaVersion = V.scalaVersion

override def scalacOptions = super.scalacOptions() ++ Seq("-Wunused:all")
Expand All @@ -47,17 +45,15 @@ trait FormatFixPublish extends ScalaModule with FormatFix with PublishModule{
organization = "io.github.quafadas",
url = "https://github.com/Quafadas/live-server-scala-cli-js",
licenses = Seq(License.`Apache-2.0`),
versionControl =
VersionControl.github("quafadas", "live-server-scala-cli-js"),
versionControl = VersionControl.github("quafadas", "live-server-scala-cli-js"),
developers = Seq(
Developer("quafadas", "Simon Parten", "https://github.com/quafadas")
)
)
}
end FormatFixPublish

}

trait Testy extends TestModule.Munit with FormatFix {
trait Testy extends TestModule.Munit with FormatFix:

override def defaultTask(): String = "testForked"

Expand All @@ -66,22 +62,15 @@ trait Testy extends TestModule.Munit with FormatFix {
mvn"org.scalameta::munit::1.1.0",
mvn"com.lihaoyi::os-lib:0.11.4"
)

}

end Testy

// SN deps which aren't yet there.
/**
1 targets failed
project.resolvedmvnDeps
Resolution failed for 2 modules:
--------------------------------------------
com.outr:scribe-cats_native0.4_3:3.13.5
not found: /Users/simon/.ivy2/local/com.outr/scribe-cats_native0.4_3/3.13.5/ivys/ivy.xml
not found: https://repo1.maven.org/maven2/com/outr/scribe-cats_native0.4_3/3.13.5/scribe-cats_native0.4_3-3.13.5.pom
--------------------------------------------

For additional information on library dependencies, see the docs at
https://mill-build.com/mill/Library_Dependencies.html

**/
/** 1 targets failed project.resolvedmvnDeps Resolution failed for 2 modules:
* -------------------------------------------- com.outr:scribe-cats_native0.4_3:3.13.5 not found:
* /Users/simon/.ivy2/local/com.outr/scribe-cats_native0.4_3/3.13.5/ivys/ivy.xml not found:
* https://repo1.maven.org/maven2/com/outr/scribe-cats_native0.4_3/3.13.5/scribe-cats_native0.4_3-3.13.5.pom
* --------------------------------------------
*
* For additional information on library dependencies, see the docs at
* https://mill-build.com/mill/Library_Dependencies.html
*/
2 changes: 1 addition & 1 deletion playwrightVersion.mill
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package build

val pwV = "1.51.0"
val pwV = "1.51.0"
31 changes: 31 additions & 0 deletions plugin/integration/resources/simple/src/hi.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package webapp

import org.scalajs.dom
import org.scalajs.dom.document
import com.raquo.laminar.api.L.{*, given}

@main
def main: Unit =
renderOnDomContentLoaded(
dom.document.getElementById("app"),
app
)

def app =
val hiVar = Var("Scala JS") // Local state
div(
h1(
s"Hello ",
child.text <-- hiVar.signal
),
p("This page should reload on change. Check the justfile... for the command to run the server."),
// https://demo.laminar.dev/app/form/controlled-inputs
input(
typ := "text",
controlled(
value <-- hiVar.signal,
onInput.mapToValue --> hiVar.writer
)
)
)
end app
74 changes: 74 additions & 0 deletions plugin/integration/src/js.test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package io.github.quafadas.millSite

import mill.api.Discover
import mill.api.Task.Simple
import mill.testkit.TestRootModule
import mill.testkit.UnitTester
import mill.util.TokenReaders.*
import mill.javalib.DepSyntax
import mill.scalajslib.ContentHashScalaJSModule
import mill.scalajslib.api.ModuleSplitStyle
import utest.*

object SiteJsTests extends TestSuite:
def tests: Tests = Tests {
test("Hashed JS files have correct cross-module references") {
object build extends TestRootModule with mill.scalajslib.ContentHashScalaJSModule:
override def scalaVersion: Simple[String] = "3.8.2"
override def scalaJSVersion: Simple[String] = "1.20.1"
override def moduleSplitStyle: Simple[ModuleSplitStyle] =
ModuleSplitStyle.SmallModulesFor("webapp")

override def mvnDeps = Seq(
mvn"com.raquo::laminar::17.0.0"
)

lazy val millDiscover = Discover[this.type]
end build

val resourceFolder = os.Path(sys.env("MILL_TEST_RESOURCE_DIR"))

UnitTester(build, resourceFolder / "simple").scoped {
eval =>

val Right(result) = eval(build.fastLinkJS).runtimeChecked
val report = result.value
val outputDir = report.dest.path
val files = os.list(outputDir).map(_.last).toSet
val jsFiles = files.filter(f => f.endsWith(".js") && !f.endsWith(".js.map"))

// No original (unhashed) JS filename should exist.
assert(!files.contains("main.js"))

// Every cross-module import inside each JS file must reference a file
// that actually exists in the output directory (i.e. imports use hashed names).
jsFiles.foreach {
filename =>
val content = os.read(outputDir / filename)
val imports = ContentHashScalaJSModule.parseJsImports(content)
imports.foreach {
importedName =>
if !jsFiles.contains(importedName) then
throw new java.lang.AssertionError(
s"In $filename: import '$importedName' not found in output. " +
s"Output files: ${jsFiles.mkString(", ")}"
)
}
}

// The public module reported back must have a hashed filename present in output.
assert(report.publicModules.nonEmpty)
report
.publicModules
.foreach {
m =>
if !jsFiles.contains(m.jsFileName) then
throw new java.lang.AssertionError(
s"Public module '${m.moduleID}' jsFileName '${m.jsFileName}' not found in output"
)
}

}
}
}
end SiteJsTests
60 changes: 60 additions & 0 deletions plugin/integration/src/wasm.test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package io.github.quafadas.millSite

import mill.api.Discover
import mill.api.Task.Simple
import mill.testkit.TestRootModule
import mill.testkit.UnitTester
import mill.util.TokenReaders.*
import mill.javalib.DepSyntax
import mill.scalajslib.ContentHashScalaJSModule
import utest.*

object SiteWasmTests extends TestSuite:
def tests: Tests = Tests {
test("WASM output has a hashed JS file with wasm binary preserved") {
object build extends TestRootModule with mill.scalajslib.ContentHashScalaJSModule:
override def scalaVersion: Simple[String] = "3.8.2"
override def scalaJSVersion: Simple[String] = "1.20.1"
override def scalaJSExperimentalUseWebAssembly = true

override def mvnDeps = Seq(
mvn"com.raquo::laminar::17.0.0"
)

lazy val millDiscover = Discover[this.type]
end build

val resourceFolder = os.Path(sys.env("MILL_TEST_RESOURCE_DIR"))

UnitTester(build, resourceFolder / "simple").scoped {
eval =>

val Right(result) = eval(build.fastLinkJS).runtimeChecked
val report = result.value
val outputDir = report.dest.path
val files = os.list(outputDir).map(_.last).toSet

// The main entry-point JS file must be renamed to a hashed filename.
assert(!files.contains("main.js"))
val hashedMainJs = files.find(f => f.startsWith("main.") && f.endsWith(".js"))
if hashedMainJs.isEmpty then throw new java.lang.AssertionError(s"no hashed main.js found in: $files")
end if

// The WASM binary must be preserved (not renamed).
if !files.exists(_.endsWith(".wasm")) then
throw new java.lang.AssertionError(s"no .wasm file found in: $files")
end if

// The Report's public module must reference the hashed JS file.
assert(report.publicModules.nonEmpty)
val reported = report.publicModules.head.jsFileName
if reported != hashedMainJs.get then
throw new java.lang.AssertionError(
s"report module jsFileName should be ${hashedMainJs.get}, was $reported"
)
end if

}
}
}
end SiteWasmTests
30 changes: 22 additions & 8 deletions plugin/package.mill
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package build.plugin

import mill.util.BuildInfo. millBinPlatform
import mill._, scalalib._, publish._
import mill.util.BuildInfo.{millVersion, millBinPlatform}
import mill.*, scalalib.*, publish.*
import mill.util.VcsVersion
import build.V
import build.FormatFixPublish
Expand All @@ -16,12 +16,12 @@ object `package` extends ScalaModule with FormatFixPublish:

override def artifactName = "sjsls_plugin"

def mvnDeps = Task{
def mvnDeps = Task {
super.mvnDeps() ++
Seq(
V.millLibs,
mvn"co.fs2:fs2-io_3:${V.fs2}"
)
Seq(
V.millLibs,
mvn"co.fs2:fs2-io_3:${V.fs2}"
)
}

def moduleDeps = Seq(build.sjsls)
Expand All @@ -42,4 +42,18 @@ object `package` extends ScalaModule with FormatFixPublish:
Developer("quafadas", "Simon Parten", "https://github.com/quafadas")
)
)
}
}

object test extends ScalaTests with TestModule.Munit:
def mvnDeps = super.mvnDeps() ++ Seq(
mvn"org.scalameta::munit::1.1.0"
)
end test

object integration extends ScalaTests with TestModule.Utest:
override def moduleDeps: Seq[JavaModule] = Seq(build.plugin)
def mvnDeps = Seq(
mvn"com.lihaoyi::mill-testkit::${millVersion}"
)
end integration
end `package`
Loading