c2cciutils 1.8.0.dev64__py3-none-any.whl → 1.8.0.dev68__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.

@@ -1,245 +0,0 @@
1
- #!/usr/bin/env python3
2
-
3
- import argparse
4
- import json
5
- import os
6
- import re
7
- import subprocess # nosec
8
-
9
- import multi_repo_automation as mra
10
- import ruamel.yaml.comments
11
-
12
- import c2cciutils
13
-
14
-
15
- def main() -> None:
16
- """Create a new version with its stabilization branch."""
17
- args_parser = argparse.ArgumentParser(
18
- description="Create a new version with its stabilization branch",
19
- usage="""
20
- This will:
21
- - Stash all your changes
22
- - Checkout the master branch
23
- - Pull it from origin
24
- - Push it to a new stabilization branch
25
- - Checkout a new branch named new-version
26
- - Do the changes for the new version
27
- - Update the SECURITY.md config
28
- - Update the Renovate config
29
- - Update the audit workflow
30
- - Create the backport label
31
- - Push it
32
- - Create a pull request
33
- - Go back to your old branch
34
-
35
- If you run the tool without any version it will check that everything is OK regarding the SECURITY.md available on GitHub.
36
- """,
37
- )
38
- args_parser.add_argument(
39
- "--version",
40
- help="The version to create",
41
- )
42
- args_parser.add_argument(
43
- "--force",
44
- action="store_true",
45
- help="Force create the branch and push it",
46
- )
47
- args_parser.add_argument(
48
- "--supported-until",
49
- help="The date until the version is supported, can also be To be defined or Best effort",
50
- default="Best effort",
51
- )
52
- args_parser.add_argument(
53
- "--upstream-supported-until",
54
- help="The date until the version is supported upstream",
55
- )
56
- arguments = args_parser.parse_args()
57
-
58
- # Get the repo information e.g.:
59
- # {
60
- # "name": "camptocamp/c2cciutils",
61
- # "remote": "origin",
62
- # "dir": "/home/user/src/c2cciutils",
63
- # }
64
- # can be override with a repo.yaml file
65
- repo = mra.get_repo_config()
66
-
67
- # Stash all your changes
68
- subprocess.run(["git", "stash", "--all", "--message=Stashed by release creation"], check=True)
69
- old_branch_name = subprocess.run(
70
- ["git", "rev-parse", "--abbrev-ref", "HEAD"],
71
- stdout=subprocess.PIPE,
72
- check=True,
73
- ).stdout.strip()
74
-
75
- # Checkout the master branch
76
- subprocess.run(["git", "checkout", repo.get("master_branch", "master")], check=True)
77
-
78
- # Pull it from origin
79
- subprocess.run(
80
- ["git", "pull", repo.get("remote", "origin"), repo.get("master_branch", "master")], check=True
81
- )
82
-
83
- # Push it to a new stabilization branch
84
- if arguments.version:
85
- subprocess.run(
86
- [
87
- "git",
88
- "push",
89
- *(["--force"] if arguments.force else []),
90
- repo.get("remote", "origin"),
91
- f"HEAD:{arguments.version}",
92
- ],
93
- check=not arguments.force,
94
- )
95
-
96
- version = arguments.version
97
- branch_name = "new-version" if version is None else f"new-version-{version}"
98
-
99
- # Checkout a new branch named new-version
100
- if arguments.force:
101
- subprocess.run(["git", "branch", "-D", branch_name]) # pylint: disable=subprocess-run-check
102
- subprocess.run(["git", "checkout", "-b", branch_name], check=True)
103
-
104
- # # # Do the changes for the new version # # #
105
-
106
- remotes = [r for r in mra.run(["git", "remote"], stdout=subprocess.PIPE).stdout.split() if r != ""]
107
- remote_branches = [
108
- b.strip()[len("remotes/") :]
109
- for b in mra.run(["git", "branch", "--all"], stdout=subprocess.PIPE).stdout.split()
110
- if b != "" and b.strip().startswith("remotes/")
111
- ]
112
- if "upstream" in remotes:
113
- remote_branches = [b[len("upstream") + 1 :] for b in remote_branches if b.startswith("upstream/")]
114
- elif "origin" in remotes:
115
- remote_branches = [b[len("origin") + 1 :] for b in remote_branches if b.startswith("origin/")]
116
- else:
117
- remote_branches = ["/".join(b.split("/")[1:]) for b in remote_branches]
118
-
119
- config = c2cciutils.get_config()
120
- branch_re = c2cciutils.compile_re(config["version"].get("branch_to_version_re", []))
121
- branches_match = [c2cciutils.match(b, branch_re) for b in remote_branches]
122
- version_branch = {m.groups()[0] if m.groups() else b: b for m, c, b in branches_match if m is not None}
123
-
124
- stabilization_branches = [
125
- version_branch.get(version, version) for version in mra.get_stabilization_versions(repo)
126
- ]
127
- modified_files = []
128
-
129
- if version:
130
- stabilization_branches.append(version)
131
-
132
- if os.path.exists("SECURITY.md"):
133
- modified_files.append("SECURITY.md")
134
- with mra.Edit("SECURITY.md") as security_md:
135
- security_md_lines = security_md.data.split("\n")
136
- index = -1
137
- for i, line in enumerate(security_md_lines):
138
- if line.startswith("| "):
139
- index = i
140
-
141
- new_line = f"| {version} | {arguments.supported_until} |"
142
- if arguments.upstream_supported_until:
143
- new_line += f" {arguments.upstream_supported_until} |"
144
-
145
- security_md.data = "\n".join(
146
- [*security_md_lines[: index + 1], new_line, *security_md_lines[index + 1 :]]
147
- )
148
-
149
- stabilization_branches_with_master = [*stabilization_branches, repo.get("master_branch", "master")]
150
-
151
- for labels in mra.gh_json("label", ["name"], "list"):
152
- if (
153
- labels["name"].startswith("backport ")
154
- and labels["name"].replace("backport ", "") not in stabilization_branches_with_master
155
- ):
156
- mra.gh("label", "delete", labels["name"], "--yes")
157
-
158
- for branch in stabilization_branches_with_master:
159
- mra.gh(
160
- "label",
161
- "create",
162
- "--force",
163
- f"backport {branch}",
164
- "--color=5aed94",
165
- f"--description=Backport the pull request to the '{branch}' branch",
166
- )
167
-
168
- if os.path.exists(".github/renovate.json5"):
169
- modified_files.append(".github/renovate.json5")
170
- with mra.EditRenovateConfig(".github/renovate.json5") as renovate_config:
171
- if stabilization_branches:
172
- if "baseBranches: " in renovate_config.data:
173
- renovate_config.data = re.sub(
174
- r"(.*baseBranches: )\[[^\]]*\](.*)",
175
- rf"\1{json.dumps(stabilization_branches_with_master)}\2",
176
- renovate_config.data,
177
- )
178
- else:
179
- renovate_config.add(
180
- f"baseBranches: {json.dumps(stabilization_branches_with_master)},\n", "baseBranches"
181
- )
182
-
183
- if stabilization_branches and os.path.exists(".github/workflows/audit.yaml"):
184
- modified_files.append(".github/workflows/audit.yaml")
185
- with mra.EditYAML(".github/workflows/audit.yaml") as yaml:
186
- for job in yaml["jobs"].values():
187
- matrix = job.get("strategy", {}).get("matrix", {})
188
- if "include" in matrix and version:
189
- new_include = dict(matrix["include"][-1])
190
- new_include["branch"] = version
191
- matrix["include"].append(new_include)
192
-
193
- if "branch" in matrix and stabilization_branches:
194
- yaml_stabilization_branches = ruamel.yaml.comments.CommentedSeq(stabilization_branches)
195
- yaml_stabilization_branches._yaml_add_comment( # pylint: disable=protected-access
196
- [
197
- ruamel.yaml.CommentToken("\n\n", ruamel.yaml.error.CommentMark(0), None),
198
- None,
199
- None,
200
- None,
201
- ],
202
- len(stabilization_branches) - 1,
203
- )
204
- job["strategy"]["matrix"]["branch"] = yaml_stabilization_branches
205
-
206
- # Commit the changes
207
- message = f"Create the new version '{version}'" if version else "Update the supported versions"
208
- if os.path.exists(".pre-commit-config.yaml"):
209
- subprocess.run(["pre-commit", "run", "--color=never", "--all-files"], check=False)
210
- subprocess.run(["git", "add", *modified_files], check=True)
211
- subprocess.run(["git", "commit", f"--message={message}"], check=True)
212
-
213
- # Push it
214
- subprocess.run(
215
- [
216
- "git",
217
- "push",
218
- *(["--force"] if arguments.force else []),
219
- repo.get("remote", "origin"),
220
- branch_name,
221
- ],
222
- check=True,
223
- )
224
-
225
- # Create a pull request
226
- url = mra.gh(
227
- "pr",
228
- "create",
229
- f"--title={message}",
230
- "--body=",
231
- f"--head={branch_name}",
232
- f"--base={repo.get('master_branch', 'master')}",
233
- ).strip()
234
-
235
- # Go back to your old branch
236
- subprocess.run(["git", "checkout", old_branch_name, "--"], check=True)
237
-
238
- if url:
239
- subprocess.run([mra.get_browser(), url], check=True)
240
- else:
241
- mra.gh("browse")
242
-
243
-
244
- if __name__ == "__main__":
245
- main()
@@ -1,37 +0,0 @@
1
- c2cciutils/__init__.py,sha256=-J6_XPwyZ3Xbix6AhmAONbltSf9okJsXwQvBj6TuP_U,13353
2
- c2cciutils/applications-versions.yaml,sha256=kVic4dGlYdvoNvHFzygTDLhDamjJwG5yYf0wKQ13CpI,225
3
- c2cciutils/applications.yaml,sha256=yn0XRi08cS29A_jXPofcBPxsGBv7PEBliztjRC3WtfM,504
4
- c2cciutils/applications_definition.py,sha256=inAh3vJitu3S9n62Ntv6N-avNUQlUd5FatNvDq4VpxM,1305
5
- c2cciutils/branches.graphql,sha256=UZrj1RO-H527M1SKqWm1VnkWtNsuKTnPTf4BCU2YcOU,358
6
- c2cciutils/commits.graphql,sha256=3HAuIEig5V7j1L-6mqBaOkiTD3Fb8_gl1ilpZjPJf74,308
7
- c2cciutils/configuration.py,sha256=LwJw-l9zB3zy7LtjjrWHFATIuxdRVMJZ-mLbTbFiug8,17062
8
- c2cciutils/default_branch.graphql,sha256=CaP3rRsNiyg_7RvqbMk0tOJr0aqWd8cOeSV-ZKgvKY4,131
9
- c2cciutils/env.py,sha256=daNqFY-6-X7PGuPz5OaN634KqYtsawj9Dj-Zt-bxctw,3338
10
- c2cciutils/lib/docker.py,sha256=ULklJgc-8sfy1vI8p_cbYYEq_u73BKNIGorMxzEKA2I,5663
11
- c2cciutils/lib/oidc.py,sha256=M03Avmwy45u3xzP8uhyTXJ8mY5BEonsXKeO-S1DC_JI,6297
12
- c2cciutils/package-lock.json,sha256=XX70MuDXo2F1Vyd7Xf4a6N6-ZR5soa5GIR6xM88949Q,13406
13
- c2cciutils/package.json,sha256=_Yakhc-qWuTMDkLBQRQ0EQJ5ERSQM3UgWlO7HqbBLQE,134
14
- c2cciutils/publish.py,sha256=MJok8QdlfxdwNF5UfPIqRzteNubDFS_BKQe1Scbumy8,17261
15
- c2cciutils/schema-applications.json,sha256=Tus-s9NB7uwKhTrQwhWQM4_oJygF_yHUqShtZhN1IxE,1551
16
- c2cciutils/schema.json,sha256=G0WbvTVn9zdDjilFr28uZqF7zDVADl7uQus12_TVnSs,14559
17
- c2cciutils/scripts/__init__.py,sha256=YvySYhMJ9eUqBc9FgH6hNbZHbTU25D7z6FIbYJiRW_U,34
18
- c2cciutils/scripts/clean.py,sha256=oB4A4TvSNoo7vGWzy5m0p2QDyGM-ix0FepxPIqqNlyg,2987
19
- c2cciutils/scripts/docker_logs.py,sha256=m8ETno2N1mqh-xHvmCi2zxXfvX_vc14dgsOqqMsxpdQ,1790
20
- c2cciutils/scripts/docker_versions_gen.py,sha256=yp1I_UqxyIABKxHek3q3UYWh0YR8tqKWzliC2kqZOa0,1315
21
- c2cciutils/scripts/download_applications.py,sha256=x0SPm4MCWCIYMp1AWekIpbOicwUixitEAJ69quMq698,4488
22
- c2cciutils/scripts/env.py,sha256=YZwV39D_vQ454ytHByI84gXP6VrtTW3eM8MdFLUBCw0,363
23
- c2cciutils/scripts/k8s/__init__.py,sha256=m8_lELJYRmzbAW7aGZL_T3tNwuFi1t8ot8F271HZp9E,67
24
- c2cciutils/scripts/k8s/db.py,sha256=GK1tzzyCqrCyIJzcBdIXjyNJUXrBPFNa-9fdtwxyrlU,3268
25
- c2cciutils/scripts/k8s/install.py,sha256=OIQ8KHA3Pst2pjO2E-J5FYNaBHW-i-fqCXlAUcG1tw0,933
26
- c2cciutils/scripts/k8s/logs.py,sha256=-xJYu8BBUmSmMrPEwiTBKZjJBRyIlMp1depCB04_NWs,2655
27
- c2cciutils/scripts/k8s/wait.py,sha256=zgPToNMN42qRTAq3RyzCApOqxOPJmmVUsIqbEuXCdiE,5689
28
- c2cciutils/scripts/main.py,sha256=DfljDzEGCWwP7FZG0RRZaXD6PmOVaXMJjnNBQ0-rAWM,785
29
- c2cciutils/scripts/pin_pipenv.py,sha256=jBTwlolcEL0MUyq6VYzO-adkcL1gqN7B3kBb3UjTo2k,2150
30
- c2cciutils/scripts/publish.py,sha256=wzXSBn_60DzMJVdO8i2NjjO6Vwg6L6efH_T6ZR6LRsU,20513
31
- c2cciutils/scripts/trigger_image_update.py,sha256=HQI4vm9kwInr_6zbLcwjIpX_Rs05woGvbMes8okhvZk,2780
32
- c2cciutils/scripts/version.py,sha256=Srk22CQudxT8JixS-ZBsxeJvWryYVzN_NiWpcJvgrWI,8931
33
- c2cciutils-1.8.0.dev64.dist-info/LICENSE,sha256=K_e76Y2cY12AHvtanvNmIEJ0nWsNh_WFMDK020TxMcY,1307
34
- c2cciutils-1.8.0.dev64.dist-info/METADATA,sha256=qdlbRTFef_Xv_nCiwWZ97XY8mgCLHIZDPG2MpSeYm20,17720
35
- c2cciutils-1.8.0.dev64.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
36
- c2cciutils-1.8.0.dev64.dist-info/entry_points.txt,sha256=54llpn1q67tS78NbLwA8rwSDWnEQ6aE3FaqMN0ctNN8,918
37
- c2cciutils-1.8.0.dev64.dist-info/RECORD,,
@@ -1,18 +0,0 @@
1
- [console_scripts]
2
- c2cciutils=c2cciutils.scripts.main:main
3
- c2cciutils-checks=c2cciutils.scripts.env:main
4
- c2cciutils-clean=c2cciutils.scripts.clean:main
5
- c2cciutils-docker-logs=c2cciutils.scripts.docker_logs:main
6
- c2cciutils-docker-versions-gen=c2cciutils.scripts.docker_versions_gen:main
7
- c2cciutils-download-applications=c2cciutils.scripts.download_applications:main
8
- c2cciutils-env=c2cciutils.scripts.env:main
9
- c2cciutils-google-calendar=c2cciutils.publish:main_calendar
10
- c2cciutils-k8s-db=c2cciutils.scripts.k8s.db:main
11
- c2cciutils-k8s-install=c2cciutils.scripts.k8s.install:main
12
- c2cciutils-k8s-logs=c2cciutils.scripts.k8s.logs:main
13
- c2cciutils-k8s-wait=c2cciutils.scripts.k8s.wait:main
14
- c2cciutils-pin-pipenv=c2cciutils.scripts.pin_pipenv:main
15
- c2cciutils-publish=c2cciutils.scripts.publish:main
16
- c2cciutils-trigger-image-update=c2cciutils.scripts.trigger_image_update:main
17
- c2cciutils-version=c2cciutils.scripts.version:main
18
-