Skip to content

Fix lint source discovery without git#10357

Open
naveenvenk17 wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
naveenvenk17:fix-bazel-lint-without-git
Open

Fix lint source discovery without git#10357
naveenvenk17 wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
naveenvenk17:fix-bazel-lint-without-git

Conversation

@naveenvenk17
Copy link
Copy Markdown
Contributor

Fixes #10311.

This removes the git ls-files dependency from the Bazel lint/format scripts by adding a shared bazel/list_sources.sh helper that uses find instead. The helper keeps the old behavior of skipping OpenROAD's upstream-owned submodule directories explicitly (src/sta, third-party/abc) and also skips VCS/build output directories.

The Tcl and Bazel lint/format entrypoints now use the helper from Bazel runfiles, and fix_lint.sh skips its final workspace status report when git is unavailable.

Verification performed in a clean WSL-native checkout:

  • diff -u <(git ls-files '*.tcl' '*.sdc' '*.upf' | sort) <(./bazel/list_sources.sh '*.tcl' '*.sdc' '*.upf' | sort)
  • diff -u <(git ls-files '*.bazel' '*.bzl' '**/BUILD' 'BUILD' '**/WORKSPACE' 'WORKSPACE' | sort) <(./bazel/list_sources.sh '*.bazel' '*.bzl' '**/BUILD' 'BUILD' '**/WORKSPACE' 'WORKSPACE' | sort)
  • ! ./bazel/list_sources.sh '*' | grep -E '^(src/sta|third-party/abc)/'
  • npx --yes @bazel/bazelisk@latest test -c opt --test_output=errors //:fmt_bzl_test //:fmt_tcl_test //:lint_bzl_test //:lint_tcl_test
  • Same Bazel test command again with a fake broken git first in PATH, using --nocache_test_results --action_env=PATH

@github-actions github-actions Bot added the size/M label May 8, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Welcome to OpenROAD! Thanks for opening your first PR.
Before we review:

Please ensure:

  • CI passes
  • Code is properly formatted
  • Tests are included where applicable
    A maintainer will review shortly!

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request replaces the dependency on git ls-files for identifying source files in linting and formatting scripts with a custom list_sources.sh script. This allows these tools to function in environments where Git is unavailable. Feedback was provided to refine the find command's pruning logic in the new script to ensure it only targets directories and symlinks, preventing the accidental exclusion of files that might match the naming patterns.

Comment thread bazel/list_sources.sh Outdated
Signed-off-by: naveenvenk17 <naveenvenkat1711@gmail.com>
@maliberty
Copy link
Copy Markdown
Member

@codex review

@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 68e099d98f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bazel/list_sources.sh Outdated
Comment on lines +42 to +53
find . \
\( \( -type d -o -type l \) \
\( \
-path "./.git" -o \
-path "./src/sta" -o \
-path "./third-party/abc" -o \
-path "./bazel-*" -o \
-path "./build" -o \
-path "./build-*" \
\) \
\) -prune -o \
\( -type f -o -type l \) \( "${patterns[@]}" \) -print0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep lint source discovery limited to tracked files

The new find-based discovery now returns any matching filesystem entry, not just repository-tracked files like the previous git ls-files calls. In local workflows (//:lint_*, //:fmt_*, //:fix_lint), this causes untracked or ignored scratch/generated files (for example, temporary *.tcl files outside build*/bazel-*) to be linted/formatted and potentially fail the target, which is a behavior regression from the prior scripts. The helper should preserve tracked-file semantics when possible (or explicitly filter ignored/untracked files) to avoid false failures unrelated to committed sources.

Useful? React with 👍 / 👎.

@maliberty
Copy link
Copy Markdown
Member

I tried this on a local sandbox and it gave loads of errors on tmp/... which is a directory that is .gitignore'd but not excluded in the find command. This approach is rather brittle. I still prefer using git ls-files and just depending on git as I indicated in #10311

Signed-off-by: naveenvenk17 <naveenvenkat1711@gmail.com>
@github-actions github-actions Bot added size/S and removed size/M labels May 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@maliberty
Copy link
Copy Markdown
Member

@hzeller do you prefer we use bazel_dep(name = "git", version = "2.54.0") to the local git?

@oharboe
Copy link
Copy Markdown
Collaborator

oharboe commented May 14, 2026

@hzeller How about this, add a command line option to inject the list of files if git is not available.

bazelisk run //:foo commands can output an error message with add --git-files $(git xxxx) if git is not installed; the user can then outside of their nix environment get the list of files and pass it in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Formatting tests error out because they don't find git

3 participants