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

Add scalafix rule for renaming assert to expect #70

Merged
merged 2 commits into from
Oct 15, 2024

Conversation

zainab-ali
Copy link
Contributor

This is a follow up to #69 . The RenameAssertToExpect rule renames calls to weaver assert to expect.

As part of the release, it would be great to add upgrade notes to the documentation and a scalafix migration.

@Baccata
Copy link
Collaborator

Baccata commented Oct 11, 2024

I'm not fully versed in scalafix migrations, but considering none of this code is wired in the sbt-build, does it mean that the scalafix folder is meant to be a self-contained project and scala-steward is able to build it on the fly ?

Copy link
Member

@kubukoz kubukoz left a comment

Choose a reason for hiding this comment

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

Are we missing the definition of RenameAssertToExpect?

Comment on lines +80 to +84
.jvmPlatform(
scalaVersions = Seq(V.scala212),
axisValues = Seq(TargetAxis(scala3Version)),
settings = Seq()
)
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain the need for the custom TargetAxis please? (also I suppose it has something to do with why this is mixing 2.12 and 3.x)

@zainab-ali
Copy link
Contributor Author

zainab-ali commented Oct 15, 2024

Apologies - I missed out a lot of context.

The scalafix directory is completely separate from the weaver build. It's intended to be temporary: we can delete this directory as soon as the assert / expect change is released.

A lot of the files (build.sbt and TargetAxis) were created by the scalafix Giter8 template. They let us run local tests against different Scala versions with sbt tests/test.

Since we don't need to maintain them past the release, I haven't looked into them in detail.

Scala steward migrations

The rule will be run by Scala steward, provided we add some config to the Scala steward repo.

The only necessary file for scala steward (or our users) to run the rule is the RenameAssertToExpect.scala file.

You can try this out locally on any project with the sbt-scalafix plugin:

sbt scalafixAll github:zainab-ali/typelevel-weaver-test/RenameAssertToExpect?sha=assert-scalafix-rule

The release process

When we instruct scala steward (or our users) to apply the rule, we'll reference a specific tag.

For example, if this rule is meant to be run as part of a v1.0.0 release, we can tell users to run:

sbt scalafixAll github:typelevel/weaver-test/RenameAssertToExpect?sha=v1.0.0

Since the file is referenced through a tag, we can delete the scalafix directory after the v1.0.0 release.

On a related note, I'm looking into how we can use scala steward's artifact migrations to seamlessly migrate users from disney to typelevel. Scala steward would need to migrate the artifact and apply the RenameAssertToExpect rule in one go.

I don't think there are any other API changes we can mitigate through scalafix rules. We have changed the signature of expect.same, but this should be source compatible for most users.

@Baccata Baccata merged commit 53ffd27 into typelevel:main Oct 15, 2024
13 checks passed
@zainab-ali zainab-ali deleted the assert-scalafix-rule branch October 15, 2024 16:14
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.

3 participants