c2cciutils 1.7.0.dev165__tar.gz → 1.7.0.dev169__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.
Files changed (42) hide show
  1. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/PKG-INFO +1 -1
  2. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/__init__.py +17 -2
  3. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/configuration.py +122 -5
  4. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/pr_checks.py +1 -1
  5. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/pr_checks.py +1 -1
  6. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/publish.py +1 -0
  7. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/pyproject.toml +1 -1
  8. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/setup.py +1 -1
  9. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/LICENSE +0 -0
  10. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/README.md +0 -0
  11. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/applications-versions.yaml +0 -0
  12. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/applications.yaml +0 -0
  13. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/applications_definition.py +0 -0
  14. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/audit.py +0 -0
  15. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/branches.graphql +0 -0
  16. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/commits.graphql +0 -0
  17. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/default_branch.graphql +0 -0
  18. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/env.py +0 -0
  19. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/lib/docker.py +0 -0
  20. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/package-lock.json +0 -0
  21. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/package.json +0 -0
  22. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/publish.py +0 -0
  23. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/schema-applications.json +0 -0
  24. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/schema.json +0 -0
  25. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/__init__.py +0 -0
  26. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/audit.py +0 -0
  27. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/clean.py +0 -0
  28. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/docker_logs.py +0 -0
  29. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/docker_versions_gen.py +0 -0
  30. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/docker_versions_update.py +0 -0
  31. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/download_applications.py +0 -0
  32. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/env.py +0 -0
  33. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/k8s/__init__.py +0 -0
  34. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/k8s/db.py +0 -0
  35. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/k8s/install.py +0 -0
  36. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/k8s/logs.py +0 -0
  37. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/k8s/wait.py +0 -0
  38. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/main.py +0 -0
  39. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/pin_pipenv.py +0 -0
  40. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/trigger_image_update.py +0 -0
  41. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/scripts/version.py +0 -0
  42. {c2cciutils-1.7.0.dev165 → c2cciutils-1.7.0.dev169}/c2cciutils/security.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: c2cciutils
3
- Version: 1.7.0.dev165
3
+ Version: 1.7.0.dev169
4
4
  Summary: Common utilities for Camptocamp CI
5
5
  Home-page: https://github.com/camptocamp/c2cciutils
6
6
  License: FreeBSD
@@ -358,6 +358,19 @@ def add_authorization_header(headers: dict[str, str]) -> dict[str, str]:
358
358
  return headers
359
359
 
360
360
 
361
+ def check_response(response: requests.Response, raise_for_status: bool = True) -> Any:
362
+ """
363
+ Check the response and raise an exception if it's not ok.
364
+
365
+ Also print the X-Ratelimit- headers to get information about the rate limiting.
366
+ """
367
+ for header in response.headers:
368
+ if header.lower().startswith("x-ratelimit-"):
369
+ print(f"{header}: {response.headers[header]}")
370
+ if raise_for_status:
371
+ response.raise_for_status()
372
+
373
+
361
374
  def graphql(query_file: str, variables: dict[str, Any], default: Any = None) -> Any:
362
375
  """
363
376
  Get a graphql result from GitHub.
@@ -389,9 +402,11 @@ def graphql(query_file: str, variables: dict[str, Any], default: Any = None) ->
389
402
  ),
390
403
  timeout=int(os.environ.get("C2CCIUTILS_TIMEOUT", "30")),
391
404
  )
392
- if http_response.status_code == 401 and default is not None:
405
+ if http_response.status_code in (401, 403) and default is not None:
406
+ print(f"::warning::GraphQL error: {http_response.status_code}, use default value")
407
+ check_response(http_response, False)
393
408
  return default
394
- http_response.raise_for_status()
409
+ check_response(http_response)
395
410
  json_response = http_response.json()
396
411
 
397
412
  if "errors" in json_response:
@@ -61,6 +61,7 @@ class Audit(TypedDict, total=False):
61
61
  The audit Snyk configuration
62
62
 
63
63
  Aggregation type: oneOf
64
+ Subtype: "AuditSnykConfig"
64
65
  """
65
66
 
66
67
 
@@ -160,6 +161,7 @@ Audit with Snyk.
160
161
  The audit Snyk configuration
161
162
 
162
163
  Aggregation type: oneOf
