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

build(core): support scala native + enabled JS tests #909

Merged
merged 5 commits into from
Dec 6, 2024

Conversation

ThijsBroersen
Copy link
Contributor

@ThijsBroersen ThijsBroersen commented Nov 23, 2024

This PR provides support for Scala Native for module core.

While implementing I discovered all tests were only defined for the JVM. For JS nothing was tested. I moved all tests to shared.
Then I discovered all File related code is incompatible with the JS platform. I moved this to jvm-native.

Only the mimaChecks seem fail because I had to move some shared zio.logging package code and add the platform specific package code in the platform directories.
I could fix it by duplicating the package objects..
Is there any way it can be fixed without duplicating the code? I tried the scala3-library transparentTrait but that did not fix it and is not available for Native.

@ThijsBroersen ThijsBroersen requested a review from a team as a code owner November 23, 2024 22:24

object SimpleApp extends ZIOAppDefault {

override val bootstrap: ZLayer[ZIOAppArgs, Any, Any] =
Runtime.removeDefaultLoggers >>> consoleLogger(ConsoleLoggerConfig.default)
if (Platform.isJS) ZLayer.empty
else Runtime.removeDefaultLoggers >>> consoleLogger(ConsoleLoggerConfig.default)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

on JS this seems to remove all logging... ideas?

Copy link
Contributor

Choose a reason for hiding this comment

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

personally i do not have experience with scala JS, but if there are differences i think is better to do example specific for jvm and JS

Copy link
Contributor

Choose a reason for hiding this comment

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

anyway, with that condition, it look like that for platform JS it will not use consoleLogger(ConsoleLoggerConfig.default)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed it, all platforms use the same setup again. And discovered it wasn't working before because the scala-java-time-tzdb dependency was missing. Added them to 'core' because it is always required when using zio-logging.

@@ -152,7 +152,7 @@ private[logging] object LogAppender {
}

def json(textAppender: String => Any): LogAppender = new LogAppender { self =>
val AnsiColorRegex = "\\u001b\\[\\d+m".r
val AnsiColorRegex = """\033\[\d+m""".r
Copy link
Contributor Author

@ThijsBroersen ThijsBroersen Nov 23, 2024

Choose a reason for hiding this comment

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

The unicode is not compatible with Native. This ANSI is.

@ThijsBroersen ThijsBroersen changed the title build(core): support scala native build(core): support scala native + enabled JS tests Nov 23, 2024
@ThijsBroersen ThijsBroersen force-pushed the feat/core/support-scala-native branch 4 times, most recently from 3218617 to 94fb3cc Compare November 24, 2024 20:21
@justcoon
Copy link
Contributor

hi @ThijsBroersen , thank you very much for contribution

@@ -16,6 +16,7 @@ inThisBuild(
List(
name := "zio-logging",
ciEnabledBranches := Seq("master"),
// ciJvmOptions ++= Seq("-Xmx6g", "-Xss2m", "-XX:+UseG1GC"),
Copy link
Contributor

Choose a reason for hiding this comment

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

is this some leftover ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is was rendered in the ci.yaml but not properly picked up in the job. If you check the jobs here then you will see it was picked up but later in the job it still seemed to have only the default 1GB of memory: https://github.com/zio/zio-logging/actions/runs/11993647760/job/33434815940
So for now I added a .jvmopts file to fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left the commented out part there so it can be fixed. I am not sure where it goes wrong. It prints NOTE: Picked up JDK_JAVA_OPTIONS: -XX:+PrintCommandLineFlags -Xmx6G -Xss2M -XX:+UseG1GC -XX:G1ConcRefinementThreads=4 -XX:GCDrainStackTargetSize=64 -XX:InitialHeapSize=1073741824 -XX:MaxHeapSize=1073741824 -XX:+PrintCommandLineFlags -XX:ReservedCodeCacheSize=134217728 -XX:ThreadStackSize=4096 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseG1GC which shows different InitialHeapSize and MaxHeapSize than the passed Xmx.
Locally I have the same issue. I am a bit puzzeled here. With the .jvmopts it is fine.

@@ -49,13 +49,13 @@ object ReconfigurableLoggerSpec extends ZIOSpecDefault {
_ <- ZIO.logDebug("debug")
elements1 <- queue.takeAll
_ <- TestSystem.putProperty("logger/format", "%level %message")
_ <- ZIO.sleep(500.millis)
_ <- ZIO.sleep(1000.millis)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it looks like on the JS platform it sometimes takes a bit longer to reconfigure

@justcoon
Copy link
Contributor

justcoon commented Nov 28, 2024

@ThijsBroersen nice, actually did you look into https://github.com/zio/zio-logging/tree/master/docs section if something do not need to be updated? seems to not, but just in case ...

in relation to package changes, we should probably to do minor release (which i think will be 2.5.0)

@ThijsBroersen
Copy link
Contributor Author

@justcoon update one line which was only mentioning JVM and JS support.

@justcoon
Copy link
Contributor

justcoon commented Dec 5, 2024

hello @ThijsBroersen , thanks for contribution, can we follow with merge of this PR, or do you want to add something?
can you rebase your PR to latest master changes? thanks

@ThijsBroersen
Copy link
Contributor Author

hello @ThijsBroersen , thanks for contribution, can we follow with merge of this PR, or do you want to add something?
can you rebase your PR to latest master changes? thanks

All is fine. Not near a computer for the next few hours, can rebase later today.

@ThijsBroersen ThijsBroersen force-pushed the feat/core/support-scala-native branch from fbd77c9 to 10ddb39 Compare December 6, 2024 07:07
@ThijsBroersen
Copy link
Contributor Author

Rebased

@justcoon justcoon merged commit 7934eba into zio:master Dec 6, 2024
15 checks passed
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.

2 participants