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

Adjust .gitignore to work better with pantsbuild #5726

Merged
merged 3 commits into from
Sep 11, 2022
Merged

Conversation

cognifloyd
Copy link
Member

@cognifloyd cognifloyd commented Sep 9, 2022

Background

This is another part of introducing pants, as discussed in the TSC Meetings on 12 July 2022, 02 Aug 2022 and 06 Sept 2022. Pants has fine-grained per-file caching of results for lint, fmt (like black), test, etc. It also has lockfiles that work well for monorepos that have multiple python packages. With these lockfiles CI should not break when any of our dependencies or our transitive dependencies release new versions, because CI will continue to use the locked version until we explicitly relock with updates.

To keep PRs as manageable/reviewable as possible, introducing pants will take a series of PRs. I do not know yet how many PRs; I will break this up into logical steps with these goals:

  • introduce pants to the st2 repo, and
  • teach some (but not all) TSC members about pants step-by-step.

Other pants PRs include:

Overview of this PR

This PR makes two adjustments to our .gitignore file.

  1. Remove build from .gitignore
  2. Add more vim temp file patterns

pants requires BUILD files to describe metadata about our code (this directory has python and it has these dependencies that can't be inferred from the imports, etc). .gitignore is not case sensitive, so build prevents adding BUILD files. This is required to use pants.

For more about BUILD files, see: https://www.pantsbuild.org/docs/targets#build-files

The vim temp file patterns is not required for pants but it makes it nicer to work with it. If files change while pants is running a process, it can pause and re-run. When I use vi to look at a file while pants is running tests, or formatters, or whatever, then the tmp files keep triggering an inspection of the filesystem (pants needs to make sure it is including all required files in the given operation). But, pants ignores all files in .gitignore, so, adding the vim temp files there prevents pants from getting false-positive filesystem changes. We might end up adding other temp files for people that use other editors to make their experience with pants nicer as well.

For more about BUILD files, see:
https://www.pantsbuild.org/docs/targets#build-files

Benjy Weinberger, one of the pants maintainers, pointed out why git
was ignoring the BUILD files.
@cognifloyd cognifloyd added this to the 3.8.0 milestone Sep 9, 2022
@cognifloyd cognifloyd requested review from nzlosh, rush-skills, amanda11 and a team September 9, 2022 23:18
@cognifloyd cognifloyd self-assigned this Sep 9, 2022
@pull-request-size pull-request-size bot added the size/XS PR that changes 0-9 lines. Quick fix/merge. label Sep 9, 2022
@cognifloyd cognifloyd requested a review from a team September 11, 2022 00:23
@@ -10,7 +10,6 @@
*.egg
*.egg-info
dist
build

Choose a reason for hiding this comment

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

FYI you can name the files BUILD.pants! Many people prefer that for clarity. It allows you to avoid making this change also.

Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting thought.
We don't have anything that creates build files or directories, so keeping it in .gitignore is kind of pointless.

But if we did change from BUILD to BUILD.pants, we would need this config in pants.toml:

[tailor]
build_file_name = "BUILD.pants"

https://www.pantsbuild.org/docs/reference-tailor#build_file_name

I thought we would also need to adjust [GLOBAL].build_patterns, but the default is ["BUILD", "BUILD.*"], so pants already recognizes BUILD.pants:
https://www.pantsbuild.org/docs/reference-global#build_patterns

I've done everything with BUILD files in my PoC. It'll be less work for me to keep using BUILD because that's less I have to change when I cherry-pick commits. If people would prefer BUILD.pants then that is possible.

Copy link
Contributor

@amanda11 amanda11 left a comment

Choose a reason for hiding this comment

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

Lgtm

@cognifloyd cognifloyd modified the milestones: 3.8.0, pants Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance pantsbuild size/XS PR that changes 0-9 lines. Quick fix/merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants