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

Setup Safari ci #19

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
74c214f
Setup Safari ci
armanbilge Sep 7, 2021
31bab00
Don't run Safari on ubuntu
armanbilge Sep 7, 2021
779f485
Cache Safari JSEnv
armanbilge Sep 7, 2021
35e7b42
Revert "Cache Safari JSEnv"
armanbilge Sep 12, 2021
e0ed1b7
Enable Test / parallelExecution := false
armanbilge Sep 12, 2021
741b369
Merge branch 'main' into feature/safari
armanbilge Sep 12, 2021
94258c3
Merge branch 'main' into feature/safari
armanbilge Sep 12, 2021
534e8ec
Try adding a killall
armanbilge Sep 12, 2021
196f429
Use correct syntax
armanbilge Sep 12, 2021
0462360
Cache Safari JSEnv
armanbilge Sep 7, 2021
d4f7279
Test only core on Safari for now
armanbilge Sep 12, 2021
419e29e
Enable keepAlive
armanbilge Sep 12, 2021
18aa42b
Merge remote-tracking branch 'upstream/main' into feature/safari
armanbilge Apr 28, 2022
1cc8fce
Don't do weird stuff
armanbilge Apr 28, 2022
0db7bf6
Simplify build config
armanbilge Apr 28, 2022
1eb424a
Revert "Simplify build config"
armanbilge Apr 28, 2022
367775d
Remove keepalive for Safari
armanbilge Apr 28, 2022
65913cc
Temporarily disable webworkers project
armanbilge Apr 28, 2022
035370f
Revert "Temporarily disable webworkers project"
armanbilge Apr 28, 2022
9d96432
Try try again
armanbilge Apr 28, 2022
6ea98e3
Poke ci
armanbilge Apr 28, 2022
a899b2f
Disable parallel exec
armanbilge Apr 28, 2022
03919b3
One more grand idea
armanbilge Apr 28, 2022
29738da
no idea
armanbilge Apr 28, 2022
2a17a9e
Try to limit threads
armanbilge Apr 28, 2022
d370996
Prefix JVM opts with -J
armanbilge Apr 28, 2022
918654f
Regenerate workflow
armanbilge Apr 28, 2022
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
21 changes: 16 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,21 @@ jobs:
name: Build and Test
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-latest, macos-latest]
scala: [2.11.12, 2.12.15, 2.13.7, 3.0.2]
java: [temurin@11]
ci: [ciNode, ciFirefox, ciChrome, ciJSDOMNodeJS]
ci: [ciNode, ciFirefox, ciChrome, ciSafari, ciJSDOMNodeJS]
exclude:
- ci: ciSafari
os: ubuntu-latest
- ci: ciNode
os: macos-latest
- ci: ciFirefox
os: macos-latest
- ci: ciChrome
os: macos-latest
- ci: ciJSDOMNodeJS
os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
Expand Down Expand Up @@ -66,9 +77,9 @@ jobs:
run: npm install

- name: Check that workflows are up to date
run: sbt ++${{ matrix.scala }} githubWorkflowCheck
run: 'sbt -J-XX:ActiveProcessorCount=1 ++${{ matrix.scala }} githubWorkflowCheck'

- run: sbt ++${{ matrix.scala }} '${{ matrix.ci }}'
- run: 'sbt -J-XX:ActiveProcessorCount=1 ++${{ matrix.scala }} ''${{ matrix.ci }}'''

publish:
name: Publish Artifacts
Expand Down Expand Up @@ -117,4 +128,4 @@ jobs:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
run: (echo "$PGP_PASSPHRASE"; echo; echo) | gpg --command-fd 0 --pinentry-mode loopback --change-passphrase 5EBC14B0F6C55083

- run: sbt ++${{ matrix.scala }} release
- run: 'sbt -J-XX:ActiveProcessorCount=1 ++${{ matrix.scala }} release'
90 changes: 57 additions & 33 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.{ChromeDriver, ChromeOptions}
import org.openqa.selenium.firefox.{FirefoxOptions, FirefoxProfile}
import org.openqa.selenium.safari.{SafariOptions, SafariDriver}
import org.openqa.selenium.remote.server.{DriverFactory, DriverProvider}

import org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv
Expand Down Expand Up @@ -47,6 +48,12 @@ ThisBuild / scmInfo := Some(

ThisBuild / crossScalaVersions := Seq("2.11.12", "2.12.15", "2.13.7", "3.0.2")

val PrimaryOS = "ubuntu-latest"
val MacOS = "macos-latest"
ThisBuild / githubWorkflowOSes := Seq(PrimaryOS, MacOS)

ThisBuild / githubWorkflowSbtCommand += " -J-XX:ActiveProcessorCount=1"

ThisBuild / githubWorkflowBuildPreamble ++= Seq(
WorkflowStep.Use(
UseRef.Public("actions", "setup-node", "v2.1.2"),
Expand All @@ -58,7 +65,11 @@ ThisBuild / githubWorkflowBuildPreamble ++= Seq(
name = Some("Install jsdom"),
cond = Some("matrix.ci == 'ciJSDOMNodeJS'")))

val ciVariants = List("ciNode", "ciFirefox", "ciChrome", "ciJSDOMNodeJS")
val ciVariants = List("ciNode", "ciFirefox", "ciChrome", "ciSafari", "ciJSDOMNodeJS")

ThisBuild / githubWorkflowBuildMatrixExclusions += MatrixExclude(Map("ci" -> "ciSafari", "os" -> PrimaryOS))
ThisBuild / githubWorkflowBuildMatrixExclusions ++= ciVariants.filter(_ != "ciSafari")
.map(ci => MatrixExclude(Map("ci" -> ci, "os" -> MacOS)))

ThisBuild / githubWorkflowBuildMatrixAdditions += "ci" -> ciVariants

Expand All @@ -69,6 +80,7 @@ replaceCommandAlias("ci", ciVariants.mkString("; ", "; ", ""))
addCommandAlias("ciNode", "; set Global / useJSEnv := JSEnv.NodeJS; test; core/doc")
addCommandAlias("ciFirefox", "; set Global / useJSEnv := JSEnv.Firefox; test; set Global / useJSEnv := JSEnv.NodeJS")
addCommandAlias("ciChrome", "; set Global / useJSEnv := JSEnv.Chrome; test; set Global / useJSEnv := JSEnv.NodeJS")
addCommandAlias("ciSafari", "; set Global / useJSEnv := JSEnv.Safari; core / test; set Global / useJSEnv := JSEnv.NodeJS")
addCommandAlias("ciJSDOMNodeJS", "; set Global / useJSEnv := JSEnv.JSDOMNodeJS; test; set Global / useJSEnv := JSEnv.NodeJS")

// release configuration
Expand Down Expand Up @@ -99,40 +111,49 @@ lazy val useJSEnv =

Global / useJSEnv := JSEnv.NodeJS

ThisBuild / Test / jsEnv := {
import JSEnv._

val old = (Test / jsEnv).value

useJSEnv.value match {
case NodeJS => old
case JSDOMNodeJS => new JSDOMNodeJSEnv()
case Firefox =>
val profile = new FirefoxProfile()
profile.setPreference("privacy.file_unique_origin", false)
val options = new FirefoxOptions()
options.setProfile(profile)
options.setHeadless(true)
new SeleniumJSEnv(options)
case Chrome =>
val options = new ChromeOptions()
options.setHeadless(true)
options.addArguments("--allow-file-access-from-files")
val factory = new DriverFactory {
val defaultFactory = SeleniumJSEnv.Config().driverFactory
def newInstance(capabilities: org.openqa.selenium.Capabilities): WebDriver = {
val driver = defaultFactory.newInstance(capabilities).asInstanceOf[ChromeDriver]
driver.manage().timeouts().pageLoadTimeout(1, TimeUnit.HOURS)
driver.manage().timeouts().setScriptTimeout(1, TimeUnit.HOURS)
driver
def commonSettings(disableSafari: Boolean = false) = Seq(
Test / jsEnv := {
import JSEnv._

val old = (Test / jsEnv).value

useJSEnv.value match {
case NodeJS => old
case JSDOMNodeJS => new JSDOMNodeJSEnv()
case Firefox =>
val profile = new FirefoxProfile()
profile.setPreference("privacy.file_unique_origin", false)
val options = new FirefoxOptions()
options.setProfile(profile)
options.setHeadless(true)
new SeleniumJSEnv(options)
case Chrome =>
val options = new ChromeOptions()
options.setHeadless(true)
options.addArguments("--allow-file-access-from-files")
val factory = new DriverFactory {
val defaultFactory = SeleniumJSEnv.Config().driverFactory
def newInstance(capabilities: org.openqa.selenium.Capabilities): WebDriver = {
val driver = defaultFactory.newInstance(capabilities).asInstanceOf[ChromeDriver]
driver.manage().timeouts().pageLoadTimeout(1, TimeUnit.HOURS)
driver.manage().timeouts().setScriptTimeout(1, TimeUnit.HOURS)
driver
}
def registerDriverProvider(provider: DriverProvider): Unit =
defaultFactory.registerDriverProvider(provider)
}
def registerDriverProvider(provider: DriverProvider): Unit =
defaultFactory.registerDriverProvider(provider)
}
new SeleniumJSEnv(options, SeleniumJSEnv.Config().withDriverFactory(factory))
new SeleniumJSEnv(options, SeleniumJSEnv.Config().withDriverFactory(factory))
case Safari if !disableSafari =>
println("DEBUG DEBUG DEBUG DEBUG")
val options = new SafariOptions()
new SeleniumJSEnv(options, SeleniumJSEnv.Config())
case _ => old
}
}
}
)

ThisBuild / parallelExecution := false
Global / concurrentRestrictions += Tags.limit(Tags.Test, 1)
ThisBuild / Test / testOptions += Tests.Argument(MUnitFramework, "+l")

// project structure
Expand All @@ -147,6 +168,7 @@ lazy val core = project
name := "scala-js-macrotask-executor",
libraryDependencies += "org.scalameta" %%% "munit" % MUnitVersion % Test,
)
.settings(commonSettings())
.enablePlugins(ScalaJSPlugin)

// this project solely exists for testing purposes
Expand All @@ -162,5 +184,7 @@ lazy val webworker = project
),
(Test / test) := (Test / test).dependsOn(Compile / fastOptJS).value,
buildInfoKeys := Seq(scalaVersion, baseDirectory, BuildInfoKey("isBrowser" -> useJSEnv.value.isBrowser)),
buildInfoPackage := "org.scalajs.macrotaskexecutor")
buildInfoPackage := "org.scalajs.macrotaskexecutor"
)
.settings(commonSettings(disableSafari = true)) // bugged
.enablePlugins(ScalaJSPlugin, BuildInfoPlugin, NoPublishPlugin)
1 change: 1 addition & 0 deletions project/JSEnv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ object JSEnv {
case object Firefox extends JSEnv(true)
case object JSDOMNodeJS extends JSEnv(false)
case object NodeJS extends JSEnv(false)
case object Safari extends JSEnv(true)
}