Skip to content

Comments

Add Buildifier Github Action#139

Draft
danielibarrola wants to merge 1 commit intogoogle-ml-infra:mainfrom
danielibarrola:ci_buildifier
Draft

Add Buildifier Github Action#139
danielibarrola wants to merge 1 commit intogoogle-ml-infra:mainfrom
danielibarrola:ci_buildifier

Conversation

@danielibarrola
Copy link

@danielibarrola danielibarrola commented Feb 17, 2026

This pull request introduces a new GitHub Action and supporting infrastructure to automate Bazel formatting checks using buildifier. It ensures that all Starlark files (BUILD, WORKSPACE, MODULE.bazel, .bzl) adhere to standard formatting guidelines.

Changes

1. Buildifier Composite Action (ci_buildifier/)

  • Created a new composite action in ci_buildifier/action.yaml that:
    • Automatically detects changed Bazel files in a PR or Push using git diff.
    • Runs buildifier --mode=check on identified files.
    • Supports an optional filepaths input for manual overrides.
  • Added a README.md in the action directory with usage instructions and prerequisites.

2. GitHub Workflows

  • Buildifier Check (.github/workflows/buildifier-check.yml): A standard workflow that runs the check on the main branch and pull requests.
  • Buildifier Check On Error (.github/workflows/buildifier-check-on-error.yml): A specialized test workflow designed to verify that the action correctly fails when it encounters unformatted code.

3. Test Suite (tests/ci_buildifier/)

  • Added a set of test files to validate action behavior:
    • formatted/: Contains a correctly formatted BUILD file.
    • unformatted/: Contains intentionally misformatted BUILD, WORKSPACE, MODULE.bazel, and .bzl files to test the "check" mode's failure detection.

How to use

You can integrate this check into your workflows by adding the following step:

- name: Run Buildifier Check
  uses: ./ci_buildifier/

Verification Results

  • The buildifier-check workflow successfully passes when pointing at the formatted/ directory.
  • The buildifier-check-on-error workflow successfully catches errors in the unformatted/ directory and confirms the expected failure outcome.

@danielibarrola danielibarrola force-pushed the ci_buildifier branch 2 times, most recently from 97ab39f to 7d317a6 Compare February 18, 2026 17:26
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.

1 participant