Skip to content

Too hard to set up buildifier for a project #170

@alexeagle

Description

@alexeagle

Angular development now requires a buildifier check: https://github.com/angular/angular/blob/ef534c0cc16b4fd3a4c721f814e5530d63cd6642/.circleci/config.yml#L31
Here are notes from setting this up and the problems we are running into
/cc @mhevery

This doesn't work well for a few reasons:

  • developers need to install buildifier on their machines, but it needs to match the version of buildifier run on the CI
  • when a change is not formatted, it's hard to both fail the CI, and indicate what changes buildifier expects because --mode=diff exits 0 even if there's a delta, and it doesn't repeat file names
  • windows developers don't have the find command indicated here
  • developers shouldn't need to think about running buildifier

Here's how I'd like it to work:

  • In WORKSPACE add a git_repository pointing here. The tag or commit ensures all developers and CI get the same buildifier version.
  • Now I can bazel run @com_github_bazelbuild_buildtools//buildifier but it uses the runfiles directory, it should cd back to the workspace root
  • I'd like to have a shorter command for developers, it should be possible to add a simple build rule in my project so I can just bazel run :buildifier (similar to how Gazelle is setup)
  • The buildifier rule could also have an implicit output so we could bazel run :buildifier.check on CI
  • --mode=diff should exit non-zero if there's a delta, workaround is to run diff followed by check
  • --mode=diff needs to echo filenames, otherwise you just get anonymous patches like https://circleci.com/gh/angular/angular/26772
  • We should document this setup, along with a git pre-commit hook so all changes to BUILD files get fixed without any effort

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions