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

Migrate the core module and tests to scala 3 #883

Merged
merged 6 commits into from
Aug 4, 2022

Conversation

jchyb
Copy link
Contributor

@jchyb jchyb commented Jun 23, 2022

All of the tests but one pass (the failing one is deserialize automatically with spray-json JsonFormat (optional list with optional values and default) in FromInputSpec - I have not yet figured out why that is. All of the tests should pass now.

For the code in the PR to work some dependencies need to be released for scala 3 and have their version updated. I commented near those dependencies with "TODO needs release", those releases should contain the following PRs to work:

While some changes to the codebase may seem questionable, they are the result of changed type inference, and, in a few cases, bugs:

I imagine once those become fixed, the various workarounds used could be removed.

I still have to complete the sangria-derivation module to finish the migration, which may take some time. However the basic functionality of defining graphql code and executing queries should be already working.

@jchyb jchyb marked this pull request as draft June 23, 2022 10:52
@yanns yanns mentioned this pull request Jun 25, 2022
@yanns
Copy link
Contributor

yanns commented Jun 28, 2022

@jchyb jchyb force-pushed the scala-3 branch 2 times, most recently from 126b1ae to a72721c Compare July 19, 2022 13:53
@jchyb jchyb marked this pull request as ready for review August 3, 2022 14:39
@jchyb
Copy link
Contributor Author

jchyb commented Aug 3, 2022

I finally managed to fix all of the tests, with the one mentioned above being more important than I initially though. sangria-derivation module is also finished and working (with a small exception), but I think I should make a separate PR for that.

@jchyb jchyb force-pushed the scala-3 branch 2 times, most recently from 5b856b0 to a718dc1 Compare August 4, 2022 08:19
@yanns
Copy link
Contributor

yanns commented Aug 4, 2022

There are 2 scalac options that we should deactivate for scala3:

[warn] bad option '-Xlint:-missing-interpolator,_' was ignored
[warn] bad option '-target:jvm-1.8' was ignored

Example on how to deal with that: https://github.com/sangria-graphql/sangria-spray-json/blob/main/build.sbt#L27

Copy link
Contributor

@yanns yanns left a comment

Choose a reason for hiding this comment

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

Thanks a lot for all this effort!! ❤️

@yanns
Copy link
Contributor

yanns commented Aug 4, 2022

The mimaReportBinaryIssues should not be triggered on scala 3.
This can be configured like in https://github.com/sangria-graphql/sangria-spray-json/blob/main/build.sbt#L6-L12

@jchyb
Copy link
Contributor Author

jchyb commented Aug 4, 2022

I had some trouble with disabling sangria-derivation compilation in Scala 3 (despite not having sources to compare to, mima plugin would still try to compile sangria-derivation), so for now I've removed Scala 3 from sbt-github-actions and set up simple separate GHA manually for scala 3 (via the ci-scala3.yml file). Later when PR'ing sangria-derivation I will remove that file and reenable the previous sbt-github-actions for scala 3

@yanns
Copy link
Contributor

yanns commented Aug 4, 2022

I had some trouble with disabling sangria-derivation compilation in Scala 3 (despite not having sources to compare to, mima plugin would still try to compile sangria-derivation), so for now I've removed Scala 3 from sbt-github-actions and set up simple separate GHA manually for scala 3 (via the ci-scala3.yml file). Later when PR'ing sangria-derivation I will remove that file and reenable the previous sbt-github-actions for scala 3

That's a reasonable approach for the time being! 👍

Comment on lines -73 to 75
sealed trait MappedAbstractType[T] extends Type with AbstractType with OutputType[T] {
sealed trait MappedAbstractType[T] extends Type with AbstractType {
def contraMap(value: T): Any
}
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 see that this change causes binary compatibility errors (for scala 2). I removed OutputType[T] as it would cause compiler conflicts in scala 3 (there is another place where an anonymous class is created with both OutputType[T] from MappedAbstractType and OutputType[Any] from UnionType). Removing it here did not cause any problems elsewhere, so I did not think much of it. Since the this is a sealed trait inside a file full of them, making a version specific versions of the file seems impractical and heavy on the maintenance work... Outside of breaking binary compatibility the only solution I can think of is something akin to akka/akka-http#4113, where they have an sbt plugin that filters some implementations out of a single file depending on the scala version used

Copy link
Contributor

Choose a reason for hiding this comment

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

You can also add some mimaBinaryIssueFilters.

Copy link
Contributor

@yanns yanns left a comment

Choose a reason for hiding this comment

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

💯 🥇

@yanns
Copy link
Contributor

yanns commented Aug 4, 2022

For me, the PR is looking ready to merge to that we can iterate on that. Or do you still have something to change on it?

@yanns
Copy link
Contributor

yanns commented Aug 4, 2022

Can you check is the publishing part would only publish the modules that are ready for scala 3?
sangria-derivation should not be published for scala 3 for example.

@jchyb
Copy link
Contributor Author

jchyb commented Aug 4, 2022

I think we can merge, anything else that I have not committed yet concerns sangria-derivation module, which is separate. About the publishing, the original GitHub action yml now does not have any mention of Scala 3 (as I purposefully removed it for now), and the new one I created does not have the publish action. I was planning to reenable the publish action via the original yaml when I PR sangria-derivation (which is ready, outside of some small issues which I am not sure I can fix)

@yanns
Copy link
Contributor

yanns commented Aug 4, 2022

One more advantage of a separated GH action! Cool!

@yanns yanns merged commit f49d860 into sangria-graphql:main Aug 4, 2022
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