-
Notifications
You must be signed in to change notification settings - Fork 9
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
Adding tests in CI #105
Adding tests in CI #105
Conversation
@armanbilge at the moment, the jvm tests are called even in the js and native jobs. I fear this might cause flakiness regarding the artifact that will get published, and if maybe this will solve lazy val root = tlCrossRootProject
.aggregate(toolkit, toolkitTest)
.configureJVM(
_.settings(
(Test / test) := (Test / test)
.dependsOn(toolkitTesting / Test / test)
.value
)
) WDYT? |
They are? I don't think so. Edit: so they are. but why 🤔 |
A thing to note is that |
Hmmm, that's actually quite annoying. What if we invoked scala-cli as an external process? |
build.sbt
Outdated
.in(file("toolkit-testing")) | ||
.settings( | ||
name := "toolkit-testing", | ||
Test / test := (Test / test).dependsOn(toolkit.jvm / publishLocal).value, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't have to be this PR, but eventually I'd like to publish the JS and Native toolkits and test those as well.
Specifically, we seem to have an issue sometimes where the toolkit requires JS or Native versions newer than what the latest scala-cli is shipping by default, I wonder if we should try to avoid merging those ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this can be done easily, but using scala-cli as an external process, a thing that will solve the System.exit(1)
too.
That's another point in favor of this solution 🤔
We could do that but I appreciate the leanness of the way is implemented now. I think another viable alternative might be to invoke the inner compile command internally and handle eventual |
Ah that's the other thing: I don't want to specialize to I know it's not as lean, but I think an external process is the way to go long-term. |
Hmm, let me think, what do we need apart calling the external process? Will adding |
We don't need to install anything, we already have scala-cli on the classpath since we added it as a dependency. We can load the classpath into the buildinfo and use that to invoke scala-cli as an ordinary java app. |
Here's how we do something similar in Cats Effect for running |
This definitively requires a night of sleep before trying to be understood. I'll take a look at it tomorrow, thanks ;) |
I like the idea; it will require a bit of trial and error, but it's feasible. I'll bring this PR back to Draft to make some tests. I have a question, though: why the full classpath was "injected" as a Java property while the platform was injected using BuildInfo? |
Because a setting cannot depend on a task ofc |
@armanbilge wdyt of the last commit? It's probably a bit overkilled, but it seems to work. Now it's the case to test both compilation and running for all the other platforms. One thing I'm not 100% sure is how to structure the js and native tests: maybe it's the case to restore something like |
build.sbt
Outdated
Test / fork := true, | ||
Test / javaOptions += s"-Dtoolkit.testing.classpath=${(Test / fullClasspath).value | ||
.map(_.data.getAbsolutePath) | ||
.mkString(File.pathSeparator)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this, we can just pass the classpath as a BuildInfo
key. Then we also don't need to fork.
Also Compile / dependencyClasspath
should be sufficient if we can move scala-cli out of test scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could do this only if Compile / dependencyClasspath
is a setting. You can't depend on tasks, neither using .value
in settings definition. I'll try but I'm not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh. Well that's annoying, forgot that. Ok, so then maybe we need to pass it as an env variable so that JS and Native can pick it up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😎
buildInfoKeys +=
BuildInfoKey.map(Compile / dependencyClasspath) { case (k, v) =>
(k, v.seq.map(_.data.getAbsolutePath).mkString(File.pathSeparator))
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be used in the CE build too :)
@armanbilge we should be done :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really great! TIL a bunch of stuff too 🤓 Sorry, I just have way too many nitpicks 😅
toolkit-testing/shared/src/test/scala/org/typelevel/toolkit/ScalaCliProcess.scala
Outdated
Show resolved
Hide resolved
toolkit-testing/shared/src/test/scala/org/typelevel/toolkit/ScalaCliProcess.scala
Outdated
Show resolved
Hide resolved
toolkit-testing/shared/src/test/scala/org/typelevel/toolkit/ScalaCliProcess.scala
Outdated
Show resolved
Hide resolved
toolkit-testing/shared/src/test/scala/org/typelevel/toolkit/ScalaCliProcess.scala
Outdated
Show resolved
Hide resolved
toolkit-testing/shared/src/test/scala/org/typelevel/toolkit/ScalaCliProcess.scala
Outdated
Show resolved
Hide resolved
toolkit-testing/shared/src/test/scala/org/typelevel/toolkit/ToolkitCompilationTest.scala
Outdated
Show resolved
Hide resolved
toolkit-testing/shared/src/test/scala/org/typelevel/toolkit/ToolkitCompilationTest.scala
Outdated
Show resolved
Hide resolved
toolkit-testing/shared/src/test/scala/org/typelevel/toolkit/ToolkitCompilationTest.scala
Outdated
Show resolved
Hide resolved
toolkit-testing/shared/src/test/scala/org/typelevel/toolkit/ToolkitCompilationTest.scala
Outdated
Show resolved
Hide resolved
@armanbilge I've addressed most of the suggestions but:
|
What's the error? Are you publishing it locally?
Something seems wrong with the filename? |
Nope, I can't recall how to use the toolkit-test artifact, we haven't written a line on doc on how to use it 😓 |
You don't need to do anything, it's automatically in scope when you use |
O_O Is the |
tests/shared/src/test/scala/org/typelevel/toolkit/ScalaCliProcess.scala
Outdated
Show resolved
Hide resolved
Using //> using toolkit typelevel::latest
import cats.effect.*
import munit.*
class Test extends CatsEffectSuite:
test("test")(IO.unit) or on the same but with |
|
It may be an ex-post explanation, but after all, within this timeout, we should:
So the task is flaky by definition, as we rely on coursier and the internet speed of maven central (or whomever serves the scala native artifact). The real question is: how could have taken just 30 seconds to do all of this before? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nicely done 👏
Some of the CI runs that passed before mangling the general timeout took more than 30 seconds O_O' |
The 30 second timeout applies per-test, not per-suite. So maybe that's how? or was a single test taking 38 seconds? |
Single test apparently: https://github.com/typelevel/toolkit/actions/runs/6309440614/job/17129364102 |
Still, that's not a mistery that we'll solve here @armanbilge :D Whenever you want,sir |
After some brainstorming with @armanbilge, I added some tests to the CI to compile some scripts using scala-cli.
The whole logic is simple:
toolkitTesting / Test / test
depends ontoolkit.jvm / publishLocal
so that before running the tests the artifact gets published locallyscalaversion
andversion
available in the test scopeScalaCli.main(Array("compile", "<tempFileName>"))
Two specialized method were added, to test both scala 3.x.x and 2.13.x syntax (and toolkit artifact)
Solves #50.