c2cciutils 1.7.0.dev334__tar.gz → 1.7.0.dev338__tar.gz
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-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/PKG-INFO +3 -24
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/README.md +2 -17
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/__init__.py +0 -212
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/configuration.py +28 -466
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/publish.py +3 -3
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/schema.json +0 -217
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/scripts/main.py +0 -5
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/pyproject.toml +4 -16
- c2cciutils-1.7.0.dev334/c2cciutils/audit.py +0 -175
- c2cciutils-1.7.0.dev334/c2cciutils/pr_checks.py +0 -286
- c2cciutils-1.7.0.dev334/c2cciutils/scripts/audit.py +0 -41
- c2cciutils-1.7.0.dev334/c2cciutils/scripts/pr_checks.py +0 -78
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/LICENSE +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/applications-versions.yaml +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/applications.yaml +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/applications_definition.py +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/branches.graphql +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/commits.graphql +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/default_branch.graphql +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/env.py +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/lib/docker.py +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/lib/oidc.py +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/package-lock.json +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/package.json +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/schema-applications.json +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/scripts/__init__.py +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/scripts/clean.py +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/scripts/docker_logs.py +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/scripts/docker_versions_gen.py +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/scripts/download_applications.py +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/scripts/env.py +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/scripts/k8s/__init__.py +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/scripts/k8s/db.py +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/scripts/k8s/install.py +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/scripts/k8s/logs.py +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/scripts/k8s/wait.py +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/scripts/pin_pipenv.py +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/scripts/publish.py +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/scripts/trigger_image_update.py +0 -0
- {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.0.dev338}/c2cciutils/scripts/version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: c2cciutils
|
|
3
|
-
Version: 1.7.0.
|
|
3
|
+
Version: 1.7.0.dev338
|
|
4
4
|
Summary: Common utilities for Camptocamp CI
|
|
5
5
|
Home-page: https://github.com/camptocamp/c2cciutils
|
|
6
6
|
License: FreeBSD
|
|
@@ -27,23 +27,17 @@ Provides-Extra: pr-checks
|
|
|
27
27
|
Provides-Extra: publish
|
|
28
28
|
Provides-Extra: publish-plugins
|
|
29
29
|
Provides-Extra: version
|
|
30
|
-
Requires-Dist: Markdown (>=3.0,<4.0)
|
|
31
30
|
Requires-Dist: PyYAML (>=6.0.0,<7.0.0)
|
|
32
|
-
Requires-Dist: codespell (==2.3.0) ; extra == "pr-checks"
|
|
33
31
|
Requires-Dist: debian-inspector (>=31.0.0,<32.0.0)
|
|
34
32
|
Requires-Dist: defusedxml (>=0.0.0,<1.0.0)
|
|
35
33
|
Requires-Dist: google-api-python-client (>=2.0.0,<3.0.0) ; extra == "publish"
|
|
36
34
|
Requires-Dist: google-auth-httplib2 (>=0.0.0,<1.0.0) ; extra == "publish"
|
|
37
35
|
Requires-Dist: google-auth-oauthlib (>=1.0.0,<2.0.0) ; extra == "publish"
|
|
38
36
|
Requires-Dist: id (>=1.0.0,<2.0.0) ; extra == "publish"
|
|
39
|
-
Requires-Dist: markdown-table (>=2020.0.0,<2021.0.0)
|
|
40
37
|
Requires-Dist: multi-repo-automation (>=1.0.0,<2.0.0) ; extra == "version"
|
|
41
|
-
Requires-Dist: python-magic (>=0.0.0,<1.0.0)
|
|
42
38
|
Requires-Dist: requests (>=2.0.0,<3.0.0)
|
|
43
39
|
Requires-Dist: ruamel.yaml (>=0.0.0,<1.0.0)
|
|
44
40
|
Requires-Dist: security-md (>=0.0.0,<1.0.0)
|
|
45
|
-
Requires-Dist: toml (>=0.0.0,<1.0.0)
|
|
46
|
-
Requires-Dist: tomlkit (>=0.0.0,<1.0.0) ; extra == "publish"
|
|
47
41
|
Requires-Dist: twine (>=5.0.0,<6.0.0) ; extra == "publish"
|
|
48
42
|
Project-URL: Repository, https://github.com/camptocamp/c2cciutils
|
|
49
43
|
Description-Content-Type: text/markdown
|
|
@@ -60,15 +54,6 @@ see the [documentation](https://github.com/camptocamp/c2cciutils/wiki/Publishing
|
|
|
60
54
|
When we create a tag by default with the `changelog` workflow a release is created on GitHub, a changelog is
|
|
61
55
|
generated and added to the release.
|
|
62
56
|
|
|
63
|
-
## Security
|
|
64
|
-
|
|
65
|
-
The security is managed by the `c2cciutils-audit` command with Snyk, it will audit the dependencies of the project on every
|
|
66
|
-
stabilization branches, if possible a pull request is created automatically to update the dependencies.
|
|
67
|
-
|
|
68
|
-
When we publish a Docker image the generated image is monitored by Snyk, this means that Snyk will search
|
|
69
|
-
for all the dependencies and send the list to the Snyk web site to be monitored.
|
|
70
|
-
We also do a test of the image and log the result (This will never cause the build to fail).
|
|
71
|
-
|
|
72
57
|
## Checks
|
|
73
58
|
|
|
74
59
|
C2C CI utils will no more provide a tool to do a check of the project, this is replaced by `pre-commit`,
|
|
@@ -103,21 +88,16 @@ workflow will delete the workflows older than 500 days.
|
|
|
103
88
|
|
|
104
89
|
C2cciutils make easier to have those workflows in a project:
|
|
105
90
|
|
|
106
|
-
- `audit.yaml`: Audit the stabilization branches of the application against vulnerabilities in the python and node dependency
|
|
107
91
|
- `auto-review.yaml`: Auto review the Renovate pull requests
|
|
108
92
|
- `backport.yaml`: Trigger the backports (work with labels)
|
|
109
93
|
- `clean.yaml`: Clean the Docker images related on a deleted feature branch
|
|
110
94
|
- `main.yaml`: Main workflow especially with the c2cciutils-checks command
|
|
111
|
-
- `changelog.yaml`: Generate the changelog and create the release on GitHub
|
|
112
|
-
- `delete-old-workflows-run.yaml`: Delete the old workflows
|
|
113
|
-
- `pr-checks.yaml`: Run the checks on the pull requests
|
|
114
95
|
|
|
115
96
|
All the provided commands used in the workflow:
|
|
116
97
|
|
|
117
98
|
- `c2cciutils`: some generic tools.
|
|
118
99
|
- `c2cciutils-version`: Create a new version of the project.
|
|
119
|
-
- `c2cciutils-
|
|
120
|
-
- `c2cciutils-audit`: Do the audit, the main difference with checks is that it can change between runs on the same code.
|
|
100
|
+
- `c2cciutils-env`: Print some environment information.
|
|
121
101
|
- `c2cciutils-publish`: Publish the project.
|
|
122
102
|
- `c2cciutils-clean`: Delete Docker images on Docker Hub after corresponding branch have been deleted.
|
|
123
103
|
|
|
@@ -178,7 +158,6 @@ You can override the configuration with the file `ci/config.yaml`.
|
|
|
178
158
|
At the base of the configuration you have:
|
|
179
159
|
|
|
180
160
|
- `version`: Contains some regular expressions to find the versions branches and tags, and to convert them into application versions.
|
|
181
|
-
- `audit`: The audit configuration, see `c2cciutils/audit.py` for more information.
|
|
182
161
|
- `publish`: The publishing configuration, see `c2cciutils/publish.py` for more information.
|
|
183
162
|
|
|
184
163
|
Many actions can be disabled by setting the corresponding configuration part to `False`.
|
|
@@ -289,7 +268,7 @@ To make it working in the `Dockerfile` you should have in the `poetry` stage:
|
|
|
289
268
|
|
|
290
269
|
```Dockerfile
|
|
291
270
|
ENV POETRY_DYNAMIC_VERSIONING_BYPASS=dev
|
|
292
|
-
RUN poetry export --extras=checks --extras=publish --
|
|
271
|
+
RUN poetry export --extras=checks --extras=publish --output=requirements.txt \
|
|
293
272
|
&& poetry export --with=dev --output=requirements-dev.txt
|
|
294
273
|
```
|
|
295
274
|
|
|
@@ -10,15 +10,6 @@ see the [documentation](https://github.com/camptocamp/c2cciutils/wiki/Publishing
|
|
|
10
10
|
When we create a tag by default with the `changelog` workflow a release is created on GitHub, a changelog is
|
|
11
11
|
generated and added to the release.
|
|
12
12
|
|
|
13
|
-
## Security
|
|
14
|
-
|
|
15
|
-
The security is managed by the `c2cciutils-audit` command with Snyk, it will audit the dependencies of the project on every
|
|
16
|
-
stabilization branches, if possible a pull request is created automatically to update the dependencies.
|
|
17
|
-
|
|
18
|
-
When we publish a Docker image the generated image is monitored by Snyk, this means that Snyk will search
|
|
19
|
-
for all the dependencies and send the list to the Snyk web site to be monitored.
|
|
20
|
-
We also do a test of the image and log the result (This will never cause the build to fail).
|
|
21
|
-
|
|
22
13
|
## Checks
|
|
23
14
|
|
|
24
15
|
C2C CI utils will no more provide a tool to do a check of the project, this is replaced by `pre-commit`,
|
|
@@ -53,21 +44,16 @@ workflow will delete the workflows older than 500 days.
|
|
|
53
44
|
|
|
54
45
|
C2cciutils make easier to have those workflows in a project:
|
|
55
46
|
|
|
56
|
-
- `audit.yaml`: Audit the stabilization branches of the application against vulnerabilities in the python and node dependency
|
|
57
47
|
- `auto-review.yaml`: Auto review the Renovate pull requests
|
|
58
48
|
- `backport.yaml`: Trigger the backports (work with labels)
|
|
59
49
|
- `clean.yaml`: Clean the Docker images related on a deleted feature branch
|
|
60
50
|
- `main.yaml`: Main workflow especially with the c2cciutils-checks command
|
|
61
|
-
- `changelog.yaml`: Generate the changelog and create the release on GitHub
|
|
62
|
-
- `delete-old-workflows-run.yaml`: Delete the old workflows
|
|
63
|
-
- `pr-checks.yaml`: Run the checks on the pull requests
|
|
64
51
|
|
|
65
52
|
All the provided commands used in the workflow:
|
|
66
53
|
|
|
67
54
|
- `c2cciutils`: some generic tools.
|
|
68
55
|
- `c2cciutils-version`: Create a new version of the project.
|
|
69
|
-
- `c2cciutils-
|
|
70
|
-
- `c2cciutils-audit`: Do the audit, the main difference with checks is that it can change between runs on the same code.
|
|
56
|
+
- `c2cciutils-env`: Print some environment information.
|
|
71
57
|
- `c2cciutils-publish`: Publish the project.
|
|
72
58
|
- `c2cciutils-clean`: Delete Docker images on Docker Hub after corresponding branch have been deleted.
|
|
73
59
|
|
|
@@ -128,7 +114,6 @@ You can override the configuration with the file `ci/config.yaml`.
|
|
|
128
114
|
At the base of the configuration you have:
|
|
129
115
|
|
|
130
116
|
- `version`: Contains some regular expressions to find the versions branches and tags, and to convert them into application versions.
|
|
131
|
-
- `audit`: The audit configuration, see `c2cciutils/audit.py` for more information.
|
|
132
117
|
- `publish`: The publishing configuration, see `c2cciutils/publish.py` for more information.
|
|
133
118
|
|
|
134
119
|
Many actions can be disabled by setting the corresponding configuration part to `False`.
|
|
@@ -239,7 +224,7 @@ To make it working in the `Dockerfile` you should have in the `poetry` stage:
|
|
|
239
224
|
|
|
240
225
|
```Dockerfile
|
|
241
226
|
ENV POETRY_DYNAMIC_VERSIONING_BYPASS=dev
|
|
242
|
-
RUN poetry export --extras=checks --extras=publish --
|
|
227
|
+
RUN poetry export --extras=checks --extras=publish --output=requirements.txt \
|
|
243
228
|
&& poetry export --with=dev --output=requirements-dev.txt
|
|
244
229
|
```
|
|
245
230
|
|
|
@@ -11,7 +11,6 @@ import sys
|
|
|
11
11
|
from re import Match, Pattern
|
|
12
12
|
from typing import Any, Optional, TypedDict, cast
|
|
13
13
|
|
|
14
|
-
import magic
|
|
15
14
|
import requests
|
|
16
15
|
import ruamel.yaml
|
|
17
16
|
|
|
@@ -126,8 +125,6 @@ def get_config() -> c2cciutils.configuration.Configuration:
|
|
|
126
125
|
|
|
127
126
|
default_config = {
|
|
128
127
|
"publish": publish_config,
|
|
129
|
-
"pr-checks": c2cciutils.configuration.PULL_REQUEST_CHECKS_DEFAULT,
|
|
130
|
-
"audit": c2cciutils.configuration.AUDIT_DEFAULT,
|
|
131
128
|
}
|
|
132
129
|
merge(default_config, config)
|
|
133
130
|
|
|
@@ -411,160 +408,6 @@ def graphql(query_file: str, variables: dict[str, Any], default: Any = None) ->
|
|
|
411
408
|
return cast(dict[str, Any], json_response["data"])
|
|
412
409
|
|
|
413
410
|
|
|
414
|
-
def get_git_files_mime(
|
|
415
|
-
mime_type: Optional[list[str]] = None,
|
|
416
|
-
extensions: Optional[list[str]] = None,
|
|
417
|
-
ignore_patterns_re: Optional[list[str]] = None,
|
|
418
|
-
) -> list[str]:
|
|
419
|
-
"""
|
|
420
|
-
Get list of paths from git with all the files that have the specified mime type.
|
|
421
|
-
|
|
422
|
-
Arguments:
|
|
423
|
-
mime_type: The considered MIME type
|
|
424
|
-
extensions: The considered extensions
|
|
425
|
-
ignore_patterns_re: A list of regular expressions of files that we should ignore
|
|
426
|
-
"""
|
|
427
|
-
if mime_type is None:
|
|
428
|
-
mime_type = ["text/x-python", "text/x-script.python"]
|
|
429
|
-
if extensions is None:
|
|
430
|
-
extensions = [".py"]
|
|
431
|
-
ignore_patterns_compiled = [re.compile(p) for p in ignore_patterns_re or []]
|
|
432
|
-
result = []
|
|
433
|
-
|
|
434
|
-
for filename in subprocess.check_output(["git", "ls-files"]).decode().strip().split("\n"):
|
|
435
|
-
if os.path.isfile(filename) and (
|
|
436
|
-
os.path.splitext(filename)[1] in extensions or magic.from_file(filename, mime=True) in mime_type
|
|
437
|
-
):
|
|
438
|
-
accept = True
|
|
439
|
-
for pattern in ignore_patterns_compiled:
|
|
440
|
-
if pattern.search(filename):
|
|
441
|
-
accept = False
|
|
442
|
-
break
|
|
443
|
-
if accept:
|
|
444
|
-
result.append(filename)
|
|
445
|
-
return result
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
def get_branch(branch: Optional[str], master_branch: str = "master") -> str:
|
|
449
|
-
"""
|
|
450
|
-
Get the branch name.
|
|
451
|
-
|
|
452
|
-
Arguments:
|
|
453
|
-
branch: The forced to use branch name
|
|
454
|
-
master_branch: The master branch name, can be used as default value
|
|
455
|
-
|
|
456
|
-
Return the branch name
|
|
457
|
-
"""
|
|
458
|
-
if branch is not None:
|
|
459
|
-
return branch
|
|
460
|
-
try:
|
|
461
|
-
branch = (
|
|
462
|
-
subprocess.run(["git", "rev-parse", "--abbrev-ref", "HEAD"], check=True, stdout=subprocess.PIPE)
|
|
463
|
-
.stdout.decode()
|
|
464
|
-
.strip()
|
|
465
|
-
)
|
|
466
|
-
except subprocess.CalledProcessError as exception:
|
|
467
|
-
print(f"Error getting branch: {exception}")
|
|
468
|
-
branch = "HEAD"
|
|
469
|
-
|
|
470
|
-
if branch == "HEAD":
|
|
471
|
-
branch = os.environ.get("GITHUB_HEAD_REF", master_branch)
|
|
472
|
-
assert branch is not None
|
|
473
|
-
return branch
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
def get_based_on_master(
|
|
477
|
-
repo: list[str],
|
|
478
|
-
override_current_branch: Optional[str],
|
|
479
|
-
master_branch: str,
|
|
480
|
-
config: c2cciutils.configuration.Configuration,
|
|
481
|
-
) -> bool:
|
|
482
|
-
"""
|
|
483
|
-
Check that we are not on a release branch (to avoid errors in versions check).
|
|
484
|
-
|
|
485
|
-
This function will check the last 20 commits in current branch,
|
|
486
|
-
and for each other branch (max 50) check if any commit in last 10 commits is the current one.
|
|
487
|
-
|
|
488
|
-
Arguments:
|
|
489
|
-
repo: The repository [<organization>, <name>]
|
|
490
|
-
override_current_branch: The branch to use instead of the current one
|
|
491
|
-
master_branch: The master branch name
|
|
492
|
-
config: The full configuration
|
|
493
|
-
"""
|
|
494
|
-
if os.environ.get("GITHUB_REF", "").startswith("refs/tags/"):
|
|
495
|
-
# The tags are never consider as based on master
|
|
496
|
-
return False
|
|
497
|
-
current_branch = get_branch(override_current_branch, master_branch)
|
|
498
|
-
if current_branch == master_branch:
|
|
499
|
-
return True
|
|
500
|
-
branches_re = compile_re(config["version"].get("branch_to_version_re", []))
|
|
501
|
-
if does_match(current_branch, branches_re):
|
|
502
|
-
return False
|
|
503
|
-
if os.environ.get("GITHUB_BASE_REF"):
|
|
504
|
-
return os.environ.get("GITHUB_BASE_REF") == master_branch
|
|
505
|
-
commits_repository_json = graphql(
|
|
506
|
-
"commits.graphql", {"name": repo[1], "owner": repo[0], "branch": current_branch}
|
|
507
|
-
).get("repository", {})
|
|
508
|
-
commits_json = (
|
|
509
|
-
commits_repository_json.get("ref", {}).get("target", {}).get("history", {}).get("nodes", [])
|
|
510
|
-
if commits_repository_json.get("ref")
|
|
511
|
-
else []
|
|
512
|
-
)
|
|
513
|
-
branches_json = [
|
|
514
|
-
branch
|
|
515
|
-
for branch in (
|
|
516
|
-
graphql("branches.graphql", {"name": repo[1], "owner": repo[0]})["repository"]["refs"]["nodes"]
|
|
517
|
-
)
|
|
518
|
-
if branch["name"] != current_branch and does_match(branch["name"], branches_re)
|
|
519
|
-
]
|
|
520
|
-
based_branch = master_branch
|
|
521
|
-
found = False
|
|
522
|
-
for commit in commits_json:
|
|
523
|
-
for branch in branches_json:
|
|
524
|
-
commits = [
|
|
525
|
-
branch_commit
|
|
526
|
-
for branch_commit in branch["target"]["history"]["nodes"]
|
|
527
|
-
if commit["oid"] == branch_commit["oid"]
|
|
528
|
-
]
|
|
529
|
-
if commits:
|
|
530
|
-
based_branch = branch["name"]
|
|
531
|
-
found = True
|
|
532
|
-
break
|
|
533
|
-
if found:
|
|
534
|
-
break
|
|
535
|
-
return based_branch == master_branch
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
def get_codespell_command(config: c2cciutils.configuration.Configuration, fix: bool = False) -> list[str]:
|
|
539
|
-
"""
|
|
540
|
-
Get the codespell command.
|
|
541
|
-
|
|
542
|
-
Arguments:
|
|
543
|
-
config: The full configuration
|
|
544
|
-
fix: If we should fix the errors
|
|
545
|
-
"""
|
|
546
|
-
codespell_config = config.get("codespell", {})
|
|
547
|
-
codespell_config = codespell_config if isinstance(codespell_config, dict) else {}
|
|
548
|
-
command = ["codespell"]
|
|
549
|
-
if fix:
|
|
550
|
-
command.append("--write-changes")
|
|
551
|
-
for spell_ignore_file in (
|
|
552
|
-
".github/spell-ignore-words.txt",
|
|
553
|
-
"spell-ignore-words.txt",
|
|
554
|
-
".spell-ignore-words.txt",
|
|
555
|
-
):
|
|
556
|
-
if os.path.exists(spell_ignore_file):
|
|
557
|
-
command.append(f"--ignore-words={spell_ignore_file}")
|
|
558
|
-
break
|
|
559
|
-
dictionaries = codespell_config.get(
|
|
560
|
-
"internal_dictionaries", c2cciutils.configuration.CODESPELL_DICTIONARIES_DEFAULT
|
|
561
|
-
)
|
|
562
|
-
if dictionaries:
|
|
563
|
-
command.append("--builtin=" + ",".join(dictionaries))
|
|
564
|
-
command += codespell_config.get("arguments", c2cciutils.configuration.CODESPELL_ARGUMENTS_DEFAULT)
|
|
565
|
-
return command
|
|
566
|
-
|
|
567
|
-
|
|
568
411
|
def snyk_exec() -> tuple[str, dict[str, str]]:
|
|
569
412
|
"""Get the Snyk cli executable path."""
|
|
570
413
|
if not os.path.exists(os.path.join(os.path.dirname(__file__), "node_modules")):
|
|
@@ -580,58 +423,3 @@ def snyk_exec() -> tuple[str, dict[str, str]]:
|
|
|
580
423
|
subprocess.run(["snyk", "config", "set", f"org={env['SNYK_ORG']}"], check=True, env=env)
|
|
581
424
|
|
|
582
425
|
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "node_modules/snyk/bin/snyk"), env
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
def create_pull_request_if_needed(
|
|
586
|
-
current_branch: str,
|
|
587
|
-
new_branch: str,
|
|
588
|
-
commit_message: str,
|
|
589
|
-
pull_request_extra_arguments: Optional[list[str]] = None,
|
|
590
|
-
) -> bool:
|
|
591
|
-
"""
|
|
592
|
-
Create a pull request if there are changes.
|
|
593
|
-
"""
|
|
594
|
-
if pull_request_extra_arguments is None:
|
|
595
|
-
pull_request_extra_arguments = ["--fill"]
|
|
596
|
-
|
|
597
|
-
diff_proc = subprocess.run(["git", "diff", "--quiet"]) # pylint: disable=subprocess-run-check
|
|
598
|
-
if diff_proc.returncode != 0:
|
|
599
|
-
print("::group::Diff")
|
|
600
|
-
sys.stdout.flush()
|
|
601
|
-
sys.stderr.flush()
|
|
602
|
-
subprocess.run(["git", "diff"], check=True)
|
|
603
|
-
print("::endgroup::")
|
|
604
|
-
|
|
605
|
-
git_hash = subprocess.run(
|
|
606
|
-
["git", "rev-parse", "HEAD"], check=True, stdout=subprocess.PIPE, encoding="utf-8"
|
|
607
|
-
).stdout.strip()
|
|
608
|
-
subprocess.run(["git", "checkout", "-b", new_branch], check=True)
|
|
609
|
-
subprocess.run(["git", "add", "--all"], check=True)
|
|
610
|
-
subprocess.run(["git", "commit", f"--message={commit_message}"], check=True)
|
|
611
|
-
if os.environ.get("TEST") != "TRUE":
|
|
612
|
-
subprocess.run(
|
|
613
|
-
["git", "push", "--force", "origin", new_branch],
|
|
614
|
-
check=True,
|
|
615
|
-
)
|
|
616
|
-
env = os.environ.copy()
|
|
617
|
-
if "GH_TOKEN" not in env:
|
|
618
|
-
if "GITHUB_TOKEN" in env:
|
|
619
|
-
env["GH_TOKEN"] = env["GITHUB_TOKEN"]
|
|
620
|
-
else:
|
|
621
|
-
env["GH_TOKEN"] = str(c2cciutils.gopass("gs/ci/github/token/gopass"))
|
|
622
|
-
subprocess.run(
|
|
623
|
-
[
|
|
624
|
-
"gh",
|
|
625
|
-
"pr",
|
|
626
|
-
"create",
|
|
627
|
-
f"--base={current_branch}",
|
|
628
|
-
*pull_request_extra_arguments,
|
|
629
|
-
],
|
|
630
|
-
check=True,
|
|
631
|
-
env=env,
|
|
632
|
-
)
|
|
633
|
-
else:
|
|
634
|
-
subprocess.run(["git", "reset", "--hard"], check=True)
|
|
635
|
-
subprocess.run(["git", "checkout", git_hash], check=True)
|
|
636
|
-
|
|
637
|
-
return diff_proc.returncode != 0
|