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

Lots of Builds in the community-build are silently skipping tests and even test-compiles #14391

Closed
deusaquilus opened this issue Jan 31, 2022 · 16 comments · Fixed by #14395
Closed

Comments

@deusaquilus
Copy link
Contributor

It looks like lots of Builds not running or even compiling their tests. When they get to testing this happens:

2022-01-30T08:16:22.4896099Z [error] Error loading test framework (java.lang.NoClassDefFoundError: sbt/testing/Framework). This usually means that you are using a layered class loader that cannot reach the sbt.testing.Framework class. The most likely cause is that your project has a runtime dependency on your test framework, e.g. scalatest. To fix this, you can try to set
2022-01-30T08:16:22.4899342Z [error] Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.ScalaLibrary
2022-01-30T08:16:22.4900029Z [error] or
2022-01-30T08:16:22.4900718Z [error] Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat
2022-01-30T08:16:22.5477827Z [success] Total time: 23 s, completed Jan 30, 2022 9:16:22 AM

As similar issues happens for some builds trying to use ZTestFramework:

2022-01-30T08:21:26.8954542Z [error] Error loading test framework (scala.MatchError: zio.test.sbt.ZTestFramework@31fd0360 (of class zio.test.sbt.ZTestFramework)). This usually means that you are using a layered class loader that cannot reach the sbt.testing.Framework class. The most likely cause is that your project has a runtime dependency on your test framework, e.g. scalatest. To fix this, you can try to set

When this error occurs in a project, none of the tests will be run or even compiled. It is effectively a total disabling of testing code for the given project.

I first saw these in the my quill PR builds:
Screenshot from 2022-01-31 11-48-26

Some quick grepping (attached) shows me this is happening for the following projects:

in community-build-a

  • scalatest
  • scala-stm
  • scalatestplus-testng
  • izumi-reflect
  • Lucre

in community-build-c

  • protoquill (I got this one...)
  • akka
  • jackson-module-scala
  • libretto
  • xml-interpolator
  • scalatestplus-scalacheck
  • scala-parallel-collections
  • sconfig
  • onnx-scala

I solved this problem by adding something slightly different to my settings:

Compile / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat

When I added this, the error went away.

This could all be totally wrong and my grepping could be incorrect too but I've tried this with the quill build. I tried running the community build with and actual compile error in my scalatests and without the classLoaderLayeringStrategy parameter. The build passes as though nothing is wrong.

I think that project owners should maybe have a look at their builds and see if this is happening for them.

grepping_results.txt

@deusaquilus deusaquilus added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 31, 2022
@smarter smarter added area:infrastructure prio:blocker and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 31, 2022
@smarter
Copy link
Member

smarter commented Jan 31, 2022

Huh, it's weird that sbt logs an error but doesn't fail the task. If ClassLoaderLayeringStrategy.Flat fixes it then I guess we should do this by default but I wonder when this issue started. Does this ring any bell @griggt ?

@smarter smarter modified the milestones: 3.1.1, 3.2.0 Jan 31, 2022
@ekrich
Copy link
Contributor

ekrich commented Jan 31, 2022

I know for sconfig that the pulled version is a bit old causing errors with the newer sbt. Not sure how that gets updated.

@griggt
Copy link
Contributor

griggt commented Jan 31, 2022

I noticed it this weekend but ran out of time to investigate. It's on my todo list for tonight.

Thanks for opening the ticket @deusaquilus

It's a bit concerning that sbt seems to return a success exit code despite the error.

@griggt griggt self-assigned this Jan 31, 2022
@pshirshov
Copy link
Contributor

pshirshov commented Jan 31, 2022

Well, I'm not sure what is this about, though in case you need us to make any changes in izumi-reflect we are happy to help. I believe just adding that setting would be enough?

@griggt
Copy link
Contributor

griggt commented Jan 31, 2022

This issue first started with the upgrade to sbt 1.6.1 in #14202

https://github.com/lampepfl/dotty/actions/runs/1657330713

The preceding CI run on master was clean

https://github.com/lampepfl/dotty/actions/runs/1656594683

@ekrich
Copy link
Contributor

ekrich commented Jan 31, 2022

Older versions used withDottyCompat so maybe updating to new versions. I tried this locally.
git submodule update --remote Don't know if that is correct but it did update a bunch of projects.

@deusaquilus
Copy link
Contributor Author

@pshirshov izumi-reflect community-build appears to not be running or even compiling tests. It has the following error:

[error] Error loading test framework (java.lang.NoClassDefFoundError: sbt/testing/Framework). This usually means that you are using a layered class loader that cannot reach the sbt.testing.Framework class. The most likely cause is that your project has a runtime dependency on your test framework, e.g. scalatest. To fix this, you can try to set
[error] Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.ScalaLibrary
[error] or
[error] Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat
[error] Error loading test framework (java.lang.NoClassDefFoundError: sbt/testing/Framework). This usually means that you are using a layered class loader that cannot reach the sbt.testing.Framework class. The most likely cause is that your project has a runtime dependency on your test framework, e.g. scalatest. To fix this, you can try to set
[error] Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.ScalaLibrary
[error] or
[error] Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat

You can see it here:
https://github.com/lampepfl/dotty/runs/5001357175?check_suite_focus=true#step:8:3950

There are a couple ways to fix this. I fixed it by adding the following setting to SBT build.

Compile / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat

@smarter
Copy link
Member

smarter commented Jan 31, 2022

