Skip to content

Commit d274278

Browse files
authoredNov 29, 2022
Merge pull request #5778: Use regex-lint to provide circular dependency checking in pants
2 parents b957135 + de4042f commit d274278

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed
 

‎CHANGELOG.rst

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ Changelog
44
in development
55
--------------
66

7+
Added
8+
~~~~~
9+
10+
* Continue introducing `pants <https://www.pantsbuild.org/docs>`_ to improve DX (Developer Experience)
11+
working on StackStorm, improve our security posture, and improve CI reliability thanks in part
12+
to pants' use of PEX lockfiles. This is not a user-facing addition.
13+
#5778
14+
Contributed by @cognifloyd
15+
716

817
3.8.0 - November 18, 2022
918
-------------------------

‎lint-configs/regex-lint.yaml

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Note that for values that are regexes, how YAML interprets backslashes and other
2+
# special characters matters. For example, an unquoted string is interpreted as a raw
3+
# string with no escape characters (so it's particularly useful for expressing regexes).
4+
# Adding quotes around these may change their meaning, so don't do so without thought.
5+
6+
required_matches:
7+
# If we decide to enable this, remove the st2flake8
8+
#python_source:
9+
# - python_header
10+
#build_files:
11+
# - python_header
12+
13+
# TODO: In the future pants should get `visibility` and possibly other
14+
# features to restrict imports for dependees or dependencies.
15+
# - https://github.com/pantsbuild/pants/issues/13393
16+
# - https://github.com/pantsbuild/pants/pull/15803
17+
# - https://github.com/pantsbuild/pants/pull/15836
18+
# When that happens, we can add that target metadata,
19+
# and remove these regex based dependency checks.
20+
21+
# st2client-dependencies-check
22+
st2client:
23+
- must_not_import_st2common
24+
25+
# st2common-circular-dependencies-check
26+
st2common:
27+
- must_not_import_st2reactor
28+
- must_not_import_st2api
29+
- must_not_import_st2auth
30+
#- must_not_import_st2actions
31+
#- must_not_import_st2stream
32+
st2common_except_services_inquiry:
33+
# The makefile excluded: runnersregistrar.py, compat.py, inquiry.py
34+
# runnersregistrar does not have an st2actions ref since 2016.
35+
# compat.py st2actions function was added and removed in 2017.
36+
# services/inquiry.py still imports st2actions.
37+
- must_not_import_st2actions
38+
st2common_except_router:
39+
# The makefile excluded router.py from st2stream check.
40+
# In router.py, "st2stream" is a string, not an import.
41+
- must_not_import_st2stream
42+
43+
path_patterns:
44+
#- name: python_source
45+
# pattern: (?<!__init__)\.py$
46+
#- name: build_files
47+
# pattern: /BUILD$
48+
49+
- name: st2client
50+
pattern: st2client/st2client/.*\.py$
51+
- name: st2common
52+
pattern: st2common/st2common/.*\.py$
53+
54+
- name: st2common_except_services_inquiry
55+
pattern: st2common/st2common/(?!services/inquiry\.py).*\.py$
56+
57+
- name: st2common_except_router
58+
pattern: st2common/st2common/(?!router\.py).*\.py$
59+
60+
content_patterns:
61+
#- name: python_header
62+
# pattern: |+
63+
# ^(?:#\!\/usr\/bin\/env python3
64+
# )?# Copyright 20\d\d The StackStorm Authors.
65+
# (?:# Copyright 20\d\d .*
66+
# )*#
67+
# # Licensed under the Apache License, Version 2.0 (the "License");
68+
# # you may not use this file except in compliance with the License.
69+
# # You may obtain a copy of the License at
70+
# #
71+
# # http://www.apache.org/licenses/LICENSE-2.0
72+
# #
73+
# # Unless required by applicable law or agreed to in writing, software
74+
# # distributed under the License is distributed on an "AS IS" BASIS,
75+
# # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
76+
# # See the License for the specific language governing permissions and
77+
# # limitations under the License.
78+
79+
- name: must_not_import_st2common
80+
pattern: st2common
81+
inverted: true
82+
83+
- name: must_not_import_st2reactor
84+
pattern: st2reactor
85+
inverted: true
86+
87+
- name: must_not_import_st2actions
88+
pattern: st2actions
89+
inverted: true
90+
91+
- name: must_not_import_st2api
92+
pattern: st2api
93+
inverted: true
94+
95+
- name: must_not_import_st2auth
96+
pattern: st2auth
97+
inverted: true
98+
99+
- name: must_not_import_st2stream
100+
pattern: st2stream
101+
inverted: true

‎pants.toml

+3
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,6 @@ extra_requirements = [
112112
"st2flake8==0.1.0", # TODO: remove in favor of regex-lint
113113
]
114114
config = "lint-configs/python/.flake8"
115+
116+
[regex-lint]
117+
config = "@lint-configs/regex-lint.yaml"

0 commit comments

Comments
 (0)
Please sign in to comment.