Skip to content
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

Feat/support projectmatrix and support better crossbuilding #440

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

ThijsBroersen
Copy link

@ThijsBroersen ThijsBroersen commented Nov 3, 2024

This PR contains quite some changes but tries to minimize the impact for the user.

After working with multiple zio-repos I noticed the build and ci setups have quite some duplication (copy paste) but also quite some differences (diverging over time). With this PR I hope the projects can scrap a lot of their own boilerplate and reuse as much as is convenient from the plugins from zio-sbt.

There are multiple projects which are building JS, JVM and Native separately in CI, this PR now does that by default by including the platforms in the ci-matrix.
The

I added two new plugins: ZioSbtProjectPlugin and ZioSbtShared

ZioSbtShared contains banner and tasks utils. Easy helpers to show info to the user.

ZioSbtProjectPlugin sets a default javaPlatform to target when building artifacts by setting the -release flag.
The plugin also adds a banner to show what java and scala versions and platforms are being used in the project.

e.g.

Scala 2.12.x 2.13.15 3.3.4
JS
JVM
Native

I have added multiple compile and test tasks:

Platform Scala 2.12 Scala 2.13 Scala 3 All
JVM compileJVM2_12 compileJVM2_13 compileJVM3 compileJVM
Scala.js compileJS2_12 compileJS2_13 compileJS3 compileJS
Scala Native compileNative2_12 compileNative2_13 compileNative3 compileNative
All compile2_12 compile2_13 compile3 compile
Platform Scala 2.12 Scala 2.13 Scala 3 All
JVM testJVM2_12 testJVM2_13 testJVM3 testJVM
Scala.js testJS2_12 testJS2_13 testJS3 testJS
Scala Native testNative2_12 testNative2_13 testNative3 testNative
All test2_12 test2_13 test3 test

When using sbt-projectmatrix the idea is to have all in the same build scope. You will see the welcome message showing tasks for all versions and platforms available. If a compile or test task is tried for a something which is not in the current context then it will be an empty task.

ZioSbtCiPlugin I extended here and there. Based on the platforms and scala versions it will now create a matrix for the ci jobs as default behaviour.
It is now also possible to set a java distribution via ciDefaultJavaDistribution.

Check the README.md for other changes.

note: this PR also contains migrations to zio-json, as I continued on my previous PR #438

@ThijsBroersen ThijsBroersen force-pushed the feat/support-projectmatrix-and-support-better-crossbuilding branch from 36f8dcf to 6f4cdd4 Compare November 3, 2024 14:12
@ThijsBroersen
Copy link
Author

ThijsBroersen commented Nov 3, 2024

What I would like to do is to create some draft PRs for other ZIO projects to show the results. Can someone publish some snapshots from this PR perhaps?
I published my own fork and made some draft, example PRs:
zio/zio-logging#908
zio/zio-json#1190
zio/zio-config#1466
zio/zio-kafka#1397

.value,
doc / skip := BuildAssertions.requireNative(true).value,
Compile / doc / sources := BuildAssertions.requireNative(Seq.empty).value
// Test / test := { val _ = (Test / compile).value; () } // ??
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this previously set? What is the benefit?

@ThijsBroersen ThijsBroersen force-pushed the feat/support-projectmatrix-and-support-better-crossbuilding branch from 92e42b4 to 6278bc7 Compare November 16, 2024 09:06
@ThijsBroersen ThijsBroersen force-pushed the feat/support-projectmatrix-and-support-better-crossbuilding branch 2 times, most recently from b44ab58 to 492eead Compare November 16, 2024 12:03
@ThijsBroersen ThijsBroersen force-pushed the feat/support-projectmatrix-and-support-better-crossbuilding branch from 492eead to a4c166f Compare November 16, 2024 13:30
_.flatten
) ++
Seq(Lint.value) ++
(if (ciCheckMima.value) Seq(CheckMima.value) else Seq.empty[Step.SingleStep])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it is better to have dedicated mima jobs? Per Scala version/platform?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkMima is now part of the lint job. Can be disabled with checkMima / skip := true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant