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

Cross build for sbt 1.0 #179

Merged
merged 1 commit into from
Sep 21, 2017
Merged

Conversation

jonas
Copy link
Contributor

@jonas jonas commented Sep 15, 2017

Bumps dependencies and fixes warnings when compiling with sbt 1.0.

References #150

@jonas jonas mentioned this pull request Sep 15, 2017
@@ -88,9 +87,7 @@ val `scalajs-bundler` =
commitNextVersion,
pushChanges,
releaseStepTask(GhPagesKeys.pushSite in manual)
),
scriptedLaunchOpts += "-Dplugin.version=" + version.value,
scriptedBufferLog := false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why the top-level project contains settings for the scripted plugins, so I've removed them.

Copy link
Contributor

@julienrf julienrf Sep 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly that was needed to run the scripted command from the root project. But maybe that’s not needed anymore with your runScripted task? Also, what would be the canonical way to run scripted tests for contributors, now?

Copy link
Contributor Author

@jonas jonas Sep 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely missed this comment. I will update CONTRIBUTING.md to mention the new runScripted task. A future improvement could be to run the supported scripted tests as part of the normal test target

test in Test := Def.sequential(
   test in Test,
   runScriptedTask
).value,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated CONTRIBUTING.md to mention runScripted.

@jonas
Copy link
Contributor Author

jonas commented Sep 15, 2017

I'm seeing a lot of library dependencies warnings, should the sbt-scalajs version be updated in the scripted tests?

[info] [warn] There may be incompatibilities among your library dependencies.
[info] [warn] Here are some of the libraries that were evicted:
[info] [warn] 	* org.scala-js:sbt-scalajs:0.6.18 -> 0.6.19
[info] [warn] Run 'evicted' to see detailed eviction warnings

@sjrd
Copy link
Collaborator

sjrd commented Sep 15, 2017

@jonas jonas changed the title Prepare support for sbt 1.0 Cross build plugins for sbt 1.0 Sep 15, 2017
@jonas
Copy link
Contributor Author

jonas commented Sep 15, 2017

@sjrd Not sure I understand. Are you saying that we should keep the sbt-scalajs plugin version as is?

@sjrd
Copy link
Collaborator

sjrd commented Sep 15, 2017

Yes, basically. Or at least that the reported warning is not a concern and should not itself be the cause to upgrade.

@jonas jonas force-pushed the prepare-for-sbt-1.0 branch from 1b716f8 to 2522d6d Compare September 15, 2017 18:57
@jonas
Copy link
Contributor Author

jonas commented Sep 15, 2017

Currently working on getting the scripted tests to run for sbt 1.0. I'll need some guidance from the maintainers on how to approach this. Some tests only support sbt 0.13 (for example those depending on the play sbt-plugin), other tests we want to run for sbt 1.0 needs to be upgraded to use Scala.js 0.6.19 (unless we remove the explicit declaration and rely on the version the scalajs-bundler plugin adds). In addition, we need to remove the project/build.properties files from scripted tests that should run for sbt 1.0.

Also, do I understand correctly that we want to keep the sbt 0.13 version of the plugin on Scala.js 0.6.18?

I'll try to push a WIP branch later tonight.

build.sbt Outdated
def args = tests.map(Path.relativeTo(base)).flatten.mkString(" ")

if (tests.nonEmpty)
Def.task(scripted.toTask(" " + args).value)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a super generic way to filter scripted tests based on @xuwei-k's amazing work on sbt/sbt-site#107. If necessary we can simplify it to filter only the last directory, e.g. under sbt/sbt-{,web}-scalajs-bundle and include some defaults such as include tests matching *sbt-${sbtVersion}*. Let me know what you think/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on @julienrf 's comment we can make this filtering based on the content of project/build.properties. If the file is missing, run for all sbt versions else parse the binary version and run it if it matches sbtBinaryVersion in pluginCrossBuild.

