Open zachgrayio opened 2 years ago
A minor update:
The badly behaving targets here turned out to be integration tests which depended on other integration test targets, in an attempt to make use of shared utility code which should have been factored out to common libraries. Interestingly this seemingly worked in Bazel 4 and earlier, but fails in 5 with the colliding actions.
The simple answer here is that the offending project code should be fixed, so maybe this is a non-issue, but that said, I wonder if it makes sense to look into and/or document the change in behavior at all?
@zachgrayio in Bazel 5, --trim_test_configuration
was changed to true, see if setting it to false helps with your issue
@zachgrayio in Bazel 5,
--trim_test_configuration
was changed to true, see if setting it to false helps with your issue
thats gotta be it, yeah. was lookin for something like this in the patch notes but failed at grep i guess :laughing:
If it helped, it probably means that there's bug Rules Scala or Bazel 5
My team actually hit this exact issue as well. Adding that flag allowed us to proceed with further testing on Bazel 5.
So following up here, yes, that flag alone is enough to avoid the issue here in this build.
That said I'm not convinced this is evidence a bug per se; as I said, the root of the issue is that I discovered tests depending on other tests in this project, and this is what's driving the colliding actions. I assume that after bazel 5 flipped this flag, one of the redundant configs is getting trimmed enough that it ends up conflicting rather than being identical, like it was under bazel 4.
The takeaway here for me is that maybe this shouldn't have ever worked in the first place and the behavior now is probably more sensible.
FWIW, fixing this correctly really wasn't that hard, and for others running into this: if you're hitting this issue it's likely you need to take another look at your build graph and fix the root cause.
Is Bazel 5 officially supported? It's not yet mentioned in the compatibility table.
That said I'm not convinced this is evidence a bug per se; as I said, the root of the issue is that I discovered tests depending on other tests in this project
This isn't actually the root cause, after I dug into this a bit. I think the root cause is non-tests depending on test libraries. I.e., if you had some targets like this, it would fail:
scala_library(
name = "mytarget",
deps = [ ":tests" ],
)
scala_test(
name = "tests",
)
https://bazel.build/reference/command-line-reference#flag--trim_test_configuration
When this flag is active, tests cannot be built as dependencies of non-test rules
Seeing some strange behavior when upgrading to Bazel 5 for a mid-sized Scala project I'm looking at.
The first issue we worked through was missing classes, and appeared after moving from bazel 4.2 and bazel 5; we resolved this by adding the missing dependency directly to the failing
scala_library
in question, so it's a trivially easy fix, but I'm not sure exactly why the behavior changed just in bumping the bazel version :thinking: but I'm a little rusty on how the dependency mode options in the scala toolchain interact with Bazel, could be there were changes there I guess?Second issue that I find even more perplexing (redacted with
foo
, this is a real project)::point_up: dozens of these kinds of things. Diffing the respective configs, they're identical other than the following which is present in only one of the configs, and maybe the culprit:
I'm not sure exactly what to make of it thus far :thinking: