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

Allow buildifier_test to escape the sandbox #1092

Merged
merged 1 commit into from
Nov 10, 2022

Conversation

milesdai
Copy link
Contributor

This PR addresses #1075 by adding a no_sandbox attribute and a WORKSPACE path attribute tobuildifier_test. Currently, users must explicitly specify every BUILD file they would like to lint in the srcs attribute of buildifier_test. This PR allows the user to create a test to lint all BUILD files as follows:

buildifier_test(
    name = "buildifier_check",
    diff_command = "diff -u",
    mode = "diff",
    no_sandbox = True,
    workspace = "//:WORKSPACE",
)

@cfrantz
Copy link

cfrantz commented Oct 10, 2022

We (opentitan-team) are curious if structuring global "whole project" tests like this is bad and if there is a better way for the test to find the root subdir of the project (tests don't have BUILD_WORKSPACE_DIRECTORY, so we're using $(dirname $(realpath $WORKSPACE_FILE))).

Copy link

@sfc-gh-ebrossard sfc-gh-ebrossard left a comment

Choose a reason for hiding this comment

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

I would love to see this merged as well :)

buildifier/runner.bash.template Outdated Show resolved Hide resolved
buildifier/internal/factory.bzl Outdated Show resolved Hide resolved
buildifier/buildifier.bzl Outdated Show resolved Hide resolved
This allows buildifier_test to access the entire workspace to avoid
needing to explicitly specify which files should be linted.
@vladmos vladmos merged commit 762712d into bazelbuild:master Nov 10, 2022
@milesdai milesdai deleted the sandbox-escape branch November 10, 2022 18:52
keith pushed a commit to keith/buildifier-prebuilt that referenced this pull request Mar 30, 2023
Port of bazelbuild/buildtools#1092

(Don't love the ergonomics of these rules, but we've already invested in
them I guess)
apattidb pushed a commit to databricks/buildtools that referenced this pull request May 10, 2024
This allows buildifier_test to access the entire workspace to avoid
needing to explicitly specify which files should be linted.
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.

None yet

4 participants