@jonas jonas force-pushed the prepare-for-sbt-1.0 branch from df12481 to 5ddcabb Compare September 16, 2017 03:03
implicit class ProcessLoggerOps(val self: ProcessLogger) extends AnyVal {
def out(msg: String) = self.info(msg)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use scala.sys.Process everywhere instead of introducing this abstraction over scala.sys.Process and sbt.Process?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will give it a try.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 8f2e318

@@ -1 +0,0 @@
sbt.version=0.13.15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove that? I think keeping it (and setting it to 1.0.1) makes it possible to load the project whatever sbt version is installed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we keep it, it will force the test to only work with that specific sbt version. Most tests I assume we want to run for both versions of sbt. Those we want to fix to a specific sbt version will have to be configured so the CI can filter them out. I've already added a mechanism to do this as pointed out elsewhere.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I see! I didn’t notice that the tests were executed with both sbt 1.0 and 0.13. This is great actually :) We should not have to introduce a mechanism testing whether a test should be run with sbt 1.0 or 0.13 only.

Copy link
Contributor Author

@jonas jonas Sep 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mechanism is needed for sbt-web-scalajs-bundler/play until the Play sbt plugin has been published for sbt 1.0 (playframework/playframework#7261). However, based on @sjrd's concern, we should probably also add tests that target the minimum version of sbt 0.13 and sbt 1.0 that scalajs-bundler supports to ensure documentation about those requirements stays up to date.

if (!installDir.exists()) {
log.info(s"Installing jsdom in ${installDir.absolutePath}")
IO.createDirectory(installDir)
install(installDir, useYarn.value, log)(s"jsdom@$jsdomVersion")
install(installDir, usingYarn, log)(s"jsdom@$jsdomVersion")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish sbt/sbt#3299 could be fixed soon so that we don’t have to introduce these redundant identifiers (ie usingYarn instead of useYarn.value)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4b2d2f9 updates to newly released sbt 1.0.2 and allows to remove these workarounds.

build.sbt Outdated
def runScriptedTask = Def.taskDyn {
val sbtBinVersion = (sbtBinaryVersion in pluginCrossBuild).value
val base = sbtTestDirectory.value
val testDirectoryFinder = base * AllPassFilter * AllPassFilter filter { _.isDirectory }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does that find test directories?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works similar to the shell glob .../sbt-test/*/*

Copy link
Contributor

@julienrf julienrf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks! Could you squash the commits into a single one before we merge?

@jonas jonas force-pushed the prepare-for-sbt-1.0 branch from d4c9552 to 7b326d5 Compare September 18, 2017 00:25
@jonas jonas changed the title Cross build plugins for sbt 1.0 Cross build for sbt 1.0 Sep 18, 2017
@jonas
Copy link
Contributor Author

jonas commented Sep 18, 2017

OK, squashed and added tests for minimum versions of sbt.

@jonas jonas force-pushed the prepare-for-sbt-1.0 branch 3 times, most recently from 7edf2cc to 2cfe6f0 Compare September 18, 2017 02:14
appveyor.yml Outdated
@@ -7,8 +7,8 @@ install:
build_script:
- sbt clean compile
test_script:
- sbt test scripted
- sbt test runScripted
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if it’s possible to have the same matrix thing as we have with travis?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in the latest version. Take note of the comment about special handling of ^. It looks related with appveyor/ci#1500.

 - Bump Scala.js to 0.6.19 which supports sbt 1.0.0-RC2+.
 - Fix error from the DSL checker when compiling with sbt 1.0.2.
 - Use scala.sys.process in both sbt versions instead of the sbt.Process
   API which has been removed in sbt 1.0.
 - Remove project/build.properties from scripted tests that should run
   for both sbt 0.13 and 1.0 and provide a new `runScripted` task to
   conditionally run tests supported by the configured sbt version.
 - Add tests for minimum required sbt versions: 0.13.9 and 1.0.0-RC2.
 - Configure build matrices in AppVeyor and Travis with sbt build
   versions.
@jonas jonas force-pushed the prepare-for-sbt-1.0 branch from 2cfe6f0 to 9c8d490 Compare September 19, 2017 16:17
jonas added a commit to sbt/sbt-site that referenced this pull request Sep 20, 2017
Allows to more easily filter both sbt 0.13 and sbt 1.0 tests.

Based on scalacenter/scalajs-bundler#179
@julienrf julienrf merged commit 919b74b into scalacenter:master Sep 21, 2017
@julienrf
Copy link
Contributor

This is great work, thanks a lot Jonas!

@jonas jonas deleted the prepare-for-sbt-1.0 branch September 21, 2017 11:41
@sjrd sjrd mentioned this pull request Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants