typelevel / typelevel/sbt-typelevel

tlIsScala3 may not be set correctly within GIthub Workflow commands

Open
#792 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
185
Forks
62
PR merge metrics
No merged PRs in 30d

Description

So I have a project that cross-compiles to Scala 2.13 and Scala 3.X. However, the Circe model is set to only compile to Scala 2.13 because at the time Circe did not yet have a Scala 3 release. In between working on the project was the change in the Gihub workers which dropped SBT and so I updated sbt-typelevel from 0.6.4 to 0.7.6 for the workflows to be generated with setup-sbt.

However, after pushing up some new commits, I had the workflows fail because they are trying to build or check binaries for Scala 3 for the braid-circe project.

The build.sbt as done for sbt-typelevel 0.6.4 is here:
https://github.com/quincyjo/braid/blob/a34aec3e2b9f1f2cb9a4ba7000eae69e35fe667d/build.sbt
And the one which passed binary check but failed to compile Scala 3 tests by adding scalaCrossVersions to the problematic project is here:
https://github.com/quincyjo/braid/blob/044a5edf016d007500ea378b02bc603c332f9591/build.sbt

The workflow failed to check binary compact when running +mimaFindBinaryIssues. I tried adding a crossScalaVersions including only 2.13 and it fixed that but the Scala 3 test workflow fails while compiling the Circe model to Scala 3. After digging around with a bunch of testing I found out that tlIsScala3 is not being set correctly with how the workflow is being generated. Specifically demonstrated below within SBT:

sbt:root> ++ 3
[info] Setting Scala version to 3.3.1 on 6 projects.
[info] Excluded 5 projects, run ++ 3 -v for more details.
[info] Reapplying settings...
[info] set current project to root (in build file:/home/quincyjo/Projects/braid/)
sbt:root> tlIsScala3
[info] operations / tlIsScala3
[info]  true
[info] core / tlIsScala3
[info]  true
[info] play / tlIsScala3
[info]  true
[info] circe / tlIsScala3
[info]  false
[info] json4s / tlIsScala3
[info]  true
[info] tlIsScala3
[info]  false
sbt:root> ++ 3 tlIsScala3
[info] Setting Scala version to 3.3.1 on 6 projects.
[info] Excluded 5 projects, run ++ 3 -v for more details.
[info] Reapplying settings...
[info] set current project to root (in build file:/home/quincyjo/Projects/braid/)
[info] core / tlIsScala3
[info]  true
[info] operations / tlIsScala3
[info]  true
[info] play / tlIsScala3
[info]  true
[info] json4s / tlIsScala3
[info]  true
sbt:root> 

The above shows that when ++ 3 tlIsScala3 is ran that the circe project is being skipped but when tlIsScala3 is ran after switching to Scala 3 with ++ 3 that it is not being skipped.

The Continuous Integration / Test (ubuntu-22.04, 3, temurin@11, rootJVM) workflow is running the following, which fails while trying to compile braid-circe to Scala 3.

sbt 'project rootJVM' '++ 3' test

While running this instead works fine because tlIsScala3 works as I expected and skips the project correctly:

sbt 'project rootJVM' '++ 3 test'

It may also be worth noting that running +test also works fine, and compiles and tests all projects across 2.13 and 3 with correctly skipping braid-circe during Scala 3.

I may be setting this controlled cross-compilation up incorrectly, and I can also probably sidestep this now because circe-core now has Scala 3 artifacts. I tried changing skip properties, dependencies, and explicitly stating scalaCrossVersions for the project, but I could never get both +mimaFindBinaryIssues and sbt 'project rootJVM' '++ 3' test to run successfully. And generating the workflows with just including test within the ++ 3 command would fix this issue, if using tlIsScala3 to skip a project in this way is intended.

PS: Yes I noticed that ScalaTest was being included as a compilation dependency and was fixing that in 0.1.1.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked build.sbt revisions and the generated Continuous Integration / Test workflow, focusing on tlIsScala3 and the commands using ++ 3. Compare sbt 'project rootJVM' '++ 3' test with sbt 'project rootJVM' '++ 3 test', and verify that braid-circe is skipped for Scala 3 while both the test workflow and +mimaFindBinaryIssues succeed.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, scala
Domain
build-system, ci-cd
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.