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

Set up sbt-release-early and change build semantics #429

Closed

Conversation

jvican
Copy link
Member

@jvican jvican commented Oct 12, 2017

This pull request aims at:

  • Setting up a sbt-release-early workflow, notably using the advantages of sbt-dynver.
  • Changing the build semantics to get a faster workflow with scripted.
  • Removing unnecessary/dead code.

Builds upon #428 and needs to be merged afterwards. When rebase, the actual diff size will be small.

@jvican jvican closed this Oct 17, 2017
@jvican jvican reopened this Oct 17, 2017
@jvican jvican changed the title Set up sbt-release-early Set up sbt-release-early and change build semantics Oct 17, 2017
@@ -1,9 +1,7 @@
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.2.27")
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.1")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0-M1")
addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.12")
Copy link
Member Author

Choose a reason for hiding this comment

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

This is already in sbt-houserules.

@jvican jvican force-pushed the improvements-sbt-build-change-semantics branch 2 times, most recently from 7995d3f to 50bd155 Compare October 18, 2017 08:18
@jvican
Copy link
Member Author

jvican commented Oct 18, 2017

This pull request adds a cached publish local that surprisingly allows us to simplify the build by removing ad-hoc commands and workarounds (scriptedUnpublished). From the commit message:

`cachedPublishLocal` is a special task that avoids publishing if an
artifact has already been published and the publication time is greater
than the changes to the source directories.

In order to find this out, `cachedPublishLocal` resolves the artifact
intransitively and in a project-specific directory. This directory is
also the used to resolve everything from scripted. This resolution is
fast because it assumes that no other task is able to publish that jar
to that concrete resolver. As a result, this assumption allows us to
remove the global dependency lock.

Running `cachedPublishLocal` in the root directory takes from 0 to 1
second. When a new change is written into a project's source file or a
resource file, `cachedPublishLocal` publishes only the project that
received the changes. This is possible because the optimizer is not
allowed and jars are independent from each other.

In this setup, `scripted` uses `cachedPublishLocal`. `scripted`
**needs** the compiler bridges for all the Scala versions, so if you
change the bridge or this is the first time you use this setup, you must
run `+compilerBridge/cachedPublishLocal`.

@jvican jvican force-pushed the improvements-sbt-build-change-semantics branch from 0066e21 to 62e95cc Compare October 18, 2017 08:45
jvican added a commit to scalacenter/zinc that referenced this pull request Oct 22, 2017
These are the improvements that I've added to scripted:

1. Scripted is now parallel and does batch execution.
2. Scripted logs to both a file and the console (if `bufferLog == true`).
   All the logs can be inspected locally by going to a directory in
   `/tmp`. This directory is shown to the user at the end of the
   execution.
3. Scripted UI has been improved.
   3.1. Colors are used for `+` and `x`.
   3.1. It shows the command that actually failed, not `Command failed {line 1}`.
   3.2. It trims the stack traces of the wrapping exceptions
        (corresponding to the scripted infrastructure). Only the stack traces
        of the causing exceptions are shown (which are the ones we're
        interested in and are usually assertion errors).

I think these improvements enhance the current dev workflow
considerably. I invite you to give them a try.

This change combined with sbt#429, gives a really fast execution of
scripted. Testing just one test is under 7 seconds in my machine (note
that in those 7 seconds we have to fetch the bridge, etc).
jvican added a commit to scalacenter/zinc that referenced this pull request Oct 22, 2017
These are the improvements that I've added to scripted:

1. Scripted is now parallel and does batch execution.
2. Scripted logs to both a file and the console (if `bufferLog == true`).
   All the logs can be inspected locally by going to a directory in
   `/tmp`. This directory is shown to the user at the end of the
   execution.
3. Scripted UI has been improved.
   3.1. Colors are used for `+` and `x`.
   3.1. It shows the command that actually failed, not `Command failed {line 1}`.
   3.2. It trims the stack traces of the wrapping exceptions
        (corresponding to the scripted infrastructure). Only the stack traces
        of the causing exceptions are shown (which are the ones we're
        interested in and are usually assertion errors).

I think these improvements enhance the current dev workflow
considerably. I invite you to give them a try.

This change combined with sbt#429, gives a really fast execution of
scripted. Testing just one test is under 7 seconds in my machine (note
that in those 7 seconds we have to fetch the bridge, etc).
jvican added a commit to scalacenter/zinc that referenced this pull request Oct 22, 2017
These are the improvements that I've added to scripted:

1. Scripted is now parallel and does batch execution.
2. Scripted logs to both a file and the console (if `bufferLog == true`).
   All the logs can be inspected locally by going to a directory in
   `/tmp`. This directory is shown to the user at the end of the
   execution.
3. Scripted UI has been improved.
   3.1. Colors are used for `+` and `x`.
   3.1. It shows the command that actually failed, not `Command failed {line 1}`.
   3.2. It trims the stack traces of the wrapping exceptions
        (corresponding to the scripted infrastructure). Only the stack traces
        of the causing exceptions are shown (which are the ones we're
        interested in and are usually assertion errors).

I think these improvements enhance the current dev workflow
considerably. I invite you to give them a try.

This change combined with sbt#429, gives a really fast execution of
scripted. Testing just one test is under 7 seconds in my machine (note
that in those 7 seconds we have to fetch the bridge, etc).
@jvican jvican force-pushed the improvements-sbt-build-change-semantics branch 10 times, most recently from a269ead to c23f534 Compare November 20, 2017 20:37
This is a squashed commit.

This is a general list of the things that are done.

- Port common settings and commands to BuildPlugin
- Remove repeated resolvers
- Move `relaxNon212` to the build plugin
- Move build and alternative publish settings.  This commit consolidates
the build settings and the settings to set up the alternative publishing
process into the `BuildPlugin`.
- Move `noPublish` to the `BuildPlugin`
- Move the rest of the build logic to the plugin
`sbt-scalafmt` is removed because it's already brought in by
`sbt-houserules`.
We only set it up for Bintray for now.

In the future we can release to Sonatype, but we need either sbt org's
credentials or the sbt org to give us Sonatype rights to publish to
"org.scala-sbt" or change org to "ch.epfl.scala".
This build requires too much cross-compiling and cross-publishing, and
hence at the moment sbt loads all the compiler classes from all the
different versions everything starts to slow down and be close to OOMs
and SOs.

The following commit adds a jvmopts file that sets up the java flags to
be used by sbt when starting up on this repository. These jvmopts file
include:

- 1024m for the memory at startup time.
- 4086m as the maximum allocated memory for sbt.
- 512m for the code cache size (otherwise code cache becomes full and
  JDK disables C2 and fallbacks on interpreter).
- Using a bigger inline level considerably helps with compile times and
  speeds up the whole build (tested in several places).
These changes to the build allow a better workflow with scripted.

`cachedPublishLocal` is a special task that avoids publishing if an
artifact has already been published and the publication time is greater
than the changes to the source directories.

In order to find this out, `cachedPublishLocal` resolves the artifact
intransitively and in a project-specific directory. This directory is
also the used to resolve everything from scripted. This resolution is
fast because it assumes that no other task is able to publish that jar
to that concrete resolver. As a result, this assumption allows us to
remove the global dependency lock.

Running `cachedPublishLocal` in the root directory takes from 0 to 1
second. When a new change is written into a project's source file or a
resource file, `cachedPublishLocal` publishes only the project that
received the changes. This is possible because the optimizer is not
allowed and jars are independent from each other.

In this setup, `scripted` uses `cachedPublishLocal`. `scripted`
**needs** the compiler bridges for all the Scala versions, so if you
change the bridge or this is the first time you use this setup, you must
run `+compilerBridge/cachedPublishLocal`.
The following code is not necessary anymore.

- `zincPublishLocal` et al: Nobody is using the
zinc-scripted-alternative because scripted does not use sbt, it uses its
own backend.
- `scriptedUnpublished` is not necessary anymore since scripted now
relies on `cachedPublishLocal`.
@jvican jvican force-pushed the improvements-sbt-build-change-semantics branch 3 times, most recently from 48a214c to d4bf307 Compare November 20, 2017 21:18
Without this change, we get some linking errors (`scala.Product$` not
found) because `+` is not capable of switching the compiler interface to the
new scala version, and linking to it from other projects with newer
scala versions breaks it.

Forcing the scala 2.10 version as the only version of the interface
causes also problems when testing the bridge on 2.11 and 2.12 (which are
the default versions of the build). Therefore, we remove it from the
build and we force that we validate that the interface can be compiled
with 2.10 (and hence Java < 8).
@jvican jvican force-pushed the improvements-sbt-build-change-semantics branch from d4bf307 to faa0cd9 Compare November 20, 2017 21:24
These commands are not necessary anymore since they can be expressed by
operations at the task level that are more intuitive than the previous
commands.

This helps simplifying the whole build setup a lot.
In sbt 1.x, it seems that `publishArtifact` is scoped in the project and
not the build. The reason why I noticed this is because these settings
were not being applied before this change.
Eugene and Dale think this way is better, because they are not used to
the previous style that has a saner way of using scopes in Scala. They
have proposed to make the changes in an independent pull request, but I
don't have time for it.
@jvican jvican force-pushed the improvements-sbt-build-change-semantics branch from faa0cd9 to af3fa21 Compare November 20, 2017 21:31
@jvican jvican mentioned this pull request Nov 20, 2017
@jvican jvican requested a review from eed3si9n November 20, 2017 21:34
@jvican jvican assigned jvican and unassigned jvican Nov 20, 2017
@jvican jvican requested a review from Duhemm November 20, 2017 21:34
build.sbt Outdated
// but given that Scala 2.10 compiler cannot parse Java 8 source, it's probably good to keep this.
crossScalaVersions := Seq(scala210),
scalaVersion := scala210,
crossScalaVersions := bridgeScalaVersions,
Copy link
Member

Choose a reason for hiding this comment

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

During the release, wouldn't this result to double publishing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question, I think it would, I'll try it tomorrow and fix it if that's the case.

build.sbt Outdated
@@ -202,8 +187,6 @@ lazy val compilerBridge: Project = (project in internalPath / "compiler-bridge")
.value,
)

// defines operations on the API of a source, including determining whether it has changed and converting it to a string
Copy link
Member

Choose a reason for hiding this comment

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

Why are we removing these comments?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because it's documented in the contributing guide, better.

@dwijnand dwijnand mentioned this pull request Nov 23, 2017
@dwijnand dwijnand closed this Jan 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants