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

Add Tiltfile + Starlark support #494

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

dbast
Copy link

@dbast dbast commented Dec 16, 2024

Add Tiltfile + Starlark support. Tiltfiles are written in Starlark, which is a language intended for use as a configuration language. It was originally designed for the Bazel build system. Starlark is a dialect of Python.

background: Lots of Python targeting pre-commit hooks (like ruff) can also be applied to Starlark files. This PR enables to apply those hooks via specifying types_or: [starlark] or types_or: [tiltfile] or types_or: [bazel] depending on what is needed. Not every Python pre-commit hook applies to every Starlark file, as there are different variants with some language features enabled or disabled.

refs:

@asottile
Copy link
Member

so there is an odd precedent set in #413 that treats all starlark as "bazel" -- I don't think that's quite correct but then this should get resolved somehow so this PR isn't inconsistent

we can't remove bazel from that extension so maybe the best is to just add it?

@dbast
Copy link
Author

dbast commented Dec 17, 2024

@asottile rebased the PR and also now explicitly setting 'copy.bara.sky': {'text', 'bazel', 'starlark'} (it implicitly already was like that before as it referenced blz which also is {'text', 'bazel', 'starlark'}). So it remains backward compatible, but downstream users can now also use starlark (instead of bazel), if they want to apply to all starlark files.

@dbast
Copy link
Author

dbast commented Dec 23, 2024

Looking at the files regex in https://github.com/keith/pre-commit-buildifier/blob/main/.pre-commit-hooks.yaml tell that there are maybe more files/extension that can be added to be identified as Starlark to simplify such kind of hooks or to use existing python hooks to also apply to starlark files. This PR focuses on adding Tiltfile detection and marking the existing definitions that are starlark to be also be detected as such. Further detections and improvements can be done via further PRs.

@asottile anything else to do here as part of this PR? thanks!

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

Successfully merging this pull request may close these issues.

2 participants