164
+ Subtype: "AuditSnykConfig"
163
165
  """
164
166
 
165
167
 
@@ -292,6 +294,10 @@ DB_CONFIGURATION_DEFAULT: dict[str, Any] = {}
292
294
  """ Default value of the field path 'K8s configuration db' """
293
295
 
294
296
 
297
+ DISPATCH_CONFIG_DEFAULT: dict[str, Any] = {}
298
+ """ Default value of the field path 'Publish Docker config dispatch oneof0' """
299
+
300
+
295
301
  DOCKER_DISPATCH_EVENT_TYPE_DEFAULT = "image-update"
296
302
  """ Default value of the field path 'dispatch config event-type' """
297
303
 
@@ -333,6 +339,9 @@ DbConfiguration = TypedDict(
333
339
  # dispatch config.
334
340
  #
335
341
  # Send a dispatch event to an other repository
342
+ #
343
+ # default:
344
+ # {}
336
345
  DispatchConfig = TypedDict(
337
346
  "DispatchConfig",
338
347
  {
@@ -495,6 +504,10 @@ PUBLISH_DOCKER_SNYK_TEST_ARGS_DEFAULT = ["--app-vulns", "--severity-threshold=cr
495
504
  """ Default value of the field path 'Publish Docker config snyk test_args' """
496
505
 
497
506
 
507
+ PUBLISH_GOOGLE_CALENDAR_CONFIG_DEFAULT: dict[str, Any] = {}
508
+ """ Default value of the field path 'Publish Google calendar oneof0' """
509
+
510
+
498
511
  PUBLISH_GOOGLE_CALENDAR_DEFAULT: dict[str, Any] = {}
499
512
  """ Default value of the field path 'publish_google_calendar' """
500
513
 
@@ -507,6 +520,10 @@ PUBLISH_PIP_PACKAGE_GROUP_DEFAULT = "default"
507
520
  """ Default value of the field path 'publish pypi package group' """
508
521
 
509
522
 
523
+ PUBLISH_PYPI_CONFIG_DEFAULT: dict[str, Any] = {}
524
+ """ Default value of the field path 'publish pypi oneof0' """
525
+
526
+
510
527
  PUBLISH_PYPI_DEFAULT: dict[str, Any] = {}
511
528
  """ Default value of the field path 'publish_pypi' """
512
529
 
@@ -647,6 +664,7 @@ class Publish(TypedDict, total=False):
647
664
  The configuration used to publish on Docker
648
665
 
649
666
  Aggregation type: oneOf
667
+ Subtype: "PublishDockerConfig"
650
668
  """
651
669
 
652
670
  pypi: "PublishPypi"
@@ -659,6 +677,7 @@ class Publish(TypedDict, total=False):
659
677
  {}
660
678
 
661
679
  Aggregation type: oneOf
680
+ Subtype: "PublishPypiConfig"
662
681
  """
663
682
 
664
683
  helm: "PublishHelm"
@@ -668,6 +687,7 @@ class Publish(TypedDict, total=False):
668
687
  Configuration to publish Helm charts on GitHub release
669
688
 
670
689
  Aggregation type: oneOf
690
+ Subtype: "PublishHelmConfig"
671
691
  """
672
692
 
673
693
  google_calendar: "PublishGoogleCalendar"
@@ -680,6 +700,7 @@ class Publish(TypedDict, total=False):
680
700
  {}
681
701
 
682
702
  Aggregation type: oneOf
703
+ Subtype: "PublishGoogleCalendarConfig"
683
704
  """
684
705
 
685
706
 
@@ -690,6 +711,7 @@ Publish Docker.
690
711
  The configuration used to publish on Docker
691
712
 
692
713
  Aggregation type: oneOf
714
+ Subtype: "PublishDockerConfig"
693
715
  """
694
716
 
695
717
 
@@ -728,7 +750,7 @@ class PublishDockerConfig(TypedDict, total=False):
728
750
  - rebuild
729
751
  """
730
752
 
731
- dispatch: Union["DispatchConfig", Literal[False]]
753
+ dispatch: Union["DispatchConfig", "_PublishDockerConfigDispatchOneof1"]
732
754
  """
733
755
  Send a dispatch event to an other repository
734
756
 
@@ -736,6 +758,7 @@ class PublishDockerConfig(TypedDict, total=False):
736
758
  {}
737
759
 
738
760
  Aggregation type: oneOf
761
+ Subtype: "DispatchConfig"
739
762
  """
740
763
 
741
764
  snyk: "_PublishDockerConfigSnyk"
@@ -788,7 +811,7 @@ class PublishDockerRepository(TypedDict, total=False):
788
811
  """
789
812
 
790
813
 
791
- PublishGoogleCalendar = Union["PublishGoogleCalendarConfig", Literal[False]]
814
+ PublishGoogleCalendar = Union["PublishGoogleCalendarConfig", "_PublishGoogleCalendarOneof1"]
792
815
  """
793
816
  Publish Google calendar.
794
817
 
@@ -798,6 +821,7 @@ default:
798
821
  {}
799
822
 
800
823
  Aggregation type: oneOf
824
+ Subtype: "PublishGoogleCalendarConfig"
801
825
  """
802
826
 
803
827
 
@@ -806,6 +830,9 @@ class PublishGoogleCalendarConfig(TypedDict, total=False):
806
830
  Publish Google calendar config.
807
831
 
808
832
  The configuration to publish on Google Calendar
833
+
834
+ default:
835
+ {}
809
836
  """
810
837
 
811
838
  on: list[str]
@@ -826,6 +853,7 @@ publish helm.
826
853
  Configuration to publish Helm charts on GitHub release
827
854
 
828
855
  Aggregation type: oneOf
856
+ Subtype: "PublishHelmConfig"
829
857
  """
830
858
 
831
859
 
@@ -843,7 +871,7 @@ class PublishHelmConfig(TypedDict, total=False):
843
871
  """ The kind or version that should be published, tag, branch or value of the --version argument of the c2cciutils-publish script """
844
872
 
845
873
 
846
- PublishPypi = Union["PublishPypiConfig", Literal[False]]
874
+ PublishPypi = Union["PublishPypiConfig", "_PublishPypiOneof1"]
847
875
  """
848
876
  publish pypi.
849
877
 
@@ -853,6 +881,7 @@ default:
853
881
  {}
854
882
 
855
883
  Aggregation type: oneOf
884
+ Subtype: "PublishPypiConfig"
856
885
  """
857
886
 
858
887
 
@@ -861,6 +890,9 @@ class PublishPypiConfig(TypedDict, total=False):
861
890
  publish pypi config.
862
891
 
863
892
  Configuration to publish on pypi
893
+
894
+ default:
895
+ {}
864
896
  """
865
897
 
866
898
  packages: list["PublishPypiPackage"]
@@ -914,6 +946,7 @@ class PullRequestChecks(TypedDict, total=False):
914
946
  Check the pull request commits messages
915
947
 
916
948
  Aggregation type: oneOf
949
+ Subtype: "PullRequestChecksCommitsMessagesConfiguration"
917
950
  """
918
951
 
919
952
  commits_spell: "PullRequestChecksCommitsSpelling"
@@ -921,6 +954,7 @@ class PullRequestChecks(TypedDict, total=False):
921
954
  pull request checks commits spelling.
922
955
 
923
956
  Aggregation type: oneOf
957
+ Subtype: "PullRequestChecksCommitsSpellingConfiguration"
924
958
  """
925
959
 
926
960
  pull_request_spell: "PullRequestChecksPullRequestSpelling"
@@ -928,6 +962,7 @@ class PullRequestChecks(TypedDict, total=False):
928
962
  pull request checks pull request spelling.
929
963
 
930
964
  Aggregation type: oneOf
965
+ Subtype: "PullRequestChecksPullRequestSpellingConfiguration"
931
966
  """
932
967
 
933
968
  pull_request_labels: "PullRequestChecksRequestLabels"
@@ -952,6 +987,7 @@ pull request checks commits messages.
952
987
  Check the pull request commits messages
953
988
 
954
989
  Aggregation type: oneOf
990
+ Subtype: "PullRequestChecksCommitsMessagesConfiguration"
955
991
  """
956
992
 
957
993
 
@@ -1022,6 +1058,7 @@ PullRequestChecksCommitsSpelling = Union["PullRequestChecksCommitsSpellingConfig
1022
1058
  pull request checks commits spelling.
1023
1059
 
1024
1060
  Aggregation type: oneOf
1061
+ Subtype: "PullRequestChecksCommitsSpellingConfiguration"
1025
1062
  """
1026
1063
 
1027
1064
 
