c2cciutils 1.7.0.dev334__tar.gz → 1.7.1__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.

Files changed (40) hide show
  1. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/PKG-INFO +4 -24
  2. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/README.md +2 -17
  3. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/__init__.py +0 -212
  4. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/applications-versions.yaml +1 -1
  5. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/configuration.py +28 -466
  6. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/publish.py +3 -3
  7. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/schema.json +0 -217
  8. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/scripts/main.py +0 -5
  9. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/scripts/publish.py +2 -2
  10. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/pyproject.toml +6 -18
  11. c2cciutils-1.7.0.dev334/c2cciutils/audit.py +0 -175
  12. c2cciutils-1.7.0.dev334/c2cciutils/pr_checks.py +0 -286
  13. c2cciutils-1.7.0.dev334/c2cciutils/scripts/audit.py +0 -41
  14. c2cciutils-1.7.0.dev334/c2cciutils/scripts/pr_checks.py +0 -78
  15. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/LICENSE +0 -0
  16. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/applications.yaml +0 -0
  17. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/applications_definition.py +0 -0
  18. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/branches.graphql +0 -0
  19. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/commits.graphql +0 -0
  20. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/default_branch.graphql +0 -0
  21. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/env.py +0 -0
  22. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/lib/docker.py +0 -0
  23. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/lib/oidc.py +0 -0
  24. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/package-lock.json +0 -0
  25. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/package.json +0 -0
  26. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/schema-applications.json +0 -0
  27. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/scripts/__init__.py +0 -0
  28. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/scripts/clean.py +0 -0
  29. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/scripts/docker_logs.py +0 -0
  30. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/scripts/docker_versions_gen.py +0 -0
  31. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/scripts/download_applications.py +0 -0
  32. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/scripts/env.py +0 -0
  33. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/scripts/k8s/__init__.py +0 -0
  34. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/scripts/k8s/db.py +0 -0
  35. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/scripts/k8s/install.py +0 -0
  36. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/scripts/k8s/logs.py +0 -0
  37. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/scripts/k8s/wait.py +0 -0
  38. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/scripts/pin_pipenv.py +0 -0
  39. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/c2cciutils/scripts/trigger_image_update.py +0 -0
  40. {c2cciutils-1.7.0.dev334 → c2cciutils-1.7.1}/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.dev334
3
+ Version: 1.7.1
4
4
  Summary: Common utilities for Camptocamp CI
5
5
  Home-page: https://github.com/camptocamp/c2cciutils
6
6
  License: FreeBSD
@@ -20,6 +20,7 @@ Classifier: Programming Language :: Python :: 3.9
20
20
  Classifier: Programming Language :: Python :: 3.10
21
21
  Classifier: Programming Language :: Python :: 3.11
22
22
  Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
23
24
  Classifier: Typing :: Typed
24
25
  Provides-Extra: audit
25
26
  Provides-Extra: checks
@@ -27,23 +28,17 @@ Provides-Extra: pr-checks
27
28
  Provides-Extra: publish
28
29
  Provides-Extra: publish-plugins
29
30
  Provides-Extra: version
30
- Requires-Dist: Markdown (>=3.0,<4.0)
31
31
  Requires-Dist: PyYAML (>=6.0.0,<7.0.0)
32
- Requires-Dist: codespell (==2.3.0) ; extra == "pr-checks"
33
32
  Requires-Dist: debian-inspector (>=31.0.0,<32.0.0)
34
33
  Requires-Dist: defusedxml (>=0.0.0,<1.0.0)
35
34
  Requires-Dist: google-api-python-client (>=2.0.0,<3.0.0) ; extra == "publish"
36
35
  Requires-Dist: google-auth-httplib2 (>=0.0.0,<1.0.0) ; extra == "publish"
37
36
  Requires-Dist: google-auth-oauthlib (>=1.0.0,<2.0.0) ; extra == "publish"
38
37
  Requires-Dist: id (>=1.0.0,<2.0.0) ; extra == "publish"
39
- Requires-Dist: markdown-table (>=2020.0.0,<2021.0.0)
40
38
  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
39
  Requires-Dist: requests (>=2.0.0,<3.0.0)
43
40
  Requires-Dist: ruamel.yaml (>=0.0.0,<1.0.0)
44
41
  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
42
  Requires-Dist: twine (>=5.0.0,<6.0.0) ; extra == "publish"
48
43
  Project-URL: Repository, https://github.com/camptocamp/c2cciutils
49
44
  Description-Content-Type: text/markdown
@@ -60,15 +55,6 @@ see the [documentation](https://github.com/camptocamp/c2cciutils/wiki/Publishing
60
55
  When we create a tag by default with the `changelog` workflow a release is created on GitHub, a changelog is
61
56
  generated and added to the release.
62
57
 
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
58
  ## Checks
73
59
 
74
60
  C2C CI utils will no more provide a tool to do a check of the project, this is replaced by `pre-commit`,
@@ -103,21 +89,16 @@ workflow will delete the workflows older than 500 days.
103
89
 
104
90
  C2cciutils make easier to have those workflows in a project:
105
91
 
106
- - `audit.yaml`: Audit the stabilization branches of the application against vulnerabilities in the python and node dependency
107
92
  - `auto-review.yaml`: Auto review the Renovate pull requests
108
93
  - `backport.yaml`: Trigger the backports (work with labels)
109
94
  - `clean.yaml`: Clean the Docker images related on a deleted feature branch
110
95
  - `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
96
 
115
97
  All the provided commands used in the workflow:
116
98
 
117
99
  - `c2cciutils`: some generic tools.
118
100
  - `c2cciutils-version`: Create a new version of the project.
119
- - `c2cciutils-checks`: Run the checks on the code (those checks don't need any project dependencies).
120
- - `c2cciutils-audit`: Do the audit, the main difference with checks is that it can change between runs on the same code.
101
+ - `c2cciutils-env`: Print some environment information.
121
102
  - `c2cciutils-publish`: Publish the project.
122
103
  - `c2cciutils-clean`: Delete Docker images on Docker Hub after corresponding branch have been deleted.
123
104
 
@@ -178,7 +159,6 @@ You can override the configuration with the file `ci/config.yaml`.
178
159
  At the base of the configuration you have:
179
160
 
180
161
  - `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
162
  - `publish`: The publishing configuration, see `c2cciutils/publish.py` for more information.
183
163
 
184
164
  Many actions can be disabled by setting the corresponding configuration part to `False`.
@@ -289,7 +269,7 @@ To make it working in the `Dockerfile` you should have in the `poetry` stage:
289
269
 
290
270
  ```Dockerfile
291
271
  ENV POETRY_DYNAMIC_VERSIONING_BYPASS=dev
292
- RUN poetry export --extras=checks --extras=publish --extras=audit --output=requirements.txt \
272
+ RUN poetry export --extras=checks --extras=publish --output=requirements.txt \
293
273
  && poetry export --with=dev --output=requirements-dev.txt
294
274
  ```
295
275
 
@@ -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-checks`: Run the checks on the code (those checks don't need any project dependencies).
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 --extras=audit --output=requirements.txt \
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
@@ -1,4 +1,4 @@
1
1
  # https://docs.renovatebot.com/modules/datasource/#github-releases-datasource
2
2
  k3d-io/k3d: v5.7.4 # github-releases
3
- postgresql: 16.0.0 # helm - https://charts.bitnami.com/bitnami
3
+ postgresql: 16.0.6 # helm - https://charts.bitnami.com/bitnami
4
4
  helm/chart-releaser: v1.6.1 # github-releases