Use regex-lint to provide circular dependency checking in pants#5778
Merged
cognifloyd merged 2 commits intomasterfrom Nov 29, 2022
Merged
Use regex-lint to provide circular dependency checking in pants#5778cognifloyd merged 2 commits intomasterfrom
cognifloyd merged 2 commits intomasterfrom
Conversation
This was referenced Oct 15, 2022
rush-skills
approved these changes
Oct 17, 2022
|
|
||
| - name: must_not_import_st2common | ||
| pattern: st2common | ||
| inverted: true |
Member
There was a problem hiding this comment.
What does inverted mean here?
Member
Author
There was a problem hiding this comment.
Search for st2common but mark files as successful if they do NOT have the string.
7b1b0d6 to
4915cc2
Compare
Eric-Arellano
approved these changes
Oct 17, 2022
4915cc2 to
5b02ca5
Compare
4bcf7fa to
5958ffd
Compare
winem
approved these changes
Nov 2, 2022
5958ffd to
eeb48b9
Compare
eeb48b9 to
de4042f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
This is another part of introducing
pants, as discussed in the TSC Meetings on 12 July 2022, 02 Aug 2022, 06 Sept 2022, and 04 Oct 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:
pantsto the st2 repo, andpantsstep-by-step.Other pants PRs include:
pants_ignoreand bump pants to v2.14.0rc1 #5733BUILDfiles with./pants tailor ::#5738Overview of this PR
The Makefile has some checks for circular dependencies. Pants has a builtin
regex-lintsubsystem that lets us do basically the same thing via pants.These are the relevant targets in the Makefile:
st2/Makefile
Lines 578 to 591 in 94d0798
It turns out that the Makefile targets are somewhat out-of-date: For example, some of the listed exceptions to the rules no longer apply and we removed st2exporter in #5676. I documented each of my updates in comments of the lint config file.
In #5776, I had to add our
st2flake8plugin forflake8which handles checking for the copyright. We can replace that plugin withregex-lint. I noted how we can do that in the regex-lint config file, but I left it commented out for now. We can enable it later when we're ready to retire thest2flake8custom plugin, which we can probably do once we're ready to remove the Makefile and related files.Relevant Pants documentation
./pants generate-lockfilesgoal./pants lintgoalThings you can do with pantsbuild
You can run
./pants lint ::to see if regex-lint finds any issues (the GHA Lint workflow runs this as well). You can run only one of the linters with the helpful--onlyarg like this:The
--onlyflag is "scoped" to the lint goal. So, these are equivalent if you wanted to specify that flag in a different order:./pants lint --only=regex-lint ::./pants --lint-only=regex-lint lint ::./pants lint :: --lint-only=regex-lintnote: that I had to add
lintin the arg name to use a different order