This issue first started with the upgrade to sbt 1.6.1 in #14202

Thanks, I assume something in 1.6.0 is the culprit here but it's not clear what (sbt/sbt#6480 is the only related PR I could find). @eed3si9n: does sbt publish nightly builds these days?

@smarter
Copy link
Member

smarter commented Jan 31, 2022

The fact that our community build apparently still injects the obsolete sbt-dotty plugin might be related since sbt/sbt#6480 removed support for sbt-dotty: https://github.com/lampepfl/dotty/blob/1776d812cfaec31813d5e0865ebdb8654aaf3de0/project/Build.scala#L1591

@griggt
Copy link
Contributor

griggt commented Jan 31, 2022

our community build apparently still injects the obsolete sbt-dotty plugin

Any objection to discontinuing this practice and manually fixing up in the dotty-staging forks any projects that have not updated upstream?

@deusaquilus
Copy link
Contributor Author

@griggt @smarter So I still use dottyLatestNightlyBuild().get from sbt-dotty to get latest nightly version so that I can compile with it locally. Has this functionality been reproduced by something in SBT proper?

@smarter
Copy link
Member

smarter commented Jan 31, 2022

@griggt That'd be awesome, go for it!
@deusaquilus Nothing built in, you'd have to copy the code in your own build: https://github.com/lampepfl/dotty/blob/2f407470d2fca0f57b46bfde37acf6d79915f1f4/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala#L30-L83

@deusaquilus
Copy link
Contributor Author

@smarter Works for me. Thanks!

@griggt
Copy link
Contributor

griggt commented Jan 31, 2022

Some local testing shows the issue also manifests with sbt 1.6.0 but not 1.5.8 (we jumped from 1.5.7 to 1.6.1 in #14202)

It also appears that not injecting sbt-dotty when using sbt 1.6.x fixes things (at least for shapeless)

Will have more time later tonight to investigate further and PR a fix. It still seems to me that sbt should return a non-zero exit code if the tests aren't being run.

@eed3si9n
Copy link
Member

does sbt publish nightly builds these days?

Sorry I haven't gotten around to resurrecting nightlies.

I wonder if this is a side effect of no longer trapping the exit code or waiting on all threads in tests. If so forking might fix it, but it's somewhat controversial - sbt/sbt#6413

@eed3si9n
Copy link
Member

I have a PR up so it won't silently succeed the build - sbt/sbt#6806

griggt added a commit to griggt/dotty that referenced this issue Mar 1, 2022
The sbt-dotty plugin was deprecated with the release of sbt 1.5.0,
and removed from the dotty build in b477c42

However it was still being injected into the community build, as many
projects therein had not been updated to a recent sbt, or were using a
(possibly outdated) version of sbt-dotty either directly or indirectly
via some other plugin.

This commit discontinues that practice, since sbt 1.6.x no longer plays
nice with sbt-dotty (see the linked ticket scala#14391).

Many of the community build projects are already updated upstream to
use sbt 1.5.x or 1.6.x without sbt-dotty; those are updated to their
upstream versions in this PR as appropriate.

A handful of community build projects are either unmaintained or do not
offer Scala 3 support upstream, or their inclusion in the community build
was part of some special effort. Those projects, listed below, have had
their dotty-staging forks updated to use sbt 1.6.2 and drop sbt-dotty.

  - betterfiles
  - effpi
  - fastparse
  - intent
  - scalap
griggt added a commit to griggt/dotty that referenced this issue Mar 1, 2022
The sbt-dotty plugin was deprecated with the release of sbt 1.5.0,
and removed from the dotty build in b477c42

However it was still being injected into the community build, as many
projects therein had not been updated to a recent sbt, or were using a
(possibly outdated) version of sbt-dotty either directly or indirectly
via some other plugin.

This commit discontinues that practice, since sbt 1.6.x no longer plays
nice with sbt-dotty (see the linked ticket scala#14391).

Many of the community build projects are already updated upstream to
use sbt 1.5.x or 1.6.x without sbt-dotty; those are updated to their
upstream versions in this PR as appropriate.

A handful of community build projects are either unmaintained or do not
offer Scala 3 support upstream, or their inclusion in the community build
was part of some special effort. Those projects, listed below, have had
their dotty-staging forks updated to use sbt 1.6.2 and drop sbt-dotty.

  - betterfiles
  - effpi
  - fastparse
  - intent
  - scalap
griggt added a commit to griggt/dotty that referenced this issue Mar 3, 2022
The sbt-dotty plugin was deprecated with the release of sbt 1.5.0,
and removed from the dotty build in b477c42

However it was still being injected into the community build, as many
projects therein had not been updated to a recent sbt, or were using a
(possibly outdated) version of sbt-dotty either directly or indirectly
via some other plugin.

This commit discontinues that practice, since sbt 1.6.x no longer plays
nice with sbt-dotty (see the linked ticket scala#14391).

Many of the community build projects are already updated upstream to
use sbt 1.5.x or 1.6.x without sbt-dotty; those are updated to their
upstream versions in this PR as appropriate.

A handful of community build projects are either unmaintained or do not
offer Scala 3 support upstream, or their inclusion in the community build
was part of some special effort. Those projects, listed below, have had
their dotty-staging forks updated to use sbt 1.6.2 and drop sbt-dotty.

  - betterfiles
  - effpi
  - fastparse
  - intent
  - scalap
@griggt griggt modified the milestones: 3.2.0-RC1, 3.1.3-RC1 Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants