Skip to content

Prototype Bazel-native FOSS tests#209

Open
nettle wants to merge 3 commits intoEricsson:mainfrom
nettle:bazel-foss
Open

Prototype Bazel-native FOSS tests#209
nettle wants to merge 3 commits intoEricsson:mainfrom
nettle:bazel-foss

Conversation

@nettle
Copy link
Copy Markdown
Collaborator

@nettle nettle commented Mar 28, 2026

Why:
The existing Python/Bash FOSS tests are hard to
understand and extend, they are also very slow
and cannot be integrated into Bazel environment.

What:
Add test/bazel/ with a foss_test() macro
that generates py_test() targets for FOSS projects.

Test:
bazel test //test/bazel/...

@nettle nettle requested review from Szelethus and furtib March 28, 2026 20:20
@nettle
Copy link
Copy Markdown
Collaborator Author

nettle commented Mar 28, 2026

Hi @furtib and @Szelethus,
I had a few minutes to demo Bazel approach for tests,
so please take a look - this is just very simple idea for FOSS tests.

Copy link
Copy Markdown
Contributor

@furtib furtib left a comment

Choose a reason for hiding this comment

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

I like the idea, haven't thought of it in this way.
But why do it in a separate folder?
(minor note, due to how the CI is set up, it doesn't actually run these tests)
It also does not work on the Bazel 6 version, since we don't use the WORKSPACE file at all.

Just now I realized, tests is only used to disable the per-file test in yaml-cpp?

Let me show what I'm thinking of. (tomorrow...)

test/bazel/BUILD Outdated

foss_test(
name = "yaml-cpp",
url = "https://github.com/jbeder/yaml-cpp/archive/refs/tags/0.8.0.tar.gz",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would prefer git hashes; they give us more options, and are more precise.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Please dont prefer git hashes :)
Tags and releases are prices and also give timeline coordination plus certain level of responsibility.
While git hashes might be used as the last resort.
We will talk about it ;)


# Resolve rules_codechecker path from the real script location
script_path = Path(os.path.realpath(__file__))
self.rules_path = script_path.parent.parent.parent
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is more readable like this.

Suggested change
self.rules_path = script_path.parent.parent.parent
self.rules_path = script_path.parents[2]

["chmod", "-R", "u+w", str(self.work_dir)],
capture_output=True,
)
shutil.rmtree(self.work_dir, ignore_errors=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we don't need this; Bazel will remove the sandbox at the end of the run.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Well, this probably should be done different way...
But what do you mean by "Bazel will remove the sandbox at the end of the run"?
Do you mean bazel clean?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No, I may have said it wrong.
I meant that Bazel will run it in a clean state each time.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My bad, I thought this was teardownClass.

Comment on lines +116 to +120
(self.project_dir / "MODULE.bazel").write_text(
MODULE_TEMPLATE.format(rules_path=self.rules_path)
)
(self.project_dir / "WORKSPACE").touch()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We want to test Bazel 6 without the bzlmod system too!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Right, Bazel 6 is not supported in this proto yet

Comment on lines +46 to +48
# FIXME: output 'analysis/codechecker_per_file/data/src-emit.cpp_clangsa.plist' was not created
# ":codechecker_per_file",
],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems to only happen in mise.
This does not happen in any CI or when simply running it locally.
I do not agree with disabling this for the sake of mise passing.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This sounds like a big bug to fix! In the test or in mise.
We MUST NOT accept "works for me" excuses.

Copy link
Copy Markdown
Contributor

@Szelethus Szelethus Apr 9, 2026

Choose a reason for hiding this comment

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

I disagree. That is likely a bug in mise that is irreproducible locally or in CI. I think its unreasonable to support it like this. We landed mise (#132 (review)) and micromamba (#167 (review)) on the condition that we will see how they can assist testing, but will not unconditionally fix or hack around related breakages until they are proven to be reliable.

Copy link
Copy Markdown
Contributor

@Szelethus Szelethus left a comment

Choose a reason for hiding this comment

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

I like the approach! Would it be okay if, while preserving the main idea, we polished the PR up?

@nettle
Copy link
Copy Markdown
Collaborator Author

nettle commented Mar 30, 2026

The approach is actually questionable - run bazel from bazel.
So we should consider it very carefully.

Anyway, I have 2 conclusions in mind:

  1. We should develop bazel tests instead of python tests
  2. Even running bazel from bazel is better than bazel from python

nettle added 2 commits April 7, 2026 16:32
Why:
The existing Python/Bash FOSS tests are hard to
understand and extend, they are also very slow
and cannot be integrated into Bazel environment.

What:
Add test/bazel/ with a foss_test() macro
that generates sh_test() targets for FOSS projects.

Test:
bazel test //test/bazel/...
@Szelethus
Copy link
Copy Markdown
Contributor

Szelethus commented Apr 9, 2026

Sure! Lets think of a solution that is actionable and can be implemented incrementally. I don't mean this to come off the wrong way, but our bazel 8 support project showed how striving for perfection was the enemy of progress.

Our foss tests so far have borne some fruit, even if they are imperfect.

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