@@ -1045,6 +1082,7 @@ PullRequestChecksPullRequestSpelling = Union["PullRequestChecksPullRequestSpelli
1045
1082
  pull request checks pull request spelling.
1046
1083
 
1047
1084
  Aggregation type: oneOf
1085
+ Subtype: "PullRequestChecksPullRequestSpellingConfiguration"
1048
1086
  """
1049
1087
 
1050
1088
 
@@ -1105,6 +1143,34 @@ _PUBLISH_DOCKER_CONFIG_DISPATCH_DEFAULT: dict[str, Any] = {}
1105
1143
  """ Default value of the field path 'Publish Docker config dispatch' """
1106
1144
 
1107
1145
 
1146
+ _PUBLISH_DOCKER_CONFIG_DISPATCH_ONEOF1_DEFAULT: dict[str, Any] = {}
1147
+ """ Default value of the field path 'Publish Docker config dispatch oneof1' """
1148
+
1149
+
1150
+ _PUBLISH_DOCKER_SNYK_MONITOR_ARGS_ONEOF0_DEFAULT = ["--app-vulns"]
1151
+ """ Default value of the field path 'Publish Docker Snyk monitor args oneof0' """
1152
+
1153
+
1154
+ _PUBLISH_DOCKER_SNYK_MONITOR_ARGS_ONEOF1_DEFAULT = ["--app-vulns"]
1155
+ """ Default value of the field path 'Publish Docker Snyk monitor args oneof1' """
1156
+
1157
+
1158
+ _PUBLISH_DOCKER_SNYK_TEST_ARGS_ONEOF0_DEFAULT = ["--app-vulns", "--severity-threshold=critical"]
1159
+ """ Default value of the field path 'Publish Docker Snyk test args oneof0' """
1160
+
1161
+
1162
+ _PUBLISH_DOCKER_SNYK_TEST_ARGS_ONEOF1_DEFAULT = ["--app-vulns", "--severity-threshold=critical"]
1163
+ """ Default value of the field path 'Publish Docker Snyk test args oneof1' """
1164
+
1165
+
1166
+ _PUBLISH_GOOGLE_CALENDAR_ONEOF1_DEFAULT: dict[str, Any] = {}
1167
+ """ Default value of the field path 'Publish Google calendar oneof1' """
1168
+
1169
+
1170
+ _PUBLISH_PYPI_ONEOF1_DEFAULT: dict[str, Any] = {}
1171
+ """ Default value of the field path 'publish pypi oneof1' """
1172
+
1173
+
1108
1174
  class _PrintVersionsVersionsItem(TypedDict, total=False):
1109
1175
  cmd: list[str]
1110
1176
  """ The command that should be used """
@@ -1116,10 +1182,17 @@ class _PrintVersionsVersionsItem(TypedDict, total=False):
1116
1182
  """ Prefix added when we print the version """
1117
1183
 
1118
1184
 
1185
+ _PublishDockerConfigDispatchOneof1 = Literal[False]
1186
+ """
1187
+ default:
1188
+ {}
1189
+ """
1190
+
1191
+
1119
1192
  class _PublishDockerConfigSnyk(TypedDict, total=False):
1120
1193
  """Checks the published images with Snyk"""
1121
1194
 
1122
- monitor_args: Union[list[str], Literal[False]]
1195
+ monitor_args: Union["_PublishDockerSnykMonitorArgsOneof0", "_PublishDockerSnykMonitorArgsOneof1"]
1123
1196
  """
1124
1197
  Publish Docker Snyk monitor args.
1125
1198
 
@@ -1131,7 +1204,7 @@ class _PublishDockerConfigSnyk(TypedDict, total=False):
1131
1204
  Aggregation type: oneOf
1132
1205
  """
1133
1206
 
1134
- test_args: Union[list[str], Literal[False]]
1207
+ test_args: Union["_PublishDockerSnykTestArgsOneof0", "_PublishDockerSnykTestArgsOneof1"]
1135
1208
  """
1136
1209
  Publish Docker Snyk test args.
1137
1210
 
@@ -1145,6 +1218,50 @@ class _PublishDockerConfigSnyk(TypedDict, total=False):
1145
1218
  """
1146
1219
 
1147
1220
 
1221
+ _PublishDockerSnykMonitorArgsOneof0 = list[str]
1222
+ """
1223
+ default:
1224
+ - --app-vulns
1225
+ """
1226
+
1227
+
1228
+ _PublishDockerSnykMonitorArgsOneof1 = Literal[False]
1229
+ """
1230
+ default:
1231
+ - --app-vulns
1232
+ """
1233
+
1234
+
1235
+ _PublishDockerSnykTestArgsOneof0 = list[str]
1236
+ """
1237
+ default:
1238
+ - --app-vulns
1239
+ - --severity-threshold=critical
1240
+ """
1241
+
1242
+
1243
+ _PublishDockerSnykTestArgsOneof1 = Literal[False]
1244
+ """
1245
+ default:
1246
+ - --app-vulns
1247
+ - --severity-threshold=critical
1248
+ """
1249
+
1250
+
1251
+ _PublishGoogleCalendarOneof1 = Literal[False]
1252
+ """
1253
+ default:
1254
+ {}
1255
+ """
1256
+
1257
+
1258
+ _PublishPypiOneof1 = Literal[False]
1259
+ """
1260
+ default:
1261
+ {}
1262
+ """
1263
+
1264
+
1148
1265
  _VersionTransformItem = TypedDict(
1149
1266
  "_VersionTransformItem",
1150
1267
  {
@@ -264,7 +264,7 @@ def add_issue_link(github_event: dict[str, Any], **kwargs: Any) -> bool:
264
264
  timeout=int(os.environ.get("C2CCIUTILS_TIMEOUT", "30")),
265
265
  headers=c2cciutils.add_authorization_header({}),
266
266
  )
267
- comments_response.raise_for_status()
267
+ c2cciutils.check_response(comments_response)
268
268
  comments = comments_response.json()
269
269
 
270
270
  for comment in comments:
@@ -37,7 +37,7 @@ def main() -> None:
37
37
  timeout=int(os.environ.get("C2CCIUTILS_TIMEOUT", "30")),
38
38
  headers=c2cciutils.add_authorization_header({}),
39
39
  )
40
- commits_response.raise_for_status()
40
+ c2cciutils.check_response(commits_response)
41
41
  commits = commits_response.json()
42
42
 
43
43
  config = full_config["pr-checks"]
@@ -206,6 +206,7 @@ def main() -> None:
206
206
  headers=c2cciutils.add_authorization_header({}),
207
207
  timeout=int(os.environ.get("C2CCIUTILS_TIMEOUT", "30")),
208
208
  )
209
+ c2cciutils.check_response(security_response, False)
209
210
  if security_response.ok:
210
211
  security_text = security_response.text
211
212
  elif security_response.status_code != 404:
@@ -19,7 +19,7 @@ strict = true
19
19
 
20
20
  [tool.poetry]
21
21
  name = "c2cciutils"
22
- version = "1.7.0.dev165"
22
+ version = "1.7.0.dev169"
23
23
  description = "Common utilities for Camptocamp CI"
24
24
  readme = "README.md"
25
25
  authors = ["Camptocamp <info@camptocamp.com>"]
@@ -59,7 +59,7 @@ entry_points = \
59
59
 
60
60
  setup_kwargs = {
61
61
  'name': 'c2cciutils',
62
- 'version': '1.7.0.dev165',
62
+ 'version': '1.7.0.dev169',
63
63
  'description': 'Common utilities for Camptocamp CI',
64
64
  'long_description': '# C2C CI utils\n\n## Publishing\n\nThe main goals of C2C CI utils is to offer the commands and the workflows to have the following project structure:\n\nHave stabilization branches named by default `<major>.<minor>`.\nHave the release named by default `<major>.<minor>.<patch>`.\n\nWith C2C CI utils you can publish a python package and a Docker image from the same repository.\n\nThe default publishing are:\n\n- Push on the `<major>.<minor>` branch will publish Docker images.\n- Create the tag `<major>.<minor>.<patch>` will publish the Docker images, and the Python package.\n- Push on a feature branch (whatever other name) will publish the Docker images.\n- Delete a feature branch will delete the Docker images.\n- Push on the `master` branch will publish the Docker images with the master tag (Publishing a python package is also possible).\n- The version at the last line of the `SECURITY.md` of the `master` branch will be also published using the `latest` tag,\n this will respect the `tags` present in the configuration\n- In the `SECURITY.md` file of the `master` branch we can also add a column `Alternate Tag` to publish the Docker images with another tag,\n this will respect the `tags` present in the configuration (only for Docker).\n\nThe Docker images are published on Docker Hub and GitHub Container Registry.\n\nYou can run the publishing locally in dry-run mode:\n\n```bash\nGITHUB_REF=... c2cciutils-publish --dry-run ...\n```\n\n## Changelog\n\nWhen we create a tag by default with the `changelog` workflow a release is created on GitHub, a changelog is\ngenerated and added to the release.\n\n## Security\n\nThe security is managed by the `c2cciutils-audit` command with Snyk, it will audit the dependencies of the project on every\nstabilization branches, if possible a pull request is created automatically to update the dependencies.\n\nWhen we publish a Docker image the generated image is monitored by Snyk, this means that Snyk will search\nfor all the dependencies and send the list to the Snyk web site to be monitored.\nWe also do a test of the image and log the result (This will never cause the build to fail).\n\n## Checks\n\nC2C CI utils will no more provide a tool to do a check of the project, this is replaced by `pre-commit`,\na base configuration is provided in the example project.\n\n## Pull request checks\n\nA workflow is provided to run the checks on the pull requests, it will run the `c2cciutils-pr-checks` command.\n\n- Check that the commit message and the pull request title start with a capital letter.\n- Check that there aren\'t any spelling issue in the commit message and in the pull request title.\n- Add a message to the pull request with a link to the JIRA issue if the pull request branch name starts with\n `[a-zA-Z]+-[0-9]+-` or end with `-[a-zA-Z]+-[0-9]+`.\n\n## Dependencies\n\nIn the example project there is a basic Renovate configuration, it will update the dependencies of the project.\nThere is also a workflow to add a review on the Renovate pull requests to make the auto merge working on\nrepository that required a review.\n\n## Backports\n\nA workflow is provided to backport the pull requests on the stabilization branches, it will be triggered by\nadding a label named `backport <destination_branch>` on the pull request.\n\n## Old workflows\n\nGitHub will retain all the old workflows, so we need to delete them, the `delete-old-workflows-run`\nworkflow will delete the workflows older than 500 days.\n\n## Workflows\n\nC2cciutils make easier to have those workflows in a project:\n\n- `audit.yaml`: Audit the stabilization branches of the application against vulnerabilities in the python and node dependency\n- `auto-review.yaml`: Auto review the Renovate pull requests\n- `backport.yaml`: Trigger the backports (work with labels)\n- `clean.yaml`: Clean the Docker images related on a deleted feature branch\n- `main.yaml`: Main workflow especially with the c2cciutils-checks command\n- `changelog.yaml`: Generate the changelog and create the release on GitHub\n- `delete-old-workflows-run.yaml`: Delete the old workflows\n- `pr-checks.yaml`: Run the checks on the pull requests\n\nAll the provided commands used in the workflow:\n\n- `c2cciutils`: some generic tools.\n- `c2cciutils-version`: Create a new version of the project.\n- `c2cciutils-checks`: Run the checks on the code (those checks don\'t need any project dependencies).\n- `c2cciutils-audit`: Do the audit, the main difference with checks is that it can change between runs on the same code.\n- `c2cciutils-publish`: Publish the project.\n- `c2cciutils-clean`: Delete Docker images on Docker Hub after corresponding branch have been deleted.\n\n## Utilities\n\nThe following utilities are provided:\n\n- `c2cciutils`: some generic tools.\n- `c2cciutils-download-applications`: Download the applications with version managed by Renovate, see below.\n- `c2cciutils-docker-logs`: Display the logs of the application in Docker (compose).\n- `c2cciutils-k8s-install`: Install a k3d / k3s cluster, see below.\n- `c2cciutils-k8s-logs`: Display the logs of the application in the k8s cluster, see below.\n- `c2cciutils-k8s-db`: Create a database in the k8s cluster, see below.\n- `c2cciutils-k8s-wait`: Wait that the application started correctly in the cluster, see below.\n- `c2cciutils-docker-versions-gen`: Generate the Docker package versions file (`ci/dpkg-versions.yaml`), see below.\n- `c2cciutils-pin-pipenv`: Display all the dependencies that\'s in the `Pipenv.lock` but not in the `Pipenv` to be able to pin them.\n- `c2cciutils-trigger-image-update`: Trigger the ArgoCD repository about image update on the CI (automatically done in the publishing).\n- `c2cciutils-google-calendar`: Tool to test the Google credentials for calendar API and refresh them if needed. See `c2cciutils-google-calendar -h` for more information.\n\n## New project\n\nThe content of `example-project` can be a good base for a new project.\n\n## New version\n\nRequirements: the right version (>= 1.6) of `c2cciutils` should be installed with the `version` extra.\n\nTo create a new minor version you just should run `c2cciutils-version --version=<version>`.\n\nYou are welcome to run `c2cciutils-version --help` to see what\'s it\'s done.\n\nNote that it didn\'t create a tag, you should do it manually.\n\nTo create a patch version you should just create tag.\n\n## Secrets\n\nIn the CI we need to have the following secrets::\n\n- `HAS_SECRETS` to be set to \'HAS_SECRETS\', to avoid error errors from external\n pull requests, already set globally on Camptocamp organization.\n- `GOPASS_CI_GITHUB_TOKEN` and `CI_GPG_PRIVATE_KEY` required to initialize the gopass password store,\n the secrets exists in the Camptocamp organization but not shared on all project, then you should add\n your project to the shared list.\n\n## Use locally, in the projects that use c2cciutils\n\nInstall it: `python3 -m pip install --user --requirement ci/requirements.txt`\nDry run publish: `GITHUB_REF=... c2cciutils-publish --dry-run ...`\n\n## Configuration\n\nYou can get the current configuration with `c2cciutils --get-config`, the default configuration depends on your project.\nNote that it didn\'t contain the default defined the schema and visible in the [generated documentation](./config.md).\n\nYou can override the configuration with the file `ci/config.yaml`.\n\nAt the base of the configuration you have:\n\n- `version`: Contains some regular expressions to find the versions branches and tags, and to convert them into application versions.\n- `audit`: The audit configuration, see `c2cciutils/audit.py` for more information.\n- `publish`: The publishing configuration, see `c2cciutils/publish.py` for more information.\n\nMany actions can be disabled by setting the corresponding configuration part to `False`.\n\n## SECURITY.md\n\nThe `SECURITY.md` file should contain the security policy of the repository, especially the end of\nsupport dates.\n\nFor compatibility with `c2cciutils` it should contain an array with at least the columns\n`Version` and `Supported Until`. The `Version` column will contain the concerned version.\nThe `Supported Until` will contain the date of end of support `dd/mm/yyyy`.\nIt can also contain the following sentences:\n\n- `Unsupported`: no longer supported => no audit, no rebuild.\n- `Best effort`: the support is ended, it is still rebuilt and audited, but this can be stopped without any notice.\n- `To be defined`: not yet released or the date will be set related of another project release date (like for GeoMapFish).\n\nSee also [GitHub Documentation](https://docs.github.com/en/github/managing-security-vulnerabilities/adding-a-security-policy-to-your-repository)\n\n## IDE\n\nThe IDE should be configured as:\n\n- using `black` and `isort` without any arguments,\n- using the `editorconfig` configuration.\n\n### VScode\n\n- Recommend extensions to work well with c2cciutils:\n - [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) And use EditorConfig\n - [shell-format](https://marketplace.visualstudio.com/items?itemName=foxundermoon.shell-format) With the configuration\n `"shellformat.flag": "-bn"`.\n - [Better TOML](https://marketplace.visualstudio.com/items?itemName=bodil.prettier-toml)\n- Other recommend extensions:\n - [hadolint](https://marketplace.visualstudio.com/items?itemName=exiasr.hadolint)\n - [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker)\n\nSelect a formatter:\n\n- `CTRL+MAJ+P`\n- Format document With...\n- Configure Default Formatter...\n- Select the formatter\n\n## Publishing\n\n### To pypi\n\nThe config is like this:\n\n```yaml\nversions:\n # List of kinds of versions you want to publish, that can be:\n # rebuild (specified with --type),\n # version_tag, version_branch, feature_branch, feature_tag (for pull request)\n```\n\nIt we have a `setup.py` file, we will be in legacy mode:\nWhen publishing, the version computed from arguments or `GITHUB_REF` is put in environment variable `VERSION`, thus you should use it in `setup.py`, example:\n\n```python\nVERSION = os.environ.get("VERSION", "1.0.0")\n```\n\nAlso we consider that we use `poetry` with [poetry-dynamic-versioning](https://pypi.org/project/poetry-dynamic-versioning/) to manage the version, and [poetry-plugin-tweak-dependencies-version](https://pypi.org/project/poetry-plugin-tweak-dependencies-version/) to manage the dependencies versions.\n\nExample of configuration:\n\n```toml\n[tool.poetry-dynamic-versioning]\nenable = true\nvcs = "git"\npattern = "^(?P<base>\\\\d+(\\\\.\\\\d+)*)"\nformat-jinja = """\n{%- if env.get("VERSION_TYPE") == "version_branch" -%}\n{{serialize_pep440(bump_version(base, 1 if env.get("IS_MASTER") == "TRUE" else 2), dev=distance)}}\n{%- elif distance == 0 -%}\n{{serialize_pep440(base)}}\n{%- else -%}\n{{serialize_pep440(bump_version(base), dev=distance)}}\n{%- endif -%}\n"""\n\n```\n\nNote that we can access to the environment variables `VERSION`,`VERSION_TYPE` and `IS_MASTER`.\n\nThen by default:\n\n- Tag with `1.2.3` => release `1.2.3`\n- Commit on feature branch just do a validation\n- Commit on `master` branch after the tag 1.3.0 => release `1.4.0.dev1`\n- Commit on `1.3` branch after the tag 1.3.0 => release `1.3.1.dev1`\n\nTo make it working in the `Dockerfile` you should have in the `poetry` stage:\n\n```Dockerfile\nENV POETRY_DYNAMIC_VERSIONING_BYPASS=dev\nRUN poetry export --extras=checks --extras=publish --extras=audit --output=requirements.txt \\\n && poetry export --with=dev --output=requirements-dev.txt\n```\n\nAnd in the `run` stage\n\n```Dockerfile\nARG VERSION=dev\nRUN --mount=type=cache,target=/root/.cache \\\n POETRY_DYNAMIC_VERSIONING_BYPASS=${VERSION} python3 -m pip install --disable-pip-version-check --no-deps --editable=.\n```\n\nAnd in the `Makefile`:\n\n```Makefile\nVERSION = $(strip $(shell poetry version --short))\n\n.PHONY: build\nbuild: ## Build the Docker images\n docker build --build-arg=VERSION=$(VERSION) --tag=$(GITHUB_REPOSITORY) .\n```\n\n### To Docker registry\n\nThe config is like this:\n\n```yaml\nlatest: True\nimages:\n - # The base name of the image we want to publish\n name:\nrepository:\n <internal_name>:\n # The fqdn name of the server if not Docker hub\n server:\n # List of kinds of versions you want to publish, that can be: rebuild (specified using --type),\n # version_tag, version_branch, feature_branch, feature_tag (for pull request)\n version:\n # List of tags we want to publish interpreted with `template(version=version)`\n # e.g. if you use `{version}-lite` when you publish the version `1.2.3` the source tag\n # (that should be built by the application build) is `latest-lite`, and it will be published\n # with the tag `1.2.3-lite`.\n tags:\n # If your images are published by different jobs you can separate them in different groups\n # and publish them with `c2cciutils-publish --group=<group>`\n group:\n```\n\nBy default, the last line of the `SECURITY.md` file will be published (`docker`) with the tag\n`latest`. Set `latest` to `False` to disable it.\n\nWith the `c2cciutils-clean` the images on Docker hub for `feature_branch` will be removed on branch removing.\n\n## Download applications\n\nIn case some executables or applications from GitHub releases or any other URLs are required on the CI host\nand are not handled by any dependency manager, we provide a set of tools to install them and manage upgrades\nthrough Renovate.\n\nCreate an application file (e.-g. `applications.yaml`) with:\n\n```yaml\n# yaml-language-server: $schema=https://raw.githubusercontent.com/camptocamp/c2cciutils/master/c2cciutils/schema-applications.json\n\n# Application from GitHub release\n<organization>/<project>:\n get-file-name: <file name present in the release>\n to-file-name: <The file name you want to create in ~/.local/bin>\n finish-command: # The command you want to run after the file is downloaded\n - - chmod # To be executable (usually required)\n - +x\n - <to-file-name>\n - - <to-file-name> # Print the version of the application\n - --version\n# Application from GitHub release in a tar file (or tar.gz)\n<organization>/<project>:\n get-file-name: <file name present in the release>\n type: tar\n tar-file-name: <The file name available in the tar file>\n to-file-name: <The file name you want to create in ~/.local/bin>\n finish-command: [...] # The command you want to run after the file is downloaded\n# Application from an URL\n<application reference name>:\n url-pattern: <The URL used to download the application>\n to-file-name: <The file name you want to create in ~/.local/bin>\n finish-command: [...] # The command you want to run after the file is downloaded\n```\n\nIn the attributes `url-pattern`, `get-file-name` you can use the following variables:\n\n- `{version}`: The version of the application present in the version file.\n- `{version_quote}`: The URL encoded version.\n- `{short_version}`: The version without the `v` prefix.\n\nThe `applications-versions.yaml` file is a map of applications and their versions.\n\nAdd in your Renovate configuration:\n\n```json5\n regexManagers: [\n {\n fileMatch: [\'^applications-versions.yaml$\'],\n matchStrings: [\n \'(?<depName>[^\\\\s]+): (?<currentValue>[^\\\\s]+) # (?<datasource>[^\\\\s]+)\',\n ],\n },\n ],\n```\n\nNow you need to call `c2cciutils-download-applications --applications-file=applications.yaml --versions-file=applications-version.yaml`\nto install required applications on CI host before using them (an already installed application is installed only if needed).\n\n## Use Renovate to trigger a new build instead of the legacy rebuild\n\nRun the command `c2cciutils-docker-versions-gen camptocamp/image[:tag]` to generate a file that is a kind of package lock of the Debian packages in the file `ci/dpkg-versions.yaml`.\n\nAdd in your renovate configuration:\n\n```javascript\n regexManagers: [\n {\n fileMatch: [\'^ci/dpkg-versions.yaml$\'],\n matchStrings: [" *(?<depName>[^\'\\\\s]+): \'?(?<currentValue>[^\'\\\\s/]*[0-9][^\'\\\\s/]*)\'?"],\n datasourceTemplate: \'repology\',\n versioningTemplate: \'loose\',\n },\n ],\n```\n\nWhen a new version of a Debian package will be available:\n\n- Renovate will automatically open a pull request to update the file `ci/dpkg-versions.yaml`.\n- And the continuous integration will build a new fresh Docker image with latest versions of all Debian packages.\n\n## Kubernetes\n\nC2cciutils provide some commands for Kubernetes.\n\nYou can define a workflow like that:\n\n```yaml\n- name: Install k3s/k3d (Kubernetes cluster)\n run: c2cciutils-k8s-install\n\n- name: Create a database to do the tests\n run: c2cciutils-k8s-db --script=<my_script>.sql\n\n- name: Install the application in the Kubernetes cluster\n run: kubectl apply -f <my_application>.yaml\n\n- name: Wait that the application is ready\n run: c2cciutils-k8s-wait\n- name: Print the application status and logs\n run: c2cciutils-k8s-logs\n if: always()\n\n- name: Uninstall the application\n run: kubectl delete -f <my_application>.yaml || true\n\n- name: Cleanup the database\n run: c2cciutils-k8s-db --cleanup\n```\n\n`c2cciutils-k8s-install` can be configured in the `ci/config.yaml` file, in section `k8s/k3d/install-commands`, default is:\n\n```yaml\n- - k3d\n cluster\n create\n test-cluster\n --no-lb\n --no-rollback\n```\n\nSee also: [K3d cluster create documentation](https://k3d.io/v4.4.8/usage/commands/k3d_cluster_create/).\n\n`c2cciutils-k8s-db` can be configured in the `ci/config.yaml` file, in section `k8s/db/chart-options`, default is:\n\n```yaml\npersistence.enabled: \'false\'\ntls.enabled: \'true\'\ntls.autoGenerated: \'true\'\npostgresqlPassword: mySuperTestingPassword\nvolumePermissions.enabled: \'true\'\n```\n\nSee also: [Parameters documentations](https://github.com/bitnami/charts/tree/master/bitnami/postgresql#parameters).\n\n## Contributing\n\nInstall the pre-commit hooks:\n\n```bash\npip install pre-commit\npre-commit install --allow-missing-config\n```\n',
65
65
  'author': 'Camptocamp',