scalameta / sbt-native-image

Plugin to generate native-image binaries with sbt
252 stars 22 forks source link

Add native image test task #60

Closed cobr123 closed 1 year ago

cobr123 commented 2 years ago

Added tasks:

Issue https://github.com/scalameta/sbt-native-image/issues/50

klpx commented 1 year ago

Really appreciate this work. Tested your branch. It works as expected without any problems. Built it with just:

sbt publishLocal

Tested with the following project configuration:

sbt.version = 1.8.2
nativeImageVersion := "22.3.1"
nativeImageJvm := "graalvm-java17"

The only thing I had to my buid.sbt is to specify test mainclass:

Test / mainClass := Some("my.app.ZioSpec")

Is there anything I can help to get this merged and released?

nartamonov commented 1 year ago

@ckipp @tgodzik @olafurpg Any hope the PR will be merged? :v: It's very useful feature, currently I use self-written task for running native tests at my work.

olafurpg commented 1 year ago

I'm on the phone right now so can't cut a release. Added a reminder to follow up and merge and release.

olafurpg commented 1 year ago

Published https://github.com/scalameta/sbt-native-image/releases/tag/v0.3.3 but may take a while for the jars to become available on Maven Central.

@nartamonov could you send a PR adding documentation to the readme so that people can discover this new functionality?

nayavu commented 1 year ago

@olafurpg 3 weeks have been passed but still no jars in Maven Central

ckipp01 commented 1 year ago

It looks like the publish job failed https://github.com/scalameta/sbt-native-image/actions/runs/4712517890. Looking I'm not really sure what's going on, but I'll update the release related things in https://github.com/scalameta/sbt-native-image/pull/69 and give it another try.

ckipp01 commented 1 year ago

Alright, the 0.3.4 tag correctly released https://github.com/scalameta/sbt-native-image/actions/runs/4893876177/jobs/8737347750. This should be available soon.

nayavu commented 1 year ago

@ckipp01 , thank you for resolving it so fast!

I created a small example of how to use new features to automate native image building for Akka HTTP, might be useful for someone: https://github.com/nayavu/akka-http-native-image

guizmaii commented 1 year ago

Hi everyone,

Does anyone know what I have to put in Test / main := Some(???) to run ZIO tests with the new nativeImageTestRun cmd?

I see in @nayavu's example, that for ScalaTest, it's: Test / mainClass := Some("org.scalatest.tools.Runner") but I don't find the equivalent for ZIO.

I tried several things and gets this error:

Error: Method 'zio.test.sbt.ZTestRunnerJVM.main' is declared as the main entry point but it can not be found. Make sure that class 'zio.test.sbt.ZTestRunnerJVM' is on the classpath and that method 'main(String[])' exists in that class.

Thanks

cobr123 commented 1 year ago

example with zio-test https://github.com/cobr123/matrix-rain/blob/main/build.sbt