-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,27 @@ jobs: | |
- '2.13.15' | ||
java: | ||
- '8' | ||
testWithNode: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: "actions/[email protected]" | ||
- uses: "coursier/cache-action@v2" | ||
- name: "graalvm setup" | ||
uses: "olafurpg/setup-scala@v13" | ||
with: | ||
java-version: "${{matrix.java}}" | ||
- name: "build node" | ||
run: | | ||
sbt "++${{matrix.scala}}; cliJSJS/fullOptJS" | ||
- name: "run bosatsu tests" | ||
run: | | ||
./bosatsu_node test --input_dir test_workspace/ --package_root test_workspace/ | ||
strategy: | ||
matrix: | ||
scala: | ||
- '2.13.15' | ||
java: | ||
- '8' | ||
testC: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) | ||
# hide the punycode deprecation warning | ||
export NODE_OPTIONS="--no-deprecation" | ||
# make sure to run sbt cliJSJS/fullOptJS | ||
node $SCRIPT_DIR/cliJS/.js/target/scala-2.13/bosatsu-clijs-opt "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.bykn.bosatsu.tool | ||
|
||
import cats.effect.{ExitCode, IO, IOApp} | ||
|
||
object Fs2Main extends IOApp { | ||
def run(args: List[String]): IO[ExitCode] = | ||
Fs2Module.run(args) match { | ||
case Right(getOutput) => | ||
Fs2Module.report(getOutput) | ||
case Left(help) => | ||
IO.blocking { | ||
System.err.println(help.toString) | ||
ExitCode.Error | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.bykn.bosatsu.tool | ||
|
||
import cats.{effect => ce} | ||
import cats.effect.{IO, Resource} | ||
import fs2.io.file.Path | ||
import org.bykn.bosatsu.{Par, MainModule, Fs2PlatformIO} | ||
|
||
object Fs2Module extends MainModule[IO, Path](Fs2PlatformIO) { self => | ||
val parResource: Resource[IO, Par.EC] = | ||
Resource.make(IO(Par.newService()))(es => IO(Par.shutdownService(es))) | ||
.map(Par.ecFromService(_)) | ||
|
||
def withEC[A](fn: Par.EC => IO[A]): IO[A] = | ||
parResource.use(fn) | ||
|
||
def fromToolExit(ec: ExitCode): ce.ExitCode = | ||
ec match { | ||
case ExitCode.Success => ce.ExitCode.Success | ||
case ExitCode.Error => ce.ExitCode.Error | ||
} | ||
|
||
def report(io: IO[Output[Path]]): IO[ce.ExitCode] = | ||
io.attempt.flatMap { | ||
case Right(out) => reportOutput(out).map(fromToolExit) | ||
case Left(err) => reportException(err).as(ce.ExitCode.Error) | ||
} | ||
|
||
def reportException(ex: Throwable): IO[Unit] = | ||
mainExceptionToString(ex) match { | ||
case Some(msg) => | ||
IO.consoleForIO.errorln(msg) | ||
case None => | ||
IO.consoleForIO.errorln("unknown error:\n") *> | ||
IO.blocking(ex.printStackTrace(System.err)) | ||
} | ||
|
||
} |