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

Fix CI pipeline #13

Merged
merged 31 commits into from
Mar 13, 2024
Merged

Fix CI pipeline #13

merged 31 commits into from
Mar 13, 2024

Conversation

zainab-ali
Copy link
Contributor

@zainab-ali zainab-ali commented Mar 8, 2024

This almost fixes the CI pipeline.

  • Updates the scalafmt config.
  • Adds type parameters to make Scala 2.12 happy.
  • Removes unused imports.
  • Adds scalac-compat-annotation and a load of unused annotations.
  • Adds junit as a scaladoc dependency for coreCats.

I'm hesitant to eagerly remove unused parameters as I don't have the context as to why they're there. If you'd like any removed, drop a comment next to them.

The only outstanding issue is doc generation and the RunWith annotation. This is likely a scaladoc / tasty bug and needs a bit more investigation.

@zainab-ali zainab-ali marked this pull request as draft March 8, 2024 15:53
@zainab-ali zainab-ali changed the title Set scala-3 dialect to Scala 3. Fix CI pipeline Mar 8, 2024
@@ -60,7 +59,6 @@ object EffectSuite {

}

@RunWith(classOf[weaver.junit.WeaverRunner])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mmm this annotation has a pretty significant importance (despite the fact that there's no test associated to it): it's what allows IntelliJ to run test suites by clicking on them.

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 thought it was important, but wanted to get to a green build before fixing it.

Our doc generation fails in Scala 3:

sbt:cats-core> doc
[error] -- Error: modules/core/shared/src/main/scala/weaver/suites.scala:63:0 ----------
[error] 63 |@RunWith(classOf[weaver.junit.WeaverRunner])
[error]    |^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]    |undefined: new org.junit.runner.RunWith # -1: TermRef(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class junit)),object runner),RunWith),<init>) at readTasty
[error] one error found

I haven't dug deep into it yet, but it seems like a bug in dottydoc or the tasty reader. Possibly, it can't read the the tasty generated by suites.scala.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's probably because the dependency is tagged as Optional in this module.

We could make the dependency required in the scope of the task that requires it maybe ? Not gonna lie, my SBT skills are not good enough to know how to do that from the top of my head

Copy link
Contributor Author

@zainab-ali zainab-ali Mar 13, 2024

Choose a reason for hiding this comment

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

That seems to be the problem.

  • junit is an Optional dependency of core.
  • coreJVM / doc has the junit jar on the classpath.
  • coreCats depends on core. However coreCatsJVM / doc doesn't have the junit jar.

The classpath rules are the same for Scala 2.13 and 3, but dottydoc uses the tasty reader, which seems to need all jars to be present.

We can resolve this by adding the junit dependency with a ScalaDocTool configuration.

Copy link
Collaborator

Choose a reason for hiding this comment

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

that's great, thank you !

@@ -40,6 +40,6 @@ object Test {

def apply[F[_]](name: String, f: F[Expectations])(
implicit F: EffectCompat[F]
): F[TestOutcome] = apply(name, (_: Log[F]) => f)
): F[TestOutcome] = apply[F](name, (_: Log[F]) => f)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We get the following error in 2.12, resolved by adding these type parameters:

[warn] compiler bug: Unexpected code path: testing two type variables for subtype relation:
[warn]   ?F <:< ?F
[warn] Please report bug at https://github.com/scala/bug/issues

}.collect { case (taskDef, Some(suite)) => (taskDef, suite) }
val tasksAndSuites = (taskDefs.toList.mapFilter { taskDef =>
suiteLoader(taskDef).map(loader => (taskDef, loader))
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The previous code flags up an unreachable case warning in Scala 3, although I'm not sure why:

[warn] 63 |    }.collect { case (taskDef, Some(suite)) => (taskDef, suite) }
[warn]    |                     ^^^^^^^^^^^^^^^^^^^^^^
[warn]    |                     Unreachable case

Copy link
Collaborator

Choose a reason for hiding this comment

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

Til about mapFilter !

suites: Seq[Fingerprinted],
logger: Logger): Resource[F, (WeaverRunner[F], Array[sbt.testing.Task])] = {
suites: Seq[Fingerprinted]
): Resource[F, (WeaverRunner[F], Array[sbt.testing.Task])] = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logger looked safe enough to remove.

@@ -76,7 +76,7 @@ abstract class WeaverFingerprints[F[_]](implicit F: Sync[F]) {
/**
* A fingerprint that searches only for classes extending
* [[weaver.EffectSuite]]. that have a constructor that takes a single
* [[weaver.GlobalResources.Read]] parameter.
* `weaver.GlobalResources.Read` parameter.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

scaladoc can't find this symbol:

[warn] 81 |  object ResourceSharingSuiteFingerprint extends WeaverFingerprint {
[warn]    |         ^
[warn]    |         No DRI found for query: weaver.GlobalResources.Read

Should this be weaver.GlobalRead?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think so, indeed

Copy link
Collaborator

Choose a reason for hiding this comment

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

As far as I'm concerned, this is the last outstanding item for this PR to be merged 🎉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

GlobalRead came from the cats module, so I went for weaver.GlobalResourceF.Read instead.

Copy link
Collaborator

Choose a reason for hiding this comment

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

hah, good call, always mix them for one another

@@ -60,7 +59,6 @@ object EffectSuite {

}

@RunWith(classOf[weaver.junit.WeaverRunner])
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 thought it was important, but wanted to get to a green build before fixing it.

Our doc generation fails in Scala 3:

sbt:cats-core> doc
[error] -- Error: modules/core/shared/src/main/scala/weaver/suites.scala:63:0 ----------
[error] 63 |@RunWith(classOf[weaver.junit.WeaverRunner])
[error]    |^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]    |undefined: new org.junit.runner.RunWith # -1: TermRef(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class junit)),object runner),RunWith),<init>) at readTasty
[error] one error found

I haven't dug deep into it yet, but it seems like a bug in dottydoc or the tasty reader. Possibly, it can't read the the tasty generated by suites.scala.

@zainab-ali zainab-ali marked this pull request as ready for review March 12, 2024 16:48
@@ -132,7 +132,7 @@ object MetaJVM {
}
}

abstract class LazyAccessSequential(global: GlobalRead, index: Int)
abstract class LazyAccessSequential(global: GlobalRead)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This index stopped being used as of this commit to improve the sequential access tests. We can safely get rid of it.

@zainab-ali
Copy link
Contributor Author

We're all green! I'm happy with merging.

@Baccata Baccata merged commit 1e57875 into typelevel:sbt-typelevel Mar 13, 2024
11 checks passed
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