Skip to content

Commit

Permalink
Fix Nightly Builds on Windows (#1953)
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd authored and iamrecursion committed Aug 18, 2021
1 parent c7f2ee1 commit ebdcca8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ env:
sbtVersion: 1.5.2
# Please ensure that this is in sync with rustVersion in build.sbt
rustToolchain: nightly-2021-05-12
# Please ensure that this is in sync with nodeVersion in scala.yml
nodeVersion: 14.17.2
# Specifies how many nightly releases should be kept. Any older releases are removed.
NIGHTLIES_TO_KEEP: 20

Expand Down Expand Up @@ -173,7 +175,7 @@ jobs:
shell: bash
run: |
sleep 1
sbt --no-colors "stdlib-version-updater/run update"
sbt --no-colors "stdlib-version-updater/run update --no-format"
# Verify Legal Review
- name: Verify Packages
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ env:
sbtVersion: 1.5.2
# Please ensure that this is in sync with rustVersion in build.sbt
rustToolchain: nightly-2021-05-12
# Please ensure that this is in sync with nodeVersion in scala.yml
nodeVersion: 14.17.2

concurrency: "releases"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import org.enso.cli.arguments.{Application, Command, Opts}

import java.nio.file.Path
import scala.util.control.NonFatal
import cats.implicits._
import org.enso.cli.arguments.Opts.implicits._

object Main {
private val commands: NonEmptyList[Command[Unit => Int]] = NonEmptyList.of(
Expand All @@ -18,8 +20,15 @@ object Main {
}
},
Command[Unit => Int]("update", "Updates Standard Library versions.") {
Opts.pure { _ =>
run(UpdatingVisitor)
val noFormat = Opts.flag(
"no-format",
"If set, does not run prettier after updating the packages.",
showInUsage = true
)

noFormat map { disableFormatting => _ =>
val shouldFormat = !disableFormatting
run(new UpdatingVisitor(shouldFormat))
0
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.enso.build.stdlibupdater

import org.enso.cli.OS

import java.nio.file.Path
import scala.sys.process._

Expand All @@ -9,10 +11,18 @@ object Prettier {
/** Formats a specific file or directory. */
def format(path: Path): Unit = {
val command =
Seq("npx", "prettier", "--write", path.toAbsolutePath.normalize.toString)
Seq(
npxCommand,
"prettier",
"--write",
path.toAbsolutePath.normalize.toString
)
val exitCode = command.!
if (exitCode != 0) {
throw new RuntimeException(s"$command failed with $exitCode exit code.")
}
}

/** The platform-specific command that is used to run the `npx` tool. */
def npxCommand: String = if (OS.isWindows) "npx.cmd" else "npx"
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ trait StdlibVisitor {
/** A [[StdlibVisitor]] that updates the directories and configs to make sure
* that the versions are correct.
*/
object UpdatingVisitor extends StdlibVisitor {
class UpdatingVisitor(shouldFormat: Boolean) extends StdlibVisitor {

/** @inheritdoc */
override def directoryMismatch(
Expand All @@ -52,7 +52,7 @@ object UpdatingVisitor extends StdlibVisitor {
pkg: Package[File]
): Unit = {
pkg.updateConfig(config => config.copy(version = targetVersion))
Prettier.format(pkg.configFile.toPath)
if (shouldFormat) { Prettier.format(pkg.configFile.toPath) }
println(
s"Updated config of [$libraryName] from [$currentVersion] to " +
s"[$targetVersion]."
Expand Down

0 comments on commit ebdcca8

Please sign in to comment.