-
Notifications
You must be signed in to change notification settings - Fork 443
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
Creating native-package for tests #1336
Comments
Hi @mdedetrich and thanks for the feature request 😊 I had a similar requirement at my company. We wanted to run the integration tests and regression tests for downstream services. We didn't use native packager back then, but the idea is the same. You put your tests in a submodule and everything in compile and not test scope. Then you'll get an executable for your tests. Having that said . We replaced this with simple git checkouts of the last successful build and use sbts IntegrationTest scope. This is IMHO out of scope for native packager. I would definitely merge an example in the recipes section of the docs. 😀 |
So this is a related issue, but I am not sure if he managed to figure out how to do it with sub-projects (i.e. If you could provide a working example in recipes that would be fantastic! |
I forgot about the sub project part 😅 . This is tricky. Native packager doesn't really aggregate sub modules. You enable packaging for module and the classpath dependencies will be packaged as jars, but that's it. Replicating sbt inside a package that you need to package with sbt. I would consider checking out the repository and run SBT is a neat tool, but somethings like "replicate everything like task X" are as complex as sbt itself 😬 |
Yeah this is the issue, for the way that CDP is set up at our work it greatly complicates things. It will substantially increase build times and will also cause us to build things twice. Trust me, if I could do it this way I would
I wonder how difficult this would be? I might try doing some hacking on sbt-native-packager myself to see how hard this would be, I already asked a question on stack overflow which sbt's maintainer replied. Would you be open to adding the ability to automatically aggregate sub-modules or is that still out of scope for you? |
I do 😂 We had performance issues as well, but got to an acceptable level by running the regression tests in parallel on jenkins.
I'm not sure what the overall feature looks like. The issue you are having is two fold. One to create a test package. This is doable for a single module by using compile dependencies. Aggregating over sub modules in another scope is a different thing. Maybe I phrased "native package doesn't really aggregate sub modules" wrong. Native packager aggregates classpath dependencies defined via
A scratch of a lazy val regressionTestBundle = project.in(file("regression-test-bundle"))
.enablePlugins(JavaAppPackaging)
.settings(
Compile / mainClass := Some("org.scalatest.tools.Runner")
)
.dependsOn(
service1 % "compile->compile,compile->test",
service2 % "compile->compile,compile->test"
) resources |
Perfect, I am going to try this out and see if it works. |
Thank you, I managed to do with bellow settings.
|
@mdedetrich Could you share how did you handle this problem? Group all unit-tests to a module, and group all inter-tests to another module as muuki88 suggestion? Or did you manage to find a better way? |
I didn't end up implementing this since it was a technical problem in the previous company I worked at and I have since left. |
This is more of a feature request than a bug report. I have an interesting problem at work where I need to create a package but for my tests rather than my application, so idea would be rather than doing
universal:packageBin
you would dotest:packageBin
ortest:universal:packageBin
.Ideally it would replicate everything the same way the tests would work, including with parent/sub projects, i.e. by default running
test
on a parent project would also run tests for all of the sub projects.I also assume that you need to put the sbt test runner into the package or something along those lines?
The text was updated successfully, but these errors were encountered: