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 pants-plugins/pack_metadata to inform pants about our packs #5868

Merged
merged 23 commits into from
Jan 23, 2023

Conversation

cognifloyd
Copy link
Member

Background

This is another part of introducing pants, as discussed in various TSC meetings.

Related PRs can be found in:

Overview of this PR

This PR makes it possible to inform pants about all of our pack metadata files by adding a new pack_metadata target. The pack_metadata target encompasses the following files:

default = (
# metadata does not include any python, shell, or other sources.
"pack.yaml",
"config.schema.yaml",
"*.yaml.example",
"**/*.yaml",
"**/*.yml",
"icon.png", # used in st2web ui
# "requirements*.txt", # including this causes target conflicts
# "README.md",
# "HISTORY.md",
)

Python, shell, and requirements files all need to be handled separately so that pants can lint/fmt them appropriately. Pants does not have a markdown plugin yet, so I put them in the list as a reminder that they will need to be dealt with, but I commented them out.

One of our packs is in a git submodule (st2tests/st2tests/fixtures/packs/test_content_version), so it also adds a pack_metadata_in_git_submodule target to cleanly handle a case where someone has not checked out the git submodules. This improves the Developer Experience by raising an error as early as possible to let people know that they need to checkout the git submodule and how to do that. Otherwise, they won't get an error until they run tests where we have some code to give the same instructions for the tests that need it.

Note that I have not enabled the plugin yet:

st2/pants.toml

Line 28 in 185e871

#"pack_metadata",

That keeps this PR focused on the plugin itself including adding tests for it. The next PR will add the pack_metadata targets (at least in part using ./pants tailor ::) in our BUILD files. If you want to explore some of that, you can look at: pants-plugins-pack_metadata...pants-pack_metadata

Developing pants plugins

Pants has extensive documentation on the plugin API, including how to create targets, how to write rules, and there's even a mini tutorial about how to add a formatter (adding formatters is a very common thing for plugins to do).

@cognifloyd cognifloyd added this to the pants milestone Jan 17, 2023
@cognifloyd cognifloyd self-assigned this Jan 17, 2023
@pull-request-size pull-request-size bot added the size/L PR that changes 100-499 lines. Requires some effort to review. label Jan 17, 2023
@cognifloyd cognifloyd requested a review from a team January 18, 2023 15:43
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.

Couple of typos

pants-plugins/README.md Outdated Show resolved Hide resolved
pants-plugins/pack_metadata/target_types.py Outdated Show resolved Hide resolved
Co-authored-by: Amanda McGuinness <[email protected]>
Copy link
Member Author

@cognifloyd cognifloyd left a comment

Choose a reason for hiding this comment

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

Good catch! Fixed.

@cognifloyd cognifloyd requested review from amanda11 and a team January 21, 2023 03:35
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement infrastructure: ci/cd pantsbuild size/L PR that changes 100-499 lines. Requires some effort to review. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants