Skip to content

feat(lang): add Starlark review support - #1021

Open
Qiyuanqiii wants to merge 6 commits into
alibaba:mainfrom
Qiyuanqiii:feat/starlark-support
Open

feat(lang): add Starlark review support#1021
Qiyuanqiii wants to merge 6 commits into
alibaba:mainfrom
Qiyuanqiii:feat/starlark-support

Conversation

@Qiyuanqiii

@Qiyuanqiii Qiyuanqiii commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Description

Summary

  • Add .bzl, .bazel, and .star to OCR's supported file types.
  • Route those extensions, plus extensionless BUILD and WORKSPACE files, to a dedicated built-in Starlark review rule.
  • Keep BUILD and WORKSPACE discoverable through the file_find tool while preserving the existing filtering of unknown extensionless files.
  • Add regression coverage across allowlist filtering, scan and preview selection, rule resolution, and file discovery.
  • Document the new rule mapping and extensionless-file behavior in the English, Chinese, Japanese, and Russian documentation.

Motivation and Scope

Issue #1014 requests review support for Starlark, including the files commonly used by Bazel. OCR previously did not allow .bzl, .bazel, or .star files through its extension filter. Extensionless Bazel build files could reach the review pipeline, but they had no Starlark-specific system rule, and file_find omitted them when the review agent searched the repository.

This PR adds consistent support across file selection, rule resolution, repository discovery, tests, and documentation. It does not execute Starlark, invoke Bazel, or run Buildifier; the new Markdown rule supplies language-specific guidance to the existing review agent.

Contributor Attribution

  • @wu21-web authored and later expanded the Starlark-specific review instructions in starlark.md, based on the official Bazel and Starlark documentation.
  • @Qiyuanqiii implemented file detection, scan and preview support, rule routing, extensionless BUILD/WORKSPACE discovery, tests, localized documentation, integration, Windows verification, and technical review of the follow-up documentation.
  • The documentation expansion was contributed through Qiyuanqiii/open-code-review#1. Commit dc6d2ca records both contributors through its Co-authored-by trailer; follow-up commit cf180762 was authored by @wu21-web and co-authored by @Qiyuanqiii.

Implementation

  • Extend the embedded file-type allowlist with .bzl, .bazel, and .star.
  • Add starlark.md and map **/{BUILD,WORKSPACE,.bzl,.bazel,*.star} to it.
  • Permit BUILD and WORKSPACE in the file discovery tool's extensionless-file exceptions.
  • Cover lowercase and uppercase extensions, all five requested path forms, scan and preview admission, and repository-backed file discovery.
  • Synchronize the rule-routing and tool documentation across all four maintained documentation locales.

Compatibility and User Impact

  • The change is additive and does not alter handling for existing supported languages.
  • Other unknown extensionless files remain excluded from file_find.
  • Existing custom, project, and global rule precedence remains unchanged.
  • No provider configuration or public CLI syntax changes are required.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

Validation Environment

  • OS: Windows 25H2, build 26200.9168, amd64
  • Go: go1.26.5 windows/amd64
  • Baseline: 699c91444ae1b485d7c6553e7858e1e1b95a2c6a

Automated Validation

  • Project make check target through mingw32-make: license headers, English-only source check, go mod tidy, formatting, and go vet
  • Project make test target through mingw32-make: complete Go test suite with the race detector
  • Project make coverage target through mingw32-make: 90.9% total statement coverage, above the required 90%
  • git diff --check
  • LF-only verification for every changed file

Manual and CLI Validation

A freshly built Windows executable resolved the built-in Starlark rule for every requested path form:

  • rules/library.bzl
  • config.star
  • MODULE.bazel
  • pkg/BUILD
  • WORKSPACE

Each path matched **/{BUILD,WORKSPACE,.bzl,.bazel,*.star} and loaded the Starlark rule. A workspace preview also selected all five supported forms while continuing to exclude an unknown extension.

The repository-requested self-review completed successfully:

[ocr] Summary: 3 file(s) reviewed, 0 comment(s)
Review complete: 0 finding(s) across 3 selected item(s).

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove the feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly
  • I have signed the CLA

Known Limitations

  • Local validation was performed on Windows/amd64; remote CI remains responsible for the repository's other supported environments.
  • This PR adds review instructions and file-routing support; it does not add a Starlark parser or execute Buildifier.

Related Issues

Closes #1014.

Co-authored-by: wu21-web <wu2196674@icloud.com>
@github-actions

Copy link
Copy Markdown
Contributor

OpenCodeReview: Review complete: 0 finding(s) across 3 selected item(s).

@Qiyuanqiii
Qiyuanqiii marked this pull request as ready for review August 20, 2026 09:48
@Qiyuanqiii

Copy link
Copy Markdown
Contributor Author

@wu21-web Thank you for drafting the Starlark-specific review instructions. I’ve integrated them into this draft PR and added you as a co-author using the email you provided. Could you please review the instructions and confirm that the integration accurately reflects your contribution?

@wu21-web

Copy link
Copy Markdown
Contributor

Sure, I will review soon.

wu21-web and others added 2 commits August 20, 2026 23:45
Co-authored-by: Qiyuanqiii <qiiiqiyuan@gmail.com>
chore: update documentation
Comment thread internal/config/rules/system_rules_test.go Outdated
Co-authored-by: Tao Xin <wu2196674@icloud.com>

@wu21-web wu21-web left a comment

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.

LGTM

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.

feat(lang): review support for Starlark

2 participants