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

Scala 2.13 upgrade #195

Merged
merged 2 commits into from
Jul 24, 2024
Merged

Scala 2.13 upgrade #195

merged 2 commits into from
Jul 24, 2024

Conversation

rtyley
Copy link
Member

@rtyley rtyley commented Jul 23, 2024

Required for facia-scala-client to drop support for Scala 2.12: guardian/facia-scala-client#317

Scala 2.13 Fixes

  • Switched from JavaConverters to 2.13's CollectionConverters.
  • Widening conversion from Long to Double is deprecated, so used toDouble instead.
  • Previously Buffer could be assigned to Seq, because Seq was mutable. Now Seq is immutable by default, so toSeq is needed to create a Seq from a Buffer.
  • Either is now right-biased, so .right is no longer needed.
  • .mapValues is deprecated, need .view.mapValues instead. .toMap is also needed to get back to a Map from a MapView.
  • Auto-application is deprecated, so () must be added in some cases.
  • Deleted Enumerators because it wasn't used, and it was using features unsupported in Scala 2.13.

Testing In CODE

We deployed to CODE and created a new package, as seen here:

testing-pr

See also

"com.gu" %% "thrift-serializer" % "4.0.0",
"com.gu" %% "thrift-serializer" % "4.0.2",
Copy link
Member Author

Choose a reason for hiding this comment

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

This was the first version of thrift-serializer to support Scala 2.13, so this is the most minimal change I could make to get the project to compile. There have been many newer versions since then, the current is 5.0.7:

https://index.scala-lang.org/guardian/thrift-serializer/artifacts/thrift-serializer

@rtyley rtyley changed the title WIP: Scala 2.13 upgrade Scala 2.13 upgrade Jul 23, 2024
rtyley and others added 2 commits July 23, 2024 17:31
Switched from `JavaConverters` to 2.13's `CollectionConverters`.

Widening conversion from `Long` to `Double` is deprecated, so used `toDouble` instead.

Previously `Buffer` could be assigned to `Seq`, because `Seq` was mutable. Now `Seq` is immutable by default, so `toSeq` is needed to create a `Seq` from a `Buffer`.

`Either` is now right-biased, so `.right` is no longer needed.

`.mapValues` is deprecated, need `.view.mapValues` instead. `.toMap` is also needed to get back to a `Map` from a `MapView`.

Auto-application is deprecated, so `()` must be added in some cases.

Deleted `Enumerators` because it wasn't used, and it was using features unsupported in Scala 2.13.
@JamieB-gu JamieB-gu marked this pull request as ready for review July 23, 2024 16:53
@davidfurey
Copy link
Member

The snyk project for this application is called story-packages:story-packages_2.12. Once this PR is merged, a new project story-packages:story-packages_2.13 will be created, but the old project will not automatically be cleaned up. Can you delete the old project once this is merged?

@rtyley rtyley merged commit 041d694 into main Jul 24, 2024
3 checks passed
@rtyley rtyley deleted the upgrade-to-scala-v2.13 branch July 24, 2024 10:11
@prout-bot
Copy link

Seen on PROD (merged by @rtyley 17 minutes and 56 seconds ago) Please check your changes!

@rtyley
Copy link
Member Author

rtyley commented Jul 24, 2024

Once this PR is merged, a new project story-packages:story-packages_2.13 will be created, but the old project will not automatically be cleaned up. Can you delete the old project once this is merged?

As you predicted, once merged, there was a new story-packages:story-packages_2.13 snyk project, effectively a duplicate:

image

...so I have now deleted the old story-packages:story-packages_2.12 one:

image

@rtyley
Copy link
Member Author

rtyley commented Jul 24, 2024

I've double-checked https://packages.gutools.co.uk/editorial, and it looks good!

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

Successfully merging this pull request may close these issues.

4 participants