Merged
Conversation
rush-skills
reviewed
Oct 17, 2022
| @@ -1,5 +1,6 @@ | |||
| python_sources( | |||
| sources=["st2*"], | |||
| skip_flake8=True, | |||
Member
There was a problem hiding this comment.
Why do we enable skip_flake8 in these?
Member
Author
There was a problem hiding this comment.
I skipped the bin files because the Makefile does not run flake8 on them, so there are a variety of violations. Here's what it looks like when I comment out this line in st2common/bin/BUILD:
jafloyd@MB-C02XKFC0JG5H st2 % ./pants lint --only=flake8 ::
10:03:43.98 [INFO] Completed: Lint with Flake8 - flake8 succeeded.
10:03:43.98 [INFO] Completed: Lint with Flake8 - flake8 succeeded.
10:03:43.98 [INFO] Completed: Lint with Flake8 - flake8 succeeded.
10:03:43.98 [INFO] Completed: Lint with Flake8 - flake8 succeeded.
10:03:43.98 [INFO] Completed: Lint with Flake8 - flake8 succeeded.
10:03:43.98 [INFO] Completed: Lint with Flake8 - flake8 succeeded.
10:03:43.98 [INFO] Completed: Lint with Flake8 - flake8 succeeded.
10:03:43.98 [INFO] Completed: Lint with Flake8 - flake8 succeeded.
10:03:46.77 [ERROR] Completed: Lint with Flake8 - flake8 failed (exit code 1).
st2common/bin/st2-bootstrap-rmq:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-bootstrap-rmq:1:2: C801 Copyright notice not present.
st2common/bin/st2-cleanup-db:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-cleanup-db:1:2: C801 Copyright notice not present.
st2common/bin/st2-generate-api-spec:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-generate-api-spec:1:2: C801 Copyright notice not present.
st2common/bin/st2-generate-schemas:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-generate-symmetric-crypto-key:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-generate-symmetric-crypto-key:1:2: C801 Copyright notice not present.
st2common/bin/st2-pack-download:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-pack-download:1:2: C801 Copyright notice not present.
st2common/bin/st2-pack-install:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-pack-install:1:2: C801 Copyright notice not present.
st2common/bin/st2-pack-setup-virtualenv:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-pack-setup-virtualenv:1:2: C801 Copyright notice not present.
st2common/bin/st2-purge-executions:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-purge-executions:1:2: C801 Copyright notice not present.
st2common/bin/st2-purge-rule-enforcements:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-purge-rule-enforcements:1:2: C801 Copyright notice not present.
st2common/bin/st2-purge-task-executions:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-purge-task-executions:1:2: C801 Copyright notice not present.
st2common/bin/st2-purge-tokens:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-purge-tokens:1:2: C801 Copyright notice not present.
st2common/bin/st2-purge-traces:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-purge-traces:1:2: C801 Copyright notice not present.
st2common/bin/st2-purge-trigger-instances:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-purge-trigger-instances:1:2: C801 Copyright notice not present.
st2common/bin/st2-purge-workflows:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-purge-workflows:1:2: C801 Copyright notice not present.
st2common/bin/st2-register-content:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-register-content:1:2: C801 Copyright notice not present.
st2common/bin/st2-track-result:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-track-result:1:2: C801 Copyright notice not present.
st2common/bin/st2-track-result:18:1: F401 'sys' imported but unused
st2common/bin/st2-validate-api-spec:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-validate-api-spec:1:2: C801 Copyright notice not present.
st2common/bin/st2-validate-pack:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-validate-pack:24:1: F401 'inspect' imported but unused
st2common/bin/st2-validate-pack:25:1: F401 'json' imported but unused
st2common/bin/st2-validate-pack:28:1: F401 'yaml' imported but unused
st2common/bin/st2-validate-pack-config:1:2: L102 Apache 2.0 license header not found
st2common/bin/st2-validate-pack-config:1:2: C801 Copyright notice not present.
✕ flake8 failed.
Member
Author
There was a problem hiding this comment.
we can remove skip_flake8 and fix the issues in a follow-up PR (probably a great first contributor PR)
8679bb8 to
9a9dc29
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
This configures pants to use
flake8when running thelintgoal.I added our st2flake8 plugin to
[flake8].extra_requirements(inpants.toml) so that our copyright check will work as it does now. Eventually, I would like to switch to pants'regex-lintso we have less custom code to maintain. For now, this sticks with how we're using flake8 now.By default, newer versions of pants will use
flake8>=5.0.4,<5.1(see pantsbuild/pants#17226), but our plugin does not support flake8 5. Since we need to use something older, we also need to pin importlib-metadata, which older versions of flake8 do not pin appropriately. We do not currently pin the version of flake8, so I went withflake8==4.0.1because that is what is getting installed in our CI workflows now.Pants uses a lockfile for each tool it uses to ensure we get consistent results. Since I changed
[flake8].extra_requirementsinpants.tomlwe also need to regenerate the flake8 lockfile. Once we drop our custom flake8 requirements, we can probably just reuse the<default>lockfile for flake8 distributed with pants.As described in #5774, I'm putting lockfiles under the
lockfiles/directory. I'm also not using an extension on the file. Pants does not care about extensions, so we can adopt our own convention on naming the lockfiles. For now, I skipped the extension, but we could easily use.lockor something similar.NOTE: it is not safe to manually change the lockfiles. If we need to change any dependencies (including transitive deps), we need to use pants to regenerate the applicable lockfiles. Therefore, 349 lines of this change are auto-generated - you can review them for sanity, but we should not change them manually.
I also added a few
skip_flake8=Trueentries to BUILD files where we aren't currently running flake8 on them. We can address any flake8-identified issues in follow-up PRs.Relevant Pants documentation
./pants generate-lockfilesgoal./pants lintgoalpython_sourcespython_sourceThings you can do with pantsbuild
I needed to generate the
lockfiles/flake8lockfile, which I did with this (the "scheduler" info messages occur wheneverpantsdis starting up in the background, so we can ignore those.):You can run
./pants lint ::to see if flake8 finds any issues (the GHA Lint workflow runs this as well).