c2cciutils 1.7.0.dev174__py3-none-any.whl → 1.8.0.dev45__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of c2cciutils might be problematic. Click here for more details.
- c2cciutils/__init__.py +15 -230
- c2cciutils/applications-versions.yaml +3 -3
- c2cciutils/applications_definition.py +20 -22
- c2cciutils/configuration.py +83 -554
- c2cciutils/env.py +8 -31
- c2cciutils/lib/docker.py +2 -8
- c2cciutils/lib/oidc.py +188 -0
- c2cciutils/package-lock.json +115 -127
- c2cciutils/package.json +1 -1
- c2cciutils/publish.py +26 -44
- c2cciutils/schema.json +3 -230
- c2cciutils/scripts/__init__.py +1 -3
- c2cciutils/scripts/clean.py +4 -11
- c2cciutils/scripts/docker_logs.py +4 -4
- c2cciutils/scripts/docker_versions_gen.py +0 -1
- c2cciutils/scripts/download_applications.py +0 -2
- c2cciutils/scripts/env.py +2 -6
- c2cciutils/scripts/k8s/__init__.py +1 -3
- c2cciutils/scripts/k8s/wait.py +2 -2
- c2cciutils/scripts/main.py +4 -16
- c2cciutils/scripts/publish.py +45 -31
- c2cciutils/scripts/trigger_image_update.py +3 -8
- c2cciutils/scripts/version.py +5 -4
- {c2cciutils-1.7.0.dev174.dist-info → c2cciutils-1.8.0.dev45.dist-info}/LICENSE +1 -1
- {c2cciutils-1.7.0.dev174.dist-info → c2cciutils-1.8.0.dev45.dist-info}/METADATA +29 -58
- c2cciutils-1.8.0.dev45.dist-info/RECORD +37 -0
- {c2cciutils-1.7.0.dev174.dist-info → c2cciutils-1.8.0.dev45.dist-info}/WHEEL +1 -1
- {c2cciutils-1.7.0.dev174.dist-info → c2cciutils-1.8.0.dev45.dist-info}/entry_points.txt +0 -3
- c2cciutils/audit.py +0 -229
- c2cciutils/pr_checks.py +0 -286
- c2cciutils/scripts/audit.py +0 -41
- c2cciutils/scripts/docker_versions_update.py +0 -85
- c2cciutils/scripts/pr_checks.py +0 -78
- c2cciutils/security.py +0 -59
- c2cciutils-1.7.0.dev174.dist-info/RECORD +0 -42
c2cciutils/pr_checks.py
DELETED
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
The pull request checking functions.
|
|
3
|
-
|
|
4
|
-
Commits, messages and labels.
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
import os
|
|
8
|
-
import re
|
|
9
|
-
import subprocess # nosec
|
|
10
|
-
from tempfile import NamedTemporaryFile
|
|
11
|
-
from typing import Any, Optional
|
|
12
|
-
|
|
13
|
-
import requests
|
|
14
|
-
import yaml
|
|
15
|
-
|
|
16
|
-
import c2cciutils.configuration
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def _commit_intro(need_separator: bool, commit: dict[str, Any]) -> bool:
|
|
20
|
-
head = commit["commit"]["message"].split("\n")[0]
|
|
21
|
-
if need_separator:
|
|
22
|
-
print("-" * 30)
|
|
23
|
-
print(f'{commit["commit"]["tree"]["sha"]}: {head}')
|
|
24
|
-
return True
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def print_event(github_event: dict[str, Any], **kwargs: Any) -> bool:
|
|
28
|
-
"""
|
|
29
|
-
Print the github object.
|
|
30
|
-
"""
|
|
31
|
-
del kwargs
|
|
32
|
-
print(yaml.dump(github_event, default_flow_style=False, Dumper=yaml.SafeDumper))
|
|
33
|
-
return True
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def commits_messages(
|
|
37
|
-
config: c2cciutils.configuration.PullRequestChecksCommitsMessagesConfiguration,
|
|
38
|
-
commits: list[dict[str, Any]],
|
|
39
|
-
**kwargs: Any,
|
|
40
|
-
) -> bool:
|
|
41
|
-
"""
|
|
42
|
-
Check the commits messages.
|
|
43
|
-
|
|
44
|
-
- They should start with a capital letter.
|
|
45
|
-
- They should not be too short.
|
|
46
|
-
- They should not be a squash or fixup commit.
|
|
47
|
-
- They should not be a merge commit.
|
|
48
|
-
- They should not be a revert commit.
|
|
49
|
-
"""
|
|
50
|
-
del kwargs
|
|
51
|
-
|
|
52
|
-
need_separator = False
|
|
53
|
-
success = True
|
|
54
|
-
first_capital = re.compile(r"^[^a-z]")
|
|
55
|
-
commit_hash = set()
|
|
56
|
-
for commit in commits:
|
|
57
|
-
need_head = True
|
|
58
|
-
commit_hash.add(commit["sha"])
|
|
59
|
-
message_lines = commit["commit"]["message"].split("\n")
|
|
60
|
-
head = message_lines[0]
|
|
61
|
-
if config.get(
|
|
62
|
-
"check_fixup", c2cciutils.configuration.PULL_REQUEST_CHECKS_COMMITS_MESSAGES_FIXUP_DEFAULT
|
|
63
|
-
) and head.startswith("fixup! "):
|
|
64
|
-
if need_head:
|
|
65
|
-
need_separator = _commit_intro(need_separator, commit)
|
|
66
|
-
need_head = False
|
|
67
|
-
print("::error::Fixup message not allowed")
|
|
68
|
-
success = False
|
|
69
|
-
if config.get(
|
|
70
|
-
"check_squash", c2cciutils.configuration.PULL_REQUEST_CHECKS_COMMITS_MESSAGES_SQUASH_DEFAULT
|
|
71
|
-
) and head.startswith("squash! "):
|
|
72
|
-
if need_head:
|
|
73
|
-
need_separator = _commit_intro(need_separator, commit)
|
|
74
|
-
need_head = False
|
|
75
|
-
print("::error::Squash message not allowed")
|
|
76
|
-
success = False
|
|
77
|
-
if (
|
|
78
|
-
config.get(
|
|
79
|
-
"check_first_capital",
|
|
80
|
-
c2cciutils.configuration.PULL_REQUEST_CHECKS_COMMITS_MESSAGES_FIRST_CAPITAL_DEFAULT,
|
|
81
|
-
)
|
|
82
|
-
and first_capital.match(head) is None
|
|
83
|
-
):
|
|
84
|
-
if need_head:
|
|
85
|
-
need_separator = _commit_intro(need_separator, commit)
|
|
86
|
-
need_head = False
|
|
87
|
-
print("::error::The first letter of message head should be a capital")
|
|
88
|
-
success = False
|
|
89
|
-
min_length = config.get(
|
|
90
|
-
"min_head_length",
|
|
91
|
-
c2cciutils.configuration.PULL_REQUEST_CHECKS_COMMITS_MESSAGES_MIN_HEAD_LENGTH_DEFAULT,
|
|
92
|
-
)
|
|
93
|
-
if min_length > 0 and len(head) < min_length:
|
|
94
|
-
if need_head:
|
|
95
|
-
need_separator = _commit_intro(need_separator, commit)
|
|
96
|
-
need_head = False
|
|
97
|
-
print(f"The message head should be at least {min_length} characters long")
|
|
98
|
-
success = False
|
|
99
|
-
if (
|
|
100
|
-
config.get(
|
|
101
|
-
"check_no_merge_commits",
|
|
102
|
-
c2cciutils.configuration.PULL_REQUEST_CHECKS_COMMITS_MESSAGES_NO_MERGE_COMMITS_DEFAULT,
|
|
103
|
-
)
|
|
104
|
-
and len(commit["parents"]) != 1
|
|
105
|
-
):
|
|
106
|
-
if need_head:
|
|
107
|
-
need_separator = _commit_intro(need_separator, commit)
|
|
108
|
-
need_head = False
|
|
109
|
-
print("::error::The merge commit are not allowed")
|
|
110
|
-
success = False
|
|
111
|
-
if config.get(
|
|
112
|
-
"check_no_own_revert",
|
|
113
|
-
c2cciutils.configuration.PULL_REQUEST_CHECKS_COMMITS_MESSAGES_NO_OWN_REVERT_DEFAULT,
|
|
114
|
-
) and (
|
|
115
|
-
head.startswith("Revert ")
|
|
116
|
-
and len(message_lines) == 3
|
|
117
|
-
and message_lines[2].startswith("This reverts commit ")
|
|
118
|
-
):
|
|
119
|
-
revert_commit_hash = message_lines[2][len("This reverts commit ") : -1]
|
|
120
|
-
if revert_commit_hash in commit_hash:
|
|
121
|
-
if need_head:
|
|
122
|
-
need_separator = _commit_intro(need_separator, commit)
|
|
123
|
-
need_head = False
|
|
124
|
-
print(f"Revert own commits is not allowed ({revert_commit_hash})")
|
|
125
|
-
success = False
|
|
126
|
-
continue
|
|
127
|
-
return success
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
def commits_spell(
|
|
131
|
-
config: c2cciutils.configuration.PullRequestChecksCommitsSpellingConfiguration,
|
|
132
|
-
full_config: c2cciutils.configuration.Configuration,
|
|
133
|
-
commits: list[dict[str, Any]],
|
|
134
|
-
**kwargs: Any,
|
|
135
|
-
) -> bool:
|
|
136
|
-
"""Check the spelling of the commits body."""
|
|
137
|
-
del kwargs
|
|
138
|
-
|
|
139
|
-
spellcheck_cmd = c2cciutils.get_codespell_command(full_config)
|
|
140
|
-
|
|
141
|
-
success = True
|
|
142
|
-
need_separator = False
|
|
143
|
-
for commit in commits:
|
|
144
|
-
with NamedTemporaryFile("w+t", encoding="utf-8", suffix=".yaml") as temp_file:
|
|
145
|
-
if config.get(
|
|
146
|
-
"only_head", c2cciutils.configuration.PULL_REQUEST_CHECKS_COMMITS_MESSAGES_ONLY_HEAD_DEFAULT
|
|
147
|
-
):
|
|
148
|
-
head = commit["commit"]["message"].split("\n")[0]
|
|
149
|
-
temp_file.write(head)
|
|
150
|
-
else:
|
|
151
|
-
temp_file.write(commit["commit"]["message"])
|
|
152
|
-
temp_file.flush()
|
|
153
|
-
spell = subprocess.run( # nosec # pylint: disable=subprocess-run-check
|
|
154
|
-
spellcheck_cmd + [temp_file.name], capture_output=True
|
|
155
|
-
)
|
|
156
|
-
if spell.returncode != 0:
|
|
157
|
-
need_separator = _commit_intro(need_separator, commit)
|
|
158
|
-
print("::error::Code spell error")
|
|
159
|
-
print(spell.stderr)
|
|
160
|
-
print(spell.stdout)
|
|
161
|
-
success = False
|
|
162
|
-
return success
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
def pull_request_spell(
|
|
166
|
-
config: c2cciutils.configuration.PullRequestChecksPullRequestSpellingConfiguration,
|
|
167
|
-
full_config: c2cciutils.configuration.Configuration,
|
|
168
|
-
github_event: dict[str, Any],
|
|
169
|
-
**kwargs: Any,
|
|
170
|
-
) -> bool:
|
|
171
|
-
"""Check the spelling of the pull request title and message."""
|
|
172
|
-
del kwargs
|
|
173
|
-
|
|
174
|
-
spellcheck_cmd = c2cciutils.get_codespell_command(full_config)
|
|
175
|
-
|
|
176
|
-
with NamedTemporaryFile("w+t") as temp_file:
|
|
177
|
-
temp_file.write(github_event["event"]["pull_request"]["title"])
|
|
178
|
-
temp_file.write("\n")
|
|
179
|
-
if not config.get(
|
|
180
|
-
"only_head", c2cciutils.configuration.PULL_REQUEST_CHECKS_ONLY_HEAD_DEFAULT
|
|
181
|
-
) and github_event["event"]["pull_request"].get("body"):
|
|
182
|
-
temp_file.write("\n")
|
|
183
|
-
temp_file.write(github_event["event"]["pull_request"]["body"])
|
|
184
|
-
temp_file.write("\n")
|
|
185
|
-
temp_file.flush()
|
|
186
|
-
spell = subprocess.run( # nosec # pylint: disable=subprocess-run-check
|
|
187
|
-
spellcheck_cmd + [temp_file.name], capture_output=True
|
|
188
|
-
)
|
|
189
|
-
if spell.returncode != 0:
|
|
190
|
-
print("::error::Code spell error in pull request")
|
|
191
|
-
print(spell.stderr)
|
|
192
|
-
print(spell.stdout)
|
|
193
|
-
return False
|
|
194
|
-
return True
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
def pull_request_labels(github_event: dict[str, Any], **kwargs: Any) -> bool:
|
|
198
|
-
"""Check it the label are set correctly for the changelog generation."""
|
|
199
|
-
del kwargs
|
|
200
|
-
|
|
201
|
-
if github_event["actor"] == "renovate[bot]":
|
|
202
|
-
return True
|
|
203
|
-
|
|
204
|
-
if not os.path.exists(".github/changelog-config.yaml"):
|
|
205
|
-
return True
|
|
206
|
-
|
|
207
|
-
required_labels = []
|
|
208
|
-
with open(".github/changelog-config.yaml", encoding="utf-8") as changelog_config_file:
|
|
209
|
-
changelog_config = yaml.load(changelog_config_file, Loader=yaml.SafeLoader)
|
|
210
|
-
for section in changelog_config.values():
|
|
211
|
-
if "labels" in section:
|
|
212
|
-
required_labels.extend(section["labels"])
|
|
213
|
-
|
|
214
|
-
print(f"Required one onf the following labels: {', '.join(required_labels)}")
|
|
215
|
-
|
|
216
|
-
if required_labels:
|
|
217
|
-
labels = [
|
|
218
|
-
label["name"]
|
|
219
|
-
for label in github_event["event"]["pull_request"]["labels"]
|
|
220
|
-
if label["name"] in required_labels
|
|
221
|
-
]
|
|
222
|
-
if len(labels) == 0:
|
|
223
|
-
print(f"::error::No required label found: {', '.join(required_labels)}")
|
|
224
|
-
return False
|
|
225
|
-
if len(labels) > 1:
|
|
226
|
-
print(f"::error::Too many required labels found: {', '.join(labels)}")
|
|
227
|
-
return False
|
|
228
|
-
return True
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
GET_ISSUE_RE = [
|
|
232
|
-
re.compile(r"^([A-Z]{3,6}-[0-9]+)-.*$"),
|
|
233
|
-
re.compile(r"^([a-z]{3,6}-[0-9]+)-.*$"),
|
|
234
|
-
re.compile(r"^.*-([A-Z]{3,6}-[0-9]+)$"),
|
|
235
|
-
re.compile(r"^.*-([a-z]{3,6}-[0-9]+)$"),
|
|
236
|
-
]
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
def _get_issue_number(name: str) -> Optional[str]:
|
|
240
|
-
for re_ in GET_ISSUE_RE:
|
|
241
|
-
match = re_.match(name)
|
|
242
|
-
if match is not None:
|
|
243
|
-
return match.group(1)
|
|
244
|
-
return None
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
def add_issue_link(github_event: dict[str, Any], **kwargs: Any) -> bool:
|
|
248
|
-
"""Add a comment with the link to Jira if needed."""
|
|
249
|
-
del kwargs
|
|
250
|
-
|
|
251
|
-
issue_number = _get_issue_number(github_event["event"]["pull_request"]["head"]["ref"])
|
|
252
|
-
|
|
253
|
-
if issue_number is None:
|
|
254
|
-
return True
|
|
255
|
-
|
|
256
|
-
issue_number = issue_number.upper()
|
|
257
|
-
|
|
258
|
-
body = github_event["event"]["pull_request"].get("body") or ""
|
|
259
|
-
if issue_number in body.upper():
|
|
260
|
-
return True
|
|
261
|
-
|
|
262
|
-
comments_response = requests.get(
|
|
263
|
-
github_event["event"]["pull_request"]["_links"]["comments"]["href"],
|
|
264
|
-
timeout=int(os.environ.get("C2CCIUTILS_TIMEOUT", "30")),
|
|
265
|
-
headers=c2cciutils.add_authorization_header({}),
|
|
266
|
-
)
|
|
267
|
-
c2cciutils.check_response(comments_response)
|
|
268
|
-
comments = comments_response.json()
|
|
269
|
-
|
|
270
|
-
for comment in comments:
|
|
271
|
-
if issue_number in comment.get("body", "").upper():
|
|
272
|
-
return True
|
|
273
|
-
|
|
274
|
-
response = requests.post(
|
|
275
|
-
github_event["event"]["pull_request"]["_links"]["comments"]["href"],
|
|
276
|
-
headers={
|
|
277
|
-
"Accept": "application/vnd.github+json",
|
|
278
|
-
"Authorization": f"Bearer {github_event['token']}",
|
|
279
|
-
},
|
|
280
|
-
json={"body": f"See also: [{issue_number}](https://jira.camptocamp.com/browse/{issue_number})"},
|
|
281
|
-
timeout=int(os.environ.get("C2CCIUTILS_TIMEOUT", "30")),
|
|
282
|
-
)
|
|
283
|
-
|
|
284
|
-
if not response.ok:
|
|
285
|
-
print(f"Unable to add the comment: {response.text}")
|
|
286
|
-
return response.ok
|
c2cciutils/scripts/audit.py
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
"""
|
|
4
|
-
The audit main function.
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
import argparse
|
|
8
|
-
import os
|
|
9
|
-
import sys
|
|
10
|
-
|
|
11
|
-
import c2cciutils.audit
|
|
12
|
-
import c2cciutils.env
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def main() -> None:
|
|
16
|
-
"""
|
|
17
|
-
Run the audit.
|
|
18
|
-
"""
|
|
19
|
-
parser = argparse.ArgumentParser(description="Run the audit of c2cciutils.")
|
|
20
|
-
parser.add_argument("--branch", help="The branch to audit, not defined means autodetect")
|
|
21
|
-
parser.add_argument("--check", help="Runs only the specified check")
|
|
22
|
-
parser.add_argument("--fix", action="store_true", help="Fix issues")
|
|
23
|
-
|
|
24
|
-
args = parser.parse_args()
|
|
25
|
-
|
|
26
|
-
full_config = c2cciutils.get_config()
|
|
27
|
-
c2cciutils.env.print_environment(full_config)
|
|
28
|
-
|
|
29
|
-
config = full_config.get("audit", {})
|
|
30
|
-
success = True
|
|
31
|
-
for key, conf in config.items():
|
|
32
|
-
if conf is not False and (args.check is None or args.check == key):
|
|
33
|
-
audit = getattr(c2cciutils.audit, key)
|
|
34
|
-
print(f"Run audit {key}")
|
|
35
|
-
success &= audit({} if conf is True else conf, full_config, args)
|
|
36
|
-
if not success and os.environ.get("TEST") != "TRUE":
|
|
37
|
-
sys.exit(1)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if __name__ == "__main__":
|
|
41
|
-
main()
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import argparse
|
|
2
|
-
import re
|
|
3
|
-
import subprocess # nosec
|
|
4
|
-
import sys
|
|
5
|
-
|
|
6
|
-
import yaml
|
|
7
|
-
|
|
8
|
-
import c2cciutils
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def main() -> None:
|
|
12
|
-
"""Update the version of packages in the file ci/dpkg-versions.yaml."""
|
|
13
|
-
|
|
14
|
-
argparser = argparse.ArgumentParser(
|
|
15
|
-
description="Update the version of packages in the file ci/dpkg-versions.yaml."
|
|
16
|
-
)
|
|
17
|
-
argparser.add_argument("--branch", help="The branch to audit, not defined means autodetect")
|
|
18
|
-
args = argparser.parse_args()
|
|
19
|
-
|
|
20
|
-
cache: dict[str, dict[str, str]] = {}
|
|
21
|
-
with open("ci/dpkg-versions.yaml", encoding="utf-8") as versions_file:
|
|
22
|
-
versions_config = yaml.load(versions_file, Loader=yaml.SafeLoader)
|
|
23
|
-
for versions in versions_config.values():
|
|
24
|
-
for package_full in versions.keys():
|
|
25
|
-
dist, package = package_full.split("/")
|
|
26
|
-
if dist not in cache:
|
|
27
|
-
correspondence = {
|
|
28
|
-
"ubuntu_22_04": ("ubuntu", "22.04"),
|
|
29
|
-
"debian_11": ("debian", "11"),
|
|
30
|
-
"debian_12": ("debian", "12"),
|
|
31
|
-
}
|
|
32
|
-
if dist in correspondence:
|
|
33
|
-
images, tag = correspondence[dist]
|
|
34
|
-
subprocess.run(
|
|
35
|
-
["docker", "rm", "--force", "apt"], stderr=subprocess.DEVNULL, check=False
|
|
36
|
-
)
|
|
37
|
-
subprocess.run(
|
|
38
|
-
[
|
|
39
|
-
"docker",
|
|
40
|
-
"run",
|
|
41
|
-
"--tty",
|
|
42
|
-
"--interactive",
|
|
43
|
-
"--detach",
|
|
44
|
-
"--name=apt",
|
|
45
|
-
"--entrypoint=",
|
|
46
|
-
f"{images}:{tag}",
|
|
47
|
-
"tail",
|
|
48
|
-
"--follow",
|
|
49
|
-
"/dev/null",
|
|
50
|
-
],
|
|
51
|
-
check=True,
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
subprocess.run(["docker", "exec", "apt", "apt-get", "update"], check=True)
|
|
55
|
-
|
|
56
|
-
package_re = re.compile(r"^([^ /]+)/[a-z-,]+ ([^ ]+) (all|amd64)( .*)?$")
|
|
57
|
-
proc = subprocess.run(
|
|
58
|
-
["docker", "exec", "apt", "apt", "list"], check=True, stdout=subprocess.PIPE
|
|
59
|
-
)
|
|
60
|
-
for proc_line in proc.stdout.decode("utf-8").split("\n"):
|
|
61
|
-
package_match = package_re.match(proc_line)
|
|
62
|
-
if package_match is None:
|
|
63
|
-
print(f"not matching: {proc_line}")
|
|
64
|
-
continue
|
|
65
|
-
cache.setdefault(dist, {})[package_match.group(1)] = package_match.group(2)
|
|
66
|
-
|
|
67
|
-
subprocess.run(["docker", "rm", "--force", "apt"], check=True)
|
|
68
|
-
|
|
69
|
-
if package in cache[dist]:
|
|
70
|
-
versions[package_full] = cache[dist][package]
|
|
71
|
-
|
|
72
|
-
with open("ci/dpkg-versions.yaml", "w", encoding="utf-8") as versions_file:
|
|
73
|
-
yaml.dump(versions_config, versions_file, Dumper=yaml.SafeDumper)
|
|
74
|
-
|
|
75
|
-
current_branch = c2cciutils.get_branch(args.branch)
|
|
76
|
-
has_diff = c2cciutils.create_pull_request_if_needed(
|
|
77
|
-
current_branch, f"dpkg-update/{current_branch}", "Update dpkg package versions"
|
|
78
|
-
)
|
|
79
|
-
if has_diff:
|
|
80
|
-
print("There is a diff, please check the pull request")
|
|
81
|
-
sys.exit(1)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if __name__ == "__main__":
|
|
85
|
-
main()
|
c2cciutils/scripts/pr_checks.py
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
"""
|
|
4
|
-
The pull request checker main function.
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
import argparse
|
|
8
|
-
import json
|
|
9
|
-
import os
|
|
10
|
-
import sys
|
|
11
|
-
import traceback
|
|
12
|
-
|
|
13
|
-
import requests
|
|
14
|
-
|
|
15
|
-
import c2cciutils
|
|
16
|
-
import c2cciutils.env
|
|
17
|
-
import c2cciutils.pr_checks
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def main() -> None:
|
|
21
|
-
"""
|
|
22
|
-
Run the checks.
|
|
23
|
-
"""
|
|
24
|
-
parser = argparse.ArgumentParser(description="Run the pull request checks of c2cciutils.")
|
|
25
|
-
parser.add_argument("--stop", action="store_true", help="stop on first error")
|
|
26
|
-
parser.add_argument("--check", help="runs only the specified check")
|
|
27
|
-
|
|
28
|
-
args = parser.parse_args()
|
|
29
|
-
|
|
30
|
-
full_config = c2cciutils.get_config()
|
|
31
|
-
c2cciutils.env.print_environment(full_config)
|
|
32
|
-
|
|
33
|
-
github_event = json.loads(os.environ["GITHUB_EVENT"])
|
|
34
|
-
|
|
35
|
-
commits_response = requests.get(
|
|
36
|
-
github_event["event"]["pull_request"]["_links"]["commits"]["href"],
|
|
37
|
-
timeout=int(os.environ.get("C2CCIUTILS_TIMEOUT", "30")),
|
|
38
|
-
headers=c2cciutils.add_authorization_header({}),
|
|
39
|
-
)
|
|
40
|
-
c2cciutils.check_response(commits_response)
|
|
41
|
-
commits = commits_response.json()
|
|
42
|
-
|
|
43
|
-
config = full_config["pr-checks"]
|
|
44
|
-
|
|
45
|
-
check_args = {
|
|
46
|
-
"args": args,
|
|
47
|
-
"full_config": full_config,
|
|
48
|
-
"commits": commits,
|
|
49
|
-
"github_event": github_event,
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
success = True
|
|
53
|
-
for key, conf in config.items():
|
|
54
|
-
if conf is not False and (args.check is None or args.check == key):
|
|
55
|
-
check = getattr(c2cciutils.pr_checks, key)
|
|
56
|
-
print(f"::group::Run check {key}")
|
|
57
|
-
try:
|
|
58
|
-
if not check(config={} if conf is True else conf, **check_args):
|
|
59
|
-
success = False
|
|
60
|
-
print("::endgroup::")
|
|
61
|
-
if args.stop:
|
|
62
|
-
sys.exit(1)
|
|
63
|
-
print("::error::With error")
|
|
64
|
-
else:
|
|
65
|
-
print("::endgroup::")
|
|
66
|
-
except Exception: # pylint: disable=broad-except
|
|
67
|
-
traceback.print_exc()
|
|
68
|
-
success = False
|
|
69
|
-
print("::endgroup::")
|
|
70
|
-
if args.stop:
|
|
71
|
-
sys.exit(1)
|
|
72
|
-
print("::error::With exception")
|
|
73
|
-
if not success:
|
|
74
|
-
sys.exit(1)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if __name__ == "__main__":
|
|
78
|
-
main()
|
c2cciutils/security.py
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Read the table of versions from SECURITY.md.
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
import xml.etree.ElementTree # nosec
|
|
6
|
-
from typing import Optional
|
|
7
|
-
|
|
8
|
-
import markdown
|
|
9
|
-
from markdown.extensions.tables import TableExtension
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class Security:
|
|
13
|
-
"""
|
|
14
|
-
Read the table of versions from SECURITY.md.
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
headers: list[str]
|
|
18
|
-
data: list[list[str]]
|
|
19
|
-
_row: Optional[list[str]] = None
|
|
20
|
-
|
|
21
|
-
def __init__(self, status: str):
|
|
22
|
-
"""
|
|
23
|
-
Initialize.
|
|
24
|
-
|
|
25
|
-
Arguments:
|
|
26
|
-
status: the content of the SECURITY.md file.
|
|
27
|
-
"""
|
|
28
|
-
|
|
29
|
-
self.headers = []
|
|
30
|
-
self.data = []
|
|
31
|
-
|
|
32
|
-
markdown_instance = markdown.Markdown(extensions=[TableExtension()])
|
|
33
|
-
|
|
34
|
-
elem = markdown_instance.parser.parseDocument(
|
|
35
|
-
[s for s in status.split("\n") if s != "" and s[0] == "|"]
|
|
36
|
-
)
|
|
37
|
-
self._pe(elem.getroot())
|
|
38
|
-
|
|
39
|
-
self.data = [r for r in self.data if len([c for c in r if c is not None]) > 0]
|
|
40
|
-
for row in self.data:
|
|
41
|
-
row.append("")
|
|
42
|
-
|
|
43
|
-
def _pe(self, elem: xml.etree.ElementTree.Element) -> None:
|
|
44
|
-
"""
|
|
45
|
-
Parse the HTML table.
|
|
46
|
-
|
|
47
|
-
Arguments:
|
|
48
|
-
elem: The XML element
|
|
49
|
-
"""
|
|
50
|
-
if elem.tag == "th":
|
|
51
|
-
assert elem.text is not None
|
|
52
|
-
self.headers.append(elem.text)
|
|
53
|
-
if elem.tag == "tr":
|
|
54
|
-
self._row = []
|
|
55
|
-
self.data.append(self._row)
|
|
56
|
-
if elem.tag == "td":
|
|
57
|
-
self._row.append(elem.text) # type: ignore
|
|
58
|
-
for element in list(elem):
|
|
59
|
-
self._pe(element)
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
c2cciutils/__init__.py,sha256=M6hqae9Eai2yB2dD4igKHktBJ5ZRqh6Cpv18fLP9Kzo,20992
|
|
2
|
-
c2cciutils/applications-versions.yaml,sha256=IyV2_a3ZdZh94QqoiVhO9yg1H5xPwlHbxD29FXBsTD4,224
|
|
3
|
-
c2cciutils/applications.yaml,sha256=yn0XRi08cS29A_jXPofcBPxsGBv7PEBliztjRC3WtfM,504
|
|
4
|
-
c2cciutils/applications_definition.py,sha256=i-RdJT6l_SEbI1kX1RpXXCJwHq9pOj6HWtI6wTSCVN4,1287
|
|
5
|
-
c2cciutils/audit.py,sha256=e3RdkO0qtQiGQ3w8J2eLFLWEknbpbyu9JYY23_7F0l0,7322
|
|
6
|
-
c2cciutils/branches.graphql,sha256=UZrj1RO-H527M1SKqWm1VnkWtNsuKTnPTf4BCU2YcOU,358
|
|
7
|
-
c2cciutils/commits.graphql,sha256=3HAuIEig5V7j1L-6mqBaOkiTD3Fb8_gl1ilpZjPJf74,308
|
|
8
|
-
c2cciutils/configuration.py,sha256=sgyyd4WuYX53ZkJsa7dShcDbWUa9rfIVbOm7tCswTm8,28357
|
|
9
|
-
c2cciutils/default_branch.graphql,sha256=CaP3rRsNiyg_7RvqbMk0tOJr0aqWd8cOeSV-ZKgvKY4,131
|
|
10
|
-
c2cciutils/env.py,sha256=J-lC7GdOkdFVIrWFZEkAxHmIuTYwhDJiE30BICj2UoM,3425
|
|
11
|
-
c2cciutils/lib/docker.py,sha256=lwvCarwSSUWK1Y4O7qcTILPdpkTf2Ujhl_fCwZ6dBUY,5677
|
|
12
|
-
c2cciutils/package-lock.json,sha256=D4LS-koyilf5zULDaBvYhhBHvuXa16L67YqLE3xiVe8,13909
|
|
13
|
-
c2cciutils/package.json,sha256=3oTjMF5dEQ-JsiYRuiJm2je9XU5cABYhPEQIZ5cyhuQ,134
|
|
14
|
-
c2cciutils/pr_checks.py,sha256=tBwDHxThcu6648pE2cqpLNsaU711lwwgRc7sB4qR6fU,10109
|
|
15
|
-
c2cciutils/publish.py,sha256=KOEtPe-y1uw0-DWfKnF5jmYfQb5c0_URKBxakthcrBI,17259
|
|
16
|
-
c2cciutils/schema-applications.json,sha256=Tus-s9NB7uwKhTrQwhWQM4_oJygF_yHUqShtZhN1IxE,1551
|
|
17
|
-
c2cciutils/schema.json,sha256=eQ4pVMp5uTWnYeh-4IaviBonZ9rtVZkMYJ71g5ZvU3k,23316
|
|
18
|
-
c2cciutils/scripts/__init__.py,sha256=N4tcdvUifXQrK9vEvFWrGvoyY9oZ0uRcjb-FoYe41cc,36
|
|
19
|
-
c2cciutils/scripts/audit.py,sha256=MUQqpA8CNkbSyK5e0HiSC5w-4GPKYEqFgV82lIwKkQk,1104
|
|
20
|
-
c2cciutils/scripts/clean.py,sha256=tpyipZjqK7om9_dNiLxvz6-l6le7N0L03inkrKe7Y_A,3039
|
|
21
|
-
c2cciutils/scripts/docker_logs.py,sha256=OoTstW3oUVpICASgLTCYfjDtgcuYMJxWDcy2pXyr6tE,1712
|
|
22
|
-
c2cciutils/scripts/docker_versions_gen.py,sha256=M_VzKlhqsmUwd9GgPIU9EW6eCmMmytkJQEhOFjYVZl4,1316
|
|
23
|
-
c2cciutils/scripts/docker_versions_update.py,sha256=6AwBXoMqWzocF5yas09VCOWACA3JtIo-_Q3KBFaO3Qs,3511
|
|
24
|
-
c2cciutils/scripts/download_applications.py,sha256=Lxnm2XJSfDtZc47xUtJQx52N2tIARYioTvPEXKOMMJ0,4490
|
|
25
|
-
c2cciutils/scripts/env.py,sha256=4AmCZa2NPF1TaPrzpk5DnrCrMO_cWbFjKK3IM3XSg8s,375
|
|
26
|
-
c2cciutils/scripts/k8s/__init__.py,sha256=ESPfnAzxPBK-TXColaFlz0OxAouX_fHV8MDamhVEsYw,69
|
|
27
|
-
c2cciutils/scripts/k8s/db.py,sha256=GK1tzzyCqrCyIJzcBdIXjyNJUXrBPFNa-9fdtwxyrlU,3268
|
|
28
|
-
c2cciutils/scripts/k8s/install.py,sha256=OIQ8KHA3Pst2pjO2E-J5FYNaBHW-i-fqCXlAUcG1tw0,933
|
|
29
|
-
c2cciutils/scripts/k8s/logs.py,sha256=-xJYu8BBUmSmMrPEwiTBKZjJBRyIlMp1depCB04_NWs,2655
|
|
30
|
-
c2cciutils/scripts/k8s/wait.py,sha256=qzQn6hbB9p1CX4bUxrkukPnbu_p6oRNem29WiMtplNk,5661
|
|
31
|
-
c2cciutils/scripts/main.py,sha256=pj9gPIrmDUctVPEtaQQGZo-7k7mMeIs14sKQ7w6Sw1Y,1162
|
|
32
|
-
c2cciutils/scripts/pin_pipenv.py,sha256=jBTwlolcEL0MUyq6VYzO-adkcL1gqN7B3kBb3UjTo2k,2150
|
|
33
|
-
c2cciutils/scripts/pr_checks.py,sha256=PA9z9QB81H2JhGSr4T02eoxyeWDjQZ4XoIKFzS5o5A0,2190
|
|
34
|
-
c2cciutils/scripts/publish.py,sha256=upTv6ia8_EwOx_R1-FXinJnLinlcdKKDQ7yhFF1LgiA,19716
|
|
35
|
-
c2cciutils/scripts/trigger_image_update.py,sha256=UPCSgFcllewo1NOC7kUkJ2QMXU0dCA2QAq6LFQHr0Uw,2780
|
|
36
|
-
c2cciutils/scripts/version.py,sha256=BU6I3nG3ofgUXCLrUBNOql45Dz9Loox4gt4ebHRM3iQ,8912
|
|
37
|
-
c2cciutils/security.py,sha256=aYmsbKqACIPFoJ2Dfg4ZtACe0uheNJY3LWx9pElb9UI,1495
|
|
38
|
-
c2cciutils-1.7.0.dev174.dist-info/entry_points.txt,sha256=qB_mezKHsYy5j11RAhsEB_gPVZC2BebEvfT5Giu_D7s,1111
|
|
39
|
-
c2cciutils-1.7.0.dev174.dist-info/LICENSE,sha256=pK1gU5i1jYBv--vi5omcf6-86pYmAWk6ZGbdERjAgcw,1307
|
|
40
|
-
c2cciutils-1.7.0.dev174.dist-info/WHEEL,sha256=gSF7fibx4crkLz_A-IKR6kcuq0jJ64KNCkG8_bcaEao,88
|
|
41
|
-
c2cciutils-1.7.0.dev174.dist-info/METADATA,sha256=8rgaB41r_bN9js551rdDA-9tYZFdtfWLlJmmxvuPyxM,19658
|
|
42
|
-
c2cciutils-1.7.0.dev174.dist-info/RECORD,,
|