-
Notifications
You must be signed in to change notification settings - Fork 76
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
Create Scaladex badge that supplies info on supported Scala versions #660
Conversation
The refactor in this commit is driven by the work in the subsequent commit for issue scalacenter#659 (creating a Scaladex badge that supplies concise info on supported Scala versions). The key word there is 'concise' - given the many Scala artifacts that can be published for a single artifact version (the matrix of Scala language version, the platform - Scala JS/Native/SBT - and the platform version), achieving a concise summary requires a lot of grouping by those properties. Grouping by Scala `LanguageVersion` was easy enough, but grouping by platform & platform version was harder, as there wasn't any existing class to represent that. Consequently, I introduced the concept of a 'platform edition' (eg 'Scala JS 0.6', or 'Scala Native 0.4'), which is composed of two values: * targetType (Scala JS, Scala Native, or SBT) * platform version (eg the version '0.6' or '1.0' of Scala JS) ...this is like a `ScalaTarget`, but without the Scala Language version that `ScalaTarget` includes (eg a `ScalaTarget` is specifically compiled for, eg, _Scala 2.11_ on Scala JS 0.6). Having introduced the concept of `PlatformEdition`, it made sense to redefine relevant `ScalaTarget`s in terms of that - to do this meant moving several ad-hoc methods from the companion objects of `ScalaTarget` implementations (ie `ScalaJs`, `ScalaNative`, `SbtPlugin`) to the corresponding `ScalaTargetType` implementations and making them more widely available, by declaring them in the new `PlatformVersionedTargetType` trait, removing duplication for this existing code: * producing a String `render` value for platform names * checking validity of platform versions. As result most of the `ScalaTarget` companion objects were now empty and could be deleted. Another smaller change was prompted by the upcoming need to identify a `ScalaTargetType` by name (when the user specifies it as a query string parameter). To do that, you need a full list of `ScalaTargetType`s, and then you can also use that list to create an `Ordering[ScalaTargetType]` Also tidied up various tests that were creating their own platform version constants (as I was already moving equivalent constants from `ScalaTarget` companion objects to `ScalaTargetType` objects)
Fixes scalacenter#659 - adding support for a badge that summarises, for a given artifact, which versions of Scala it supports (and what the latest artifact version is for each of those Scala versions). ``` $ curl --silent -I http://localhost:8080/typelevel/cats/cats-core/latest-by-scala-version.svg | grep Location Location: https://img.shields.io/badge/cats--core-0.9.0_(Scala_2.12,_2.11,_2.10)-green.svg? $ curl --silent -I http://localhost:8080/typelevel/cats/cats-core/latest-by-scala-version.svg?targetType=Js | grep Location Location: https://img.shields.io/badge/cats--core-0.9.0_(Scala_2.12,_2.11,_2.10_--_Js_0.6)-green.svg? ```
Hi there! Is there anything I can do to help with getting this PR merged? If the size of the PR is a blocker I can try removing the refactor in the first commit? |
Thanks for the reminder @rtyley! I'll do the review today and the refactoring should not be a problem. |
server/src/test/scala/ch.epfl.scala.index.server/ArtifactScalaVersionSupportTest.scala
Outdated
Show resolved
Hide resolved
Prompted by scalacenter#660 (comment), this is a testcase for when Scala platform editions are not available for all cited Scala versions. In this situation, there are a few options for what the badge text could be: * Over promise: `7.1.0 (Scala 3.0.0-M3, 2.13 - Native 0.4+0.3)`, which incorrectly implies that there's a `3.0.0-M3` version for `Native 0.4`. * Provide full detail: `7.1.0 (Scala 3.0.0-M3 - Native 0.4, Scala 2.13 - Native 0.3)`. * Omit platform versions that don't have full support for the listed Scala language versions: `7.1.0 (Scala 3.0.0-M3, 2.13)`. The endpoint `latest-by-scala-version.svg`, is intended to list all supported Scala versions, with the latest artifact version against them, and giving that information concisely takes priority over providing completely comprehensive information about the differing versions of the Scala platforms. It's also best not to over-promise, so of the three options I think the last is the best.
I have deployed this PR on https://index-dev.scala-lang.org/ for testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the general idea and the trade-off between conciseness and accuracy of the badges are good. Also the tests are very clear.
I left some comments about the organization of the code.
server/src/main/scala/ch.epfl.scala.index.server/routes/Badges.scala
Outdated
Show resolved
Hide resolved
server/src/main/scala/ch.epfl.scala.index.server/ArtifactScalaVersionSupport.scala
Outdated
Show resolved
Hide resolved
* Switch from case class to function that encloses intermediate states * Rename `ArtifactScalaVersionSupport` to `BadgesSupport` as it's only used by the `Badges` class scalacenter#660 (comment) scalacenter#660 (comment) I've overloaded the `summaryOfLatestVersions()` method so the tests can have a version of the method that accepts a `Map[SemanticVersion, Seq[ScalaTarget]]` - it makes the tests more concise.
Many thanks for the feedback! As suggested, I've removed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
Prompted by #660 (comment), this is a testcase for when Scala platform editions are not available for all cited Scala versions. In this situation, there are a few options for what the badge text could be: * Over promise: `7.1.0 (Scala 3.0.0-M3, 2.13 - Native 0.4+0.3)`, which incorrectly implies that there's a `3.0.0-M3` version for `Native 0.4`. * Provide full detail: `7.1.0 (Scala 3.0.0-M3 - Native 0.4, Scala 2.13 - Native 0.3)`. * Omit platform versions that don't have full support for the listed Scala language versions: `7.1.0 (Scala 3.0.0-M3, 2.13)`. The endpoint `latest-by-scala-version.svg`, is intended to list all supported Scala versions, with the latest artifact version against them, and giving that information concisely takes priority over providing completely comprehensive information about the differing versions of the Scala platforms. It's also best not to over-promise, so of the three options I think the last is the best.
Many thanks! I'm post-vaccine today, and so recovering from the common side-effects, but I'm look forward to applying this badge to all my projects! 🎉 |
Badge introduced with scalacenter/scaladex#660
Badge introduced with scalacenter/scaladex#660
Badge introduced with scalacenter/scaladex#660
Badge introduced with scalacenter/scaladex#660
Badge introduced with scalacenter/scaladex#660
Badge introduced with scalacenter/scaladex#660
Badge introduced with scalacenter/scaladex#660
Badge introduced with scalacenter/scaladex#660
Badge introduced with scalacenter/scaladex#660 A few other documentation tweaks have crept in.
The new badge was introduced with scalacenter/scaladex#660
I contributed slightly broken versions of these in scalacenter#660
This Scaladex badge summarises which versions of Scala are supported by `twitter4s` (and what the latest `twitter4s` version is for each of those Scala versions), so it provides a bit more information than a Maven badge: [![twitter4s Scala version support](https://index.scala-lang.org/danielasfregola/twitter4s/twitter4s/latest-by-scala-version.svg)](https://index.scala-lang.org/danielasfregola/twitter4s/twitter4s) More details on the badge format: scalacenter/scaladex#660
The Scaladex badge is a bit more helpful than the Maven Central badge - it summarises which versions of sbt are supported by sbt-updates (and what the latest sbt-updates version is for each of those sbt versions: [![sbt-updates Scala version support](https://index.scala-lang.org/rtimush/sbt-updates/sbt-updates/latest-by-scala-version.svg?targetType=Sbt)](https://index.scala-lang.org/rtimush/sbt-updates/sbt-updates) Interestingly, at the moment, there is a new 0.6.2 release of `sbt-updates` for sbt 0.13, but not for 1.0, which wouldn't have been indicated by the old badge! More details on the badge format here: scalacenter/scaladex#660 (with some extra changes to better support sbt in scalacenter/scaladex#674).
Unfortunately the Bintray badge on the readme is broken, I guess due to Bintray being [sunset](https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/)? However, this new Scaladex badge can replace the old Bintray badge - it summarises which versions of sbt are supported by sbt-native-packager (and what the latest sbt-native-packager version is for each of those sbt versions): [![sbt-native-packager Scala version support](https://index.scala-lang.org/sbt/sbt-native-packager/sbt-native-packager/latest-by-scala-version.svg?targetType=Sbt)](https://index.scala-lang.org/sbt/sbt-native-packager/sbt-native-packager) More details on the badge format here: scalacenter/scaladex#660 (with some extra changes to better support sbt in scalacenter/scaladex#674).
This Scaladex badge summarises which versions of Scala are supported by `scalatra` (and what the latest `scalatra` version is for each of those Scala versions), so it provides a bit more information than a Maven badge: [![scalatra Scala version support](https://index.scala-lang.org/scalatra/scalatra/scalatra/latest-by-scala-version.svg?platform=jvm)](https://index.scala-lang.org/scalatra/scalatra/scalatra) More details on the badge format: scalacenter/scaladex#660
This Scaladex badge summarises which versions of Scala are supported by `scalatra` (and what the latest `scalatra` version is for each of those Scala versions), so it provides a bit more information than a Maven badge: [![scalatra Scala version support](https://index.scala-lang.org/scalatra/scalatra/scalatra/latest-by-scala-version.svg?platform=jvm)](https://index.scala-lang.org/scalatra/scalatra/scalatra) More details on the badge format: scalacenter/scaladex#660
This Scaladex badge summarises which versions of Scala are supported by `atom-publisher-lib` (and what the latest `atom-publisher-lib` version is for each of those Scala versions), so it provides a bit more information than a Maven badge: [![atom-publisher-lib Scala version support](https://index.scala-lang.org/guardian/atom-maker/atom-publisher-lib/latest-by-scala-version.svg?platform=jvm)](https://index.scala-lang.org/guardian/atom-maker/atom-publisher-lib) More details on the badge format: scalacenter/scaladex#660
…1458) This Scaladex badge summarises which versions of Scala are supported by `scalatra` (and what the latest `scalatra` version is for each of those Scala versions), so it provides a bit more information than a Maven badge: [![scalatra Scala version support](https://index.scala-lang.org/scalatra/scalatra/scalatra/latest-by-scala-version.svg?platform=jvm)](https://index.scala-lang.org/scalatra/scalatra/scalatra) More details on the badge format: scalacenter/scaladex#660
This Scaladex badge summarises which versions of Scala are supported by `ScalaPB` (and what the latest `ScalaPB` version is for each of those Scala versions): [![compilerplugin Scala version support](https://index.scala-lang.org/scalapb/scalapb/compilerplugin/latest-by-scala-version.svg?platform=jvm)](https://index.scala-lang.org/scalapb/scalapb/compilerplugin) More details on the badge format: scalacenter/scaladex#660
Use Scaladex badge on ReadMe to show Scala version support This Scaladex badge summarises which versions of Scala are supported by `ScalaPB` (and what the latest `ScalaPB` version is for each of those Scala versions): More details on the badge format: scalacenter/scaladex#660 --------- Co-authored-by: Nadav Samet <thesamet@gmail.com>
This Scaladex badge summarises which versions of Scala are supported by `scaffeine` (and what the latest `scaffeine` version is for each of those Scala versions): [![scaffeine Scala version support](https://index.scala-lang.org/blemale/scaffeine/scaffeine/latest-by-scala-version.svg?platform=jvm)](https://index.scala-lang.org/blemale/scaffeine/scaffeine) More details on the badge format: scalacenter/scaladex#660
This Scaladex badge summarises which versions of Scala are supported by `mobile-apps-api-models` (and what the latest `mobile-apps-api-models` version is for each of those Scala versions): [![mobile-apps-api-models Scala version support](https://index.scala-lang.org/guardian/mobile-apps-api-models/mobile-apps-api-models/latest-by-scala-version.svg?platform=jvm)](https://index.scala-lang.org/guardian/mobile-apps-api-models/mobile-apps-api-models) At the moment, `mobile-apps-api-models` only supports Scala 2.12, but when you come to add Scala 2.13 support, the badge will update automatically. More details on the badge format: scalacenter/scaladex#660
This Scaladex badge summarises which versions of Scala are supported by `mobile-apps-api-models` (and what the latest `mobile-apps-api-models` version is for each of those Scala versions): [![mobile-apps-api-models Scala version support](https://index.scala-lang.org/guardian/mobile-apps-api-models/mobile-apps-api-models/latest-by-scala-version.svg?platform=jvm)](https://index.scala-lang.org/guardian/mobile-apps-api-models/mobile-apps-api-models) At the moment, `mobile-apps-api-models` only supports Scala 2.12, but when you come to add Scala 2.13 support, the badge will update automatically. More details on the badge format: scalacenter/scaladex#660
This Scaladex badge summarises which versions of Scala are supported by `scala-collection-compat` (and what the latest `scala-collection-compat` version is for each of those Scala versions): [![scala-collection-compat Scala version support](https://index.scala-lang.org/scala/scala-collection-compat/scala-collection-compat/latest-by-scala-version.svg?platform=jvm)](https://index.scala-lang.org/scala/scala-collection-compat/scala-collection-compat) More details on the badge format: scalacenter/scaladex#660
The Scaladex badge is a bit more helpful than the Maven Central badge - it summarises which versions of sbt are supported by sbt-updates (and what the latest sbt-updates version is for each of those sbt versions: [![sbt-updates Scala version support](https://index.scala-lang.org/rtimush/sbt-updates/sbt-updates/latest-by-scala-version.svg?targetType=Sbt)](https://index.scala-lang.org/rtimush/sbt-updates/sbt-updates) Interestingly, at the moment, there is a new 0.6.2 release of `sbt-updates` for sbt 0.13, but not for 1.0, which wouldn't have been indicated by the old badge! More details on the badge format here: scalacenter/scaladex#660 (with some extra changes to better support sbt in scalacenter/scaladex#674).
Currently, for the `content-api-firehose-client`, the Scaladex badges page is showing some contrasting values: https://index.scala-lang.org/guardian/content-api-firehose-client/badges * The 'Latest version' badge is showing a good version: 1.0.12 * The 'JVM badge' (which shows a summary of latest versions by supported Scala version, introduced with scalacenter#660) is showing an undesireable pre-release version: 1.0.13-PREVIEW.rt-dbremove-travis-file.2024-01-10T1738.6e259255 You can see both values on the versions page, but only if you tick the 'Show pre-release versions' button: * https://index.scala-lang.org/guardian/content-api-firehose-client/artifacts/content-api-firehose-client * https://index.scala-lang.org/guardian/content-api-firehose-client/artifacts/content-api-firehose-client?pre-releases=true#
Currently, for the `content-api-firehose-client`, the Scaladex badges page is showing some contrasting values: https://index.scala-lang.org/guardian/content-api-firehose-client/badges * The 'Latest version' badge is showing a good version: 1.0.12 * The 'JVM badge' (which shows a summary of latest versions by supported Scala version, introduced with scalacenter#660) is showing an undesireable pre-release version: 1.0.13-PREVIEW.rt-dbremove-travis-file.2024-01-10T1738.6e259255 You can see both values on the versions page, but only if you tick the 'Show pre-release versions' button: * https://index.scala-lang.org/guardian/content-api-firehose-client/artifacts/content-api-firehose-client * https://index.scala-lang.org/guardian/content-api-firehose-client/artifacts/content-api-firehose-client?pre-releases=true#
Currently, for the `content-api-firehose-client`, the Scaladex badges page is showing some contrasting values: https://index.scala-lang.org/guardian/content-api-firehose-client/badges * The 'Latest version' badge is showing a good version: 1.0.12 * The 'JVM badge' (which shows a summary of latest versions by supported Scala version, introduced with scalacenter#660) is showing an undesireable pre-release version: 1.0.13-PREVIEW.rt-dbremove-travis-file.2024-01-10T1738.6e259255 You can see both values on the versions page, but only if you tick the 'Show pre-release versions' button: * https://index.scala-lang.org/guardian/content-api-firehose-client/artifacts/content-api-firehose-client * https://index.scala-lang.org/guardian/content-api-firehose-client/artifacts/content-api-firehose-client?pre-releases=true# This PR fixes the behaviour on the latest-by-scala-version badge to match the behaviour of the other badge - it does this with a new PreferReleases ordering for SemanticVersions.
Fixes #659 - adding support for a badge that summarises, for a given artifact, which versions of Scala it supports (and what the latest artifact version is for each of those Scala versions).
...on my local box (with a minimal Scaladex elasticsearch index) this renders like this
Scala JS & Scala Native
By default, the badge summarises just Scala JVM artifacts, but it's easy to create platform-specific badges by adding
targetType=js
ortargetType=native
as a query-string parameter to the url:Refactor & Implementation
This PR is split into 2 commits:
ScalaTargetType
&ScalaTarget
to make grouping by 'platform edition' (eg 'Scala JS 1.x') easier (see commit message for more detail on that), which had the side benefit of reducing existing code duplication. TheScalaTarget
classes are still successfully deserialised from Elasticsearch- I haven't modified them to the point of breaking that!ArtifactScalaVersionSupport
to do all the grouping operations to give a concise summary of Scala version support for a given artifact. The accompanying tests inArtifactScalaVersionSupportTest
detail & test some of the desired behaviour of the badge summary text.cc @adpi2