c2cciutils 1.6.24.dev28__tar.gz → 1.7.0__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.
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/LICENSE +1 -1
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/PKG-INFO +24 -60
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/README.md +16 -44
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/__init__.py +0 -220
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/applications-versions.yaml +2 -2
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/applications_definition.py +17 -15
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/configuration.py +249 -446
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/env.py +0 -7
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/lib/docker.py +1 -2
- c2cciutils-1.7.0/c2cciutils/lib/oidc.py +186 -0
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/package-lock.json +159 -96
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/package.json +1 -1
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/publish.py +13 -18
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/schema-applications.json +2 -2
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/schema.json +4 -230
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/scripts/clean.py +0 -1
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/scripts/docker_versions_gen.py +0 -1
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/scripts/download_applications.py +0 -2
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/scripts/k8s/wait.py +2 -2
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/scripts/main.py +2 -10
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/scripts/publish.py +13 -4
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/scripts/trigger_image_update.py +0 -1
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/scripts/version.py +0 -1
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/pyproject.toml +23 -40
- c2cciutils-1.6.24.dev28/c2cciutils/audit.py +0 -233
- c2cciutils-1.6.24.dev28/c2cciutils/pr_checks.py +0 -285
- c2cciutils-1.6.24.dev28/c2cciutils/scripts/audit.py +0 -41
- c2cciutils-1.6.24.dev28/c2cciutils/scripts/docker_versions_update.py +0 -85
- c2cciutils-1.6.24.dev28/c2cciutils/scripts/pr_checks.py +0 -78
- c2cciutils-1.6.24.dev28/c2cciutils/security.py +0 -112
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/applications.yaml +0 -0
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/branches.graphql +0 -0
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/commits.graphql +0 -0
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/default_branch.graphql +0 -0
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/scripts/__init__.py +0 -0
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/scripts/docker_logs.py +0 -0
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/scripts/env.py +0 -0
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/scripts/k8s/__init__.py +0 -0
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/scripts/k8s/db.py +0 -0
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/scripts/k8s/install.py +0 -0
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/scripts/k8s/logs.py +0 -0
- {c2cciutils-1.6.24.dev28 → c2cciutils-1.7.0}/c2cciutils/scripts/pin_pipenv.py +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: c2cciutils
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.0
|
|
4
4
|
Summary: Common utilities for Camptocamp CI
|
|
5
5
|
Home-page: https://github.com/camptocamp/c2cciutils
|
|
6
6
|
License: FreeBSD
|
|
7
7
|
Keywords: ci
|
|
8
8
|
Author: Camptocamp
|
|
9
9
|
Author-email: info@camptocamp.com
|
|
10
|
-
Requires-Python: >=3.9
|
|
10
|
+
Requires-Python: >=3.9,<4.0
|
|
11
11
|
Classifier: Development Status :: 5 - Production/Stable
|
|
12
12
|
Classifier: Environment :: Console
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
@@ -16,8 +16,10 @@ Classifier: License :: Other/Proprietary License
|
|
|
16
16
|
Classifier: Operating System :: OS Independent
|
|
17
17
|
Classifier: Programming Language :: Python
|
|
18
18
|
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
20
|
Classifier: Programming Language :: Python :: 3.10
|
|
20
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
23
|
Classifier: Typing :: Typed
|
|
22
24
|
Provides-Extra: audit
|
|
23
25
|
Provides-Extra: checks
|
|
@@ -25,28 +27,18 @@ Provides-Extra: pr-checks
|
|
|
25
27
|
Provides-Extra: publish
|
|
26
28
|
Provides-Extra: publish-plugins
|
|
27
29
|
Provides-Extra: version
|
|
28
|
-
Requires-Dist: Markdown (>=3.0.0,<4.0.0)
|
|
29
30
|
Requires-Dist: PyYAML (>=6.0.0,<7.0.0)
|
|
30
|
-
Requires-Dist: certifi
|
|
31
|
-
Requires-Dist: codespell (==2.2.6) ; extra == "pr-checks"
|
|
32
|
-
Requires-Dist: cryptography
|
|
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
|
-
Requires-Dist:
|
|
39
|
-
Requires-Dist:
|
|
40
|
-
Requires-Dist: markdown-table (>=2020.0.0,<2021.0.0)
|
|
41
|
-
Requires-Dist: multi-repo-automation (>=0.0.0,<1.0.0) ; extra == "version"
|
|
42
|
-
Requires-Dist: python-magic (>=0.0.0,<1.0.0)
|
|
36
|
+
Requires-Dist: id (>=1.0.0,<2.0.0) ; extra == "publish"
|
|
37
|
+
Requires-Dist: multi-repo-automation (>=1.0.0,<2.0.0) ; extra == "version"
|
|
43
38
|
Requires-Dist: requests (>=2.0.0,<3.0.0)
|
|
44
39
|
Requires-Dist: ruamel.yaml (>=0.0.0,<1.0.0)
|
|
45
|
-
Requires-Dist:
|
|
46
|
-
Requires-Dist:
|
|
47
|
-
Requires-Dist: twine (>=4.0.0,<5.0.0) ; extra == "publish"
|
|
48
|
-
Requires-Dist: urllib3 (>=2.0.0,<3.0.0)
|
|
49
|
-
Requires-Dist: zipp (>=3.0.0,<4.0.0)
|
|
40
|
+
Requires-Dist: security-md (>=0.0.0,<1.0.0)
|
|
41
|
+
Requires-Dist: twine (>=5.0.0,<6.0.0) ; extra == "publish"
|
|
50
42
|
Project-URL: Repository, https://github.com/camptocamp/c2cciutils
|
|
51
43
|
Description-Content-Type: text/markdown
|
|
52
44
|
|
|
@@ -54,47 +46,14 @@ Description-Content-Type: text/markdown
|
|
|
54
46
|
|
|
55
47
|
## Publishing
|
|
56
48
|
|
|
57
|
-
The main goals of C2C CI utils is to offer the commands
|
|
58
|
-
|
|
59
|
-
Have stabilization branches named by default `<major>.<minor>`.
|
|
60
|
-
Have the release named by default `<major>.<minor>.<patch>`.
|
|
61
|
-
|
|
62
|
-
With C2C CI utils you can publish a python package and a Docker image from the same repository.
|
|
63
|
-
|
|
64
|
-
The default publishing are:
|
|
65
|
-
|
|
66
|
-
- Push on the `<major>.<minor>` branch will publish Docker images.
|
|
67
|
-
- Create the tag `<major>.<minor>.<patch>` will publish the Docker images, and the Python package.
|
|
68
|
-
- Push on a feature branch (whatever other name) will publish the Docker images.
|
|
69
|
-
- Delete a feature branch will delete the Docker images.
|
|
70
|
-
- Push on the `master` branch will publish the Docker images with the master tag (Publishing a python package is also possible).
|
|
71
|
-
- The version at the last line of the `SECURITY.md` of the `master` branch will be also published using the `latest` tag,
|
|
72
|
-
this will respect the `tags` present in the configuration
|
|
73
|
-
- 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,
|
|
74
|
-
this will respect the `tags` present in the configuration (only for Docker).
|
|
75
|
-
|
|
76
|
-
The Docker images are published on Docker Hub and GitHub Container Registry.
|
|
77
|
-
|
|
78
|
-
You can run the publishing locally in dry-run mode:
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
GITHUB_REF=... c2cciutils-publish --dry-run ...
|
|
82
|
-
```
|
|
49
|
+
The main goals of C2C CI utils is to offer the commands to publish the project,
|
|
50
|
+
see the [documentation](https://github.com/camptocamp/c2cciutils/wiki/Publishing).
|
|
83
51
|
|
|
84
52
|
## Changelog
|
|
85
53
|
|
|
86
54
|
When we create a tag by default with the `changelog` workflow a release is created on GitHub, a changelog is
|
|
87
55
|
generated and added to the release.
|
|
88
56
|
|
|
89
|
-
## Security
|
|
90
|
-
|
|
91
|
-
The security is managed by the `c2cciutils-audit` command with Snyk, it will audit the dependencies of the project on every
|
|
92
|
-
stabilization branches, if possible a pull request is created automatically to update the dependencies.
|
|
93
|
-
|
|
94
|
-
When we publish a Docker image the generated image is monitored by Snyk, this means that Snyk will search
|
|
95
|
-
for all the dependencies and send the list to the Snyk web site to be monitored.
|
|
96
|
-
We also do a test of the image and log the result (This will never cause the build to fail).
|
|
97
|
-
|
|
98
57
|
## Checks
|
|
99
58
|
|
|
100
59
|
C2C CI utils will no more provide a tool to do a check of the project, this is replaced by `pre-commit`,
|
|
@@ -129,21 +88,16 @@ workflow will delete the workflows older than 500 days.
|
|
|
129
88
|
|
|
130
89
|
C2cciutils make easier to have those workflows in a project:
|
|
131
90
|
|
|
132
|
-
- `audit.yaml`: Audit the stabilization branches of the application against vulnerabilities in the python and node dependency
|
|
133
91
|
- `auto-review.yaml`: Auto review the Renovate pull requests
|
|
134
92
|
- `backport.yaml`: Trigger the backports (work with labels)
|
|
135
93
|
- `clean.yaml`: Clean the Docker images related on a deleted feature branch
|
|
136
94
|
- `main.yaml`: Main workflow especially with the c2cciutils-checks command
|
|
137
|
-
- `changelog.yaml`: Generate the changelog and create the release on GitHub
|
|
138
|
-
- `delete-old-workflows-run.yaml`: Delete the old workflows
|
|
139
|
-
- `pr-checks.yaml`: Run the checks on the pull requests
|
|
140
95
|
|
|
141
96
|
All the provided commands used in the workflow:
|
|
142
97
|
|
|
143
98
|
- `c2cciutils`: some generic tools.
|
|
144
99
|
- `c2cciutils-version`: Create a new version of the project.
|
|
145
|
-
- `c2cciutils-
|
|
146
|
-
- `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.
|
|
147
101
|
- `c2cciutils-publish`: Publish the project.
|
|
148
102
|
- `c2cciutils-clean`: Delete Docker images on Docker Hub after corresponding branch have been deleted.
|
|
149
103
|
|
|
@@ -204,7 +158,6 @@ You can override the configuration with the file `ci/config.yaml`.
|
|
|
204
158
|
At the base of the configuration you have:
|
|
205
159
|
|
|
206
160
|
- `version`: Contains some regular expressions to find the versions branches and tags, and to convert them into application versions.
|
|
207
|
-
- `audit`: The audit configuration, see `c2cciutils/audit.py` for more information.
|
|
208
161
|
- `publish`: The publishing configuration, see `c2cciutils/publish.py` for more information.
|
|
209
162
|
|
|
210
163
|
Many actions can be disabled by setting the corresponding configuration part to `False`.
|
|
@@ -300,11 +253,22 @@ Then by default:
|
|
|
300
253
|
- Commit on `master` branch after the tag 1.3.0 => release `1.4.0.dev1`
|
|
301
254
|
- Commit on `1.3` branch after the tag 1.3.0 => release `1.3.1.dev1`
|
|
302
255
|
|
|
256
|
+
#### Authentication
|
|
257
|
+
|
|
258
|
+
If the file `~/.pypirc` exists we consider that we ar already logged in also
|
|
259
|
+
we will do the login with the `pypi` server with OpenID Connect (OIDC).
|
|
260
|
+
|
|
261
|
+
The OIDC login is recommended because it didn't needs any additional secrets,
|
|
262
|
+
but it need some configuration on pypi in the package,
|
|
263
|
+
see the [GitHub Documentation](https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-pypi#adding-the-identity-provider-to-pypi).
|
|
264
|
+
|
|
265
|
+
#### Integration if the package directly in a Docker image
|
|
266
|
+
|
|
303
267
|
To make it working in the `Dockerfile` you should have in the `poetry` stage:
|
|
304
268
|
|
|
305
269
|
```Dockerfile
|
|
306
270
|
ENV POETRY_DYNAMIC_VERSIONING_BYPASS=dev
|
|
307
|
-
RUN poetry export --extras=checks --extras=publish --
|
|
271
|
+
RUN poetry export --extras=checks --extras=publish --output=requirements.txt \
|
|
308
272
|
&& poetry export --with=dev --output=requirements-dev.txt
|
|
309
273
|
```
|
|
310
274
|
|
|
@@ -342,7 +306,7 @@ repository:
|
|
|
342
306
|
# List of kinds of versions you want to publish, that can be: rebuild (specified using --type),
|
|
343
307
|
# version_tag, version_branch, feature_branch, feature_tag (for pull request)
|
|
344
308
|
version:
|
|
345
|
-
# List of tags we want to publish interpreted with `
|
|
309
|
+
# List of tags we want to publish interpreted with `format(version=version)`
|
|
346
310
|
# e.g. if you use `{version}-lite` when you publish the version `1.2.3` the source tag
|
|
347
311
|
# (that should be built by the application build) is `latest-lite`, and it will be published
|
|
348
312
|
# with the tag `1.2.3-lite`.
|
|
@@ -2,47 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Publishing
|
|
4
4
|
|
|
5
|
-
The main goals of C2C CI utils is to offer the commands
|
|
6
|
-
|
|
7
|
-
Have stabilization branches named by default `<major>.<minor>`.
|
|
8
|
-
Have the release named by default `<major>.<minor>.<patch>`.
|
|
9
|
-
|
|
10
|
-
With C2C CI utils you can publish a python package and a Docker image from the same repository.
|
|
11
|
-
|
|
12
|
-
The default publishing are:
|
|
13
|
-
|
|
14
|
-
- Push on the `<major>.<minor>` branch will publish Docker images.
|
|
15
|
-
- Create the tag `<major>.<minor>.<patch>` will publish the Docker images, and the Python package.
|
|
16
|
-
- Push on a feature branch (whatever other name) will publish the Docker images.
|
|
17
|
-
- Delete a feature branch will delete the Docker images.
|
|
18
|
-
- Push on the `master` branch will publish the Docker images with the master tag (Publishing a python package is also possible).
|
|
19
|
-
- The version at the last line of the `SECURITY.md` of the `master` branch will be also published using the `latest` tag,
|
|
20
|
-
this will respect the `tags` present in the configuration
|
|
21
|
-
- 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,
|
|
22
|
-
this will respect the `tags` present in the configuration (only for Docker).
|
|
23
|
-
|
|
24
|
-
The Docker images are published on Docker Hub and GitHub Container Registry.
|
|
25
|
-
|
|
26
|
-
You can run the publishing locally in dry-run mode:
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
GITHUB_REF=... c2cciutils-publish --dry-run ...
|
|
30
|
-
```
|
|
5
|
+
The main goals of C2C CI utils is to offer the commands to publish the project,
|
|
6
|
+
see the [documentation](https://github.com/camptocamp/c2cciutils/wiki/Publishing).
|
|
31
7
|
|
|
32
8
|
## Changelog
|
|
33
9
|
|
|
34
10
|
When we create a tag by default with the `changelog` workflow a release is created on GitHub, a changelog is
|
|
35
11
|
generated and added to the release.
|
|
36
12
|
|
|
37
|
-
## Security
|
|
38
|
-
|
|
39
|
-
The security is managed by the `c2cciutils-audit` command with Snyk, it will audit the dependencies of the project on every
|
|
40
|
-
stabilization branches, if possible a pull request is created automatically to update the dependencies.
|
|
41
|
-
|
|
42
|
-
When we publish a Docker image the generated image is monitored by Snyk, this means that Snyk will search
|
|
43
|
-
for all the dependencies and send the list to the Snyk web site to be monitored.
|
|
44
|
-
We also do a test of the image and log the result (This will never cause the build to fail).
|
|
45
|
-
|
|
46
13
|
## Checks
|
|
47
14
|
|
|
48
15
|
C2C CI utils will no more provide a tool to do a check of the project, this is replaced by `pre-commit`,
|
|
@@ -77,21 +44,16 @@ workflow will delete the workflows older than 500 days.
|
|
|
77
44
|
|
|
78
45
|
C2cciutils make easier to have those workflows in a project:
|
|
79
46
|
|
|
80
|
-
- `audit.yaml`: Audit the stabilization branches of the application against vulnerabilities in the python and node dependency
|
|
81
47
|
- `auto-review.yaml`: Auto review the Renovate pull requests
|
|
82
48
|
- `backport.yaml`: Trigger the backports (work with labels)
|
|
83
49
|
- `clean.yaml`: Clean the Docker images related on a deleted feature branch
|
|
84
50
|
- `main.yaml`: Main workflow especially with the c2cciutils-checks command
|
|
85
|
-
- `changelog.yaml`: Generate the changelog and create the release on GitHub
|
|
86
|
-
- `delete-old-workflows-run.yaml`: Delete the old workflows
|
|
87
|
-
- `pr-checks.yaml`: Run the checks on the pull requests
|
|
88
51
|
|
|
89
52
|
All the provided commands used in the workflow:
|
|
90
53
|
|
|
91
54
|
- `c2cciutils`: some generic tools.
|
|
92
55
|
- `c2cciutils-version`: Create a new version of the project.
|
|
93
|
-
- `c2cciutils-
|
|
94
|
-
- `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.
|
|
95
57
|
- `c2cciutils-publish`: Publish the project.
|
|
96
58
|
- `c2cciutils-clean`: Delete Docker images on Docker Hub after corresponding branch have been deleted.
|
|
97
59
|
|
|
@@ -152,7 +114,6 @@ You can override the configuration with the file `ci/config.yaml`.
|
|
|
152
114
|
At the base of the configuration you have:
|
|
153
115
|
|
|
154
116
|
- `version`: Contains some regular expressions to find the versions branches and tags, and to convert them into application versions.
|
|
155
|
-
- `audit`: The audit configuration, see `c2cciutils/audit.py` for more information.
|
|
156
117
|
- `publish`: The publishing configuration, see `c2cciutils/publish.py` for more information.
|
|
157
118
|
|
|
158
119
|
Many actions can be disabled by setting the corresponding configuration part to `False`.
|
|
@@ -248,11 +209,22 @@ Then by default:
|
|
|
248
209
|
- Commit on `master` branch after the tag 1.3.0 => release `1.4.0.dev1`
|
|
249
210
|
- Commit on `1.3` branch after the tag 1.3.0 => release `1.3.1.dev1`
|
|
250
211
|
|
|
212
|
+
#### Authentication
|
|
213
|
+
|
|
214
|
+
If the file `~/.pypirc` exists we consider that we ar already logged in also
|
|
215
|
+
we will do the login with the `pypi` server with OpenID Connect (OIDC).
|
|
216
|
+
|
|
217
|
+
The OIDC login is recommended because it didn't needs any additional secrets,
|
|
218
|
+
but it need some configuration on pypi in the package,
|
|
219
|
+
see the [GitHub Documentation](https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-pypi#adding-the-identity-provider-to-pypi).
|
|
220
|
+
|
|
221
|
+
#### Integration if the package directly in a Docker image
|
|
222
|
+
|
|
251
223
|
To make it working in the `Dockerfile` you should have in the `poetry` stage:
|
|
252
224
|
|
|
253
225
|
```Dockerfile
|
|
254
226
|
ENV POETRY_DYNAMIC_VERSIONING_BYPASS=dev
|
|
255
|
-
RUN poetry export --extras=checks --extras=publish --
|
|
227
|
+
RUN poetry export --extras=checks --extras=publish --output=requirements.txt \
|
|
256
228
|
&& poetry export --with=dev --output=requirements-dev.txt
|
|
257
229
|
```
|
|
258
230
|
|
|
@@ -290,7 +262,7 @@ repository:
|
|
|
290
262
|
# List of kinds of versions you want to publish, that can be: rebuild (specified using --type),
|
|
291
263
|
# version_tag, version_branch, feature_branch, feature_tag (for pull request)
|
|
292
264
|
version:
|
|
293
|
-
# List of tags we want to publish interpreted with `
|
|
265
|
+
# List of tags we want to publish interpreted with `format(version=version)`
|
|
294
266
|
# e.g. if you use `{version}-lite` when you publish the version `1.2.3` the source tag
|
|
295
267
|
# (that should be built by the application build) is `latest-lite`, and it will be published
|
|
296
268
|
# with the tag `1.2.3-lite`.
|
|
@@ -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
|
|
|
@@ -22,7 +21,6 @@ def get_repository() -> str:
|
|
|
22
21
|
"""
|
|
23
22
|
Get the current GitHub repository like `organization/project`.
|
|
24
23
|
"""
|
|
25
|
-
|
|
26
24
|
if "GITHUB_REPOSITORY" in os.environ:
|
|
27
25
|
return os.environ["GITHUB_REPOSITORY"]
|
|
28
26
|
|
|
@@ -47,7 +45,6 @@ def merge(default_config: Any, config: Any) -> Any:
|
|
|
47
45
|
default_config: The default config that will be applied
|
|
48
46
|
config: The base config, will be modified
|
|
49
47
|
"""
|
|
50
|
-
|
|
51
48
|
if not isinstance(default_config, dict) or not isinstance(config, dict):
|
|
52
49
|
return config
|
|
53
50
|
|
|
@@ -79,7 +76,6 @@ def get_config() -> c2cciutils.configuration.Configuration:
|
|
|
79
76
|
"""
|
|
80
77
|
Get the configuration, with project and auto detections.
|
|
81
78
|
"""
|
|
82
|
-
|
|
83
79
|
config: c2cciutils.configuration.Configuration = {}
|
|
84
80
|
if os.path.exists("ci/config.yaml"):
|
|
85
81
|
with open("ci/config.yaml", encoding="utf-8") as open_file:
|
|
@@ -129,8 +125,6 @@ def get_config() -> c2cciutils.configuration.Configuration:
|
|
|
129
125
|
|
|
130
126
|
default_config = {
|
|
131
127
|
"publish": publish_config,
|
|
132
|
-
"pr-checks": c2cciutils.configuration.PULL_REQUEST_CHECKS_DEFAULT,
|
|
133
|
-
"audit": c2cciutils.configuration.AUDIT_DEFAULT,
|
|
134
128
|
}
|
|
135
129
|
merge(default_config, config)
|
|
136
130
|
|
|
@@ -279,7 +273,6 @@ def print_versions(config: c2cciutils.configuration.PrintVersions) -> bool:
|
|
|
279
273
|
Arguments:
|
|
280
274
|
config: The print configuration
|
|
281
275
|
"""
|
|
282
|
-
|
|
283
276
|
for version in config.get("versions", c2cciutils.configuration.PRINT_VERSIONS_VERSIONS_DEFAULT):
|
|
284
277
|
try:
|
|
285
278
|
sys.stdout.flush()
|
|
@@ -383,7 +376,6 @@ def graphql(query_file: str, variables: dict[str, Any], default: Any = None) ->
|
|
|
383
376
|
Return the data result
|
|
384
377
|
In case of error it throw an exception
|
|
385
378
|
"""
|
|
386
|
-
|
|
387
379
|
with open(os.path.join(os.path.dirname(__file__), query_file), encoding="utf-8") as query_open:
|
|
388
380
|
query = query_open.read()
|
|
389
381
|
|
|
@@ -416,164 +408,8 @@ def graphql(query_file: str, variables: dict[str, Any], default: Any = None) ->
|
|
|
416
408
|
return cast(dict[str, Any], json_response["data"])
|
|
417
409
|
|
|
418
410
|
|
|
419
|
-
def get_git_files_mime(
|
|
420
|
-
mime_type: Optional[list[str]] = None,
|
|
421
|
-
extensions: Optional[list[str]] = None,
|
|
422
|
-
ignore_patterns_re: Optional[list[str]] = None,
|
|
423
|
-
) -> list[str]:
|
|
424
|
-
"""
|
|
425
|
-
Get list of paths from git with all the files that have the specified mime type.
|
|
426
|
-
|
|
427
|
-
Arguments:
|
|
428
|
-
mime_type: The considered MIME type
|
|
429
|
-
extensions: The considered extensions
|
|
430
|
-
ignore_patterns_re: A list of regular expressions of files that we should ignore
|
|
431
|
-
"""
|
|
432
|
-
if mime_type is None:
|
|
433
|
-
mime_type = ["text/x-python", "text/x-script.python"]
|
|
434
|
-
if extensions is None:
|
|
435
|
-
extensions = [".py"]
|
|
436
|
-
ignore_patterns_compiled = [re.compile(p) for p in ignore_patterns_re or []]
|
|
437
|
-
result = []
|
|
438
|
-
|
|
439
|
-
for filename in subprocess.check_output(["git", "ls-files"]).decode().strip().split("\n"):
|
|
440
|
-
if os.path.isfile(filename) and (
|
|
441
|
-
os.path.splitext(filename)[1] in extensions or magic.from_file(filename, mime=True) in mime_type
|
|
442
|
-
):
|
|
443
|
-
accept = True
|
|
444
|
-
for pattern in ignore_patterns_compiled:
|
|
445
|
-
if pattern.search(filename):
|
|
446
|
-
accept = False
|
|
447
|
-
break
|
|
448
|
-
if accept:
|
|
449
|
-
result.append(filename)
|
|
450
|
-
return result
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
def get_branch(branch: Optional[str], master_branch: str = "master") -> str:
|
|
454
|
-
"""
|
|
455
|
-
Get the branch name.
|
|
456
|
-
|
|
457
|
-
Arguments:
|
|
458
|
-
branch: The forced to use branch name
|
|
459
|
-
master_branch: The master branch name, can be used as default value
|
|
460
|
-
|
|
461
|
-
Return the branch name
|
|
462
|
-
"""
|
|
463
|
-
|
|
464
|
-
if branch is not None:
|
|
465
|
-
return branch
|
|
466
|
-
try:
|
|
467
|
-
branch = (
|
|
468
|
-
subprocess.run(["git", "rev-parse", "--abbrev-ref", "HEAD"], check=True, stdout=subprocess.PIPE)
|
|
469
|
-
.stdout.decode()
|
|
470
|
-
.strip()
|
|
471
|
-
)
|
|
472
|
-
except subprocess.CalledProcessError as exception:
|
|
473
|
-
print(f"Error getting branch: {exception}")
|
|
474
|
-
branch = "HEAD"
|
|
475
|
-
|
|
476
|
-
if branch == "HEAD":
|
|
477
|
-
branch = os.environ.get("GITHUB_HEAD_REF", master_branch)
|
|
478
|
-
assert branch is not None
|
|
479
|
-
return branch
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
def get_based_on_master(
|
|
483
|
-
repo: list[str],
|
|
484
|
-
override_current_branch: Optional[str],
|
|
485
|
-
master_branch: str,
|
|
486
|
-
config: c2cciutils.configuration.Configuration,
|
|
487
|
-
) -> bool:
|
|
488
|
-
"""
|
|
489
|
-
Check that we are not on a release branch (to avoid errors in versions check).
|
|
490
|
-
|
|
491
|
-
This function will check the last 20 commits in current branch,
|
|
492
|
-
and for each other branch (max 50) check if any commit in last 10 commits is the current one.
|
|
493
|
-
|
|
494
|
-
Arguments:
|
|
495
|
-
repo: The repository [<organization>, <name>]
|
|
496
|
-
override_current_branch: The branch to use instead of the current one
|
|
497
|
-
master_branch: The master branch name
|
|
498
|
-
config: The full configuration
|
|
499
|
-
"""
|
|
500
|
-
if os.environ.get("GITHUB_REF", "").startswith("refs/tags/"):
|
|
501
|
-
# The tags are never consider as based on master
|
|
502
|
-
return False
|
|
503
|
-
current_branch = get_branch(override_current_branch, master_branch)
|
|
504
|
-
if current_branch == master_branch:
|
|
505
|
-
return True
|
|
506
|
-
branches_re = compile_re(config["version"].get("branch_to_version_re", []))
|
|
507
|
-
if does_match(current_branch, branches_re):
|
|
508
|
-
return False
|
|
509
|
-
if os.environ.get("GITHUB_BASE_REF"):
|
|
510
|
-
return os.environ.get("GITHUB_BASE_REF") == master_branch
|
|
511
|
-
commits_repository_json = graphql(
|
|
512
|
-
"commits.graphql", {"name": repo[1], "owner": repo[0], "branch": current_branch}
|
|
513
|
-
).get("repository", {})
|
|
514
|
-
commits_json = (
|
|
515
|
-
commits_repository_json.get("ref", {}).get("target", {}).get("history", {}).get("nodes", [])
|
|
516
|
-
if commits_repository_json.get("ref")
|
|
517
|
-
else []
|
|
518
|
-
)
|
|
519
|
-
branches_json = [
|
|
520
|
-
branch
|
|
521
|
-
for branch in (
|
|
522
|
-
graphql("branches.graphql", {"name": repo[1], "owner": repo[0]})["repository"]["refs"]["nodes"]
|
|
523
|
-
)
|
|
524
|
-
if branch["name"] != current_branch and does_match(branch["name"], branches_re)
|
|
525
|
-
]
|
|
526
|
-
based_branch = master_branch
|
|
527
|
-
found = False
|
|
528
|
-
for commit in commits_json:
|
|
529
|
-
for branch in branches_json:
|
|
530
|
-
commits = [
|
|
531
|
-
branch_commit
|
|
532
|
-
for branch_commit in branch["target"]["history"]["nodes"]
|
|
533
|
-
if commit["oid"] == branch_commit["oid"]
|
|
534
|
-
]
|
|
535
|
-
if commits:
|
|
536
|
-
based_branch = branch["name"]
|
|
537
|
-
found = True
|
|
538
|
-
break
|
|
539
|
-
if found:
|
|
540
|
-
break
|
|
541
|
-
return based_branch == master_branch
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
def get_codespell_command(config: c2cciutils.configuration.Configuration, fix: bool = False) -> list[str]:
|
|
545
|
-
"""
|
|
546
|
-
Get the codespell command.
|
|
547
|
-
|
|
548
|
-
Arguments:
|
|
549
|
-
config: The full configuration
|
|
550
|
-
fix: If we should fix the errors
|
|
551
|
-
"""
|
|
552
|
-
codespell_config = config.get("codespell", {})
|
|
553
|
-
codespell_config = codespell_config if isinstance(codespell_config, dict) else {}
|
|
554
|
-
command = ["codespell"]
|
|
555
|
-
if fix:
|
|
556
|
-
command.append("--write-changes")
|
|
557
|
-
for spell_ignore_file in (
|
|
558
|
-
".github/spell-ignore-words.txt",
|
|
559
|
-
"spell-ignore-words.txt",
|
|
560
|
-
".spell-ignore-words.txt",
|
|
561
|
-
):
|
|
562
|
-
if os.path.exists(spell_ignore_file):
|
|
563
|
-
command.append(f"--ignore-words={spell_ignore_file}")
|
|
564
|
-
break
|
|
565
|
-
dictionaries = codespell_config.get(
|
|
566
|
-
"internal_dictionaries", c2cciutils.configuration.CODESPELL_DICTIONARIES_DEFAULT
|
|
567
|
-
)
|
|
568
|
-
if dictionaries:
|
|
569
|
-
command.append("--builtin=" + ",".join(dictionaries))
|
|
570
|
-
command += codespell_config.get("arguments", c2cciutils.configuration.CODESPELL_ARGUMENTS_DEFAULT)
|
|
571
|
-
return command
|
|
572
|
-
|
|
573
|
-
|
|
574
411
|
def snyk_exec() -> tuple[str, dict[str, str]]:
|
|
575
412
|
"""Get the Snyk cli executable path."""
|
|
576
|
-
|
|
577
413
|
if not os.path.exists(os.path.join(os.path.dirname(__file__), "node_modules")):
|
|
578
414
|
subprocess.run(["npm", "install"], cwd=os.path.dirname(__file__), check=True) # nosec
|
|
579
415
|
|
|
@@ -587,59 +423,3 @@ def snyk_exec() -> tuple[str, dict[str, str]]:
|
|
|
587
423
|
subprocess.run(["snyk", "config", "set", f"org={env['SNYK_ORG']}"], check=True, env=env)
|
|
588
424
|
|
|
589
425
|
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "node_modules/snyk/bin/snyk"), env
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
def create_pull_request_if_needed(
|
|
593
|
-
current_branch: str,
|
|
594
|
-
new_branch: str,
|
|
595
|
-
commit_message: str,
|
|
596
|
-
pull_request_extra_arguments: Optional[list[str]] = None,
|
|
597
|
-
) -> bool:
|
|
598
|
-
"""
|
|
599
|
-
Create a pull request if there are changes.
|
|
600
|
-
"""
|
|
601
|
-
|
|
602
|
-
if pull_request_extra_arguments is None:
|
|
603
|
-
pull_request_extra_arguments = ["--fill"]
|
|
604
|
-
|
|
605
|
-
diff_proc = subprocess.run(["git", "diff", "--quiet"]) # pylint: disable=subprocess-run-check
|
|
606
|
-
if diff_proc.returncode != 0:
|
|
607
|
-
print("::group::Diff")
|
|
608
|
-
sys.stdout.flush()
|
|
609
|
-
sys.stderr.flush()
|
|
610
|
-
subprocess.run(["git", "diff"], check=True)
|
|
611
|
-
print("::endgroup::")
|
|
612
|
-
|
|
613
|
-
git_hash = subprocess.run(
|
|
614
|
-
["git", "rev-parse", "HEAD"], check=True, stdout=subprocess.PIPE, encoding="utf-8"
|
|
615
|
-
).stdout.strip()
|
|
616
|
-
subprocess.run(["git", "checkout", "-b", new_branch], check=True)
|
|
617
|
-
subprocess.run(["git", "add", "--all"], check=True)
|
|
618
|
-
subprocess.run(["git", "commit", f"--message={commit_message}"], check=True)
|
|
619
|
-
if os.environ.get("TEST") != "TRUE":
|
|
620
|
-
subprocess.run(
|
|
621
|
-
["git", "push", "--force", "origin", new_branch],
|
|
622
|
-
check=True,
|
|
623
|
-
)
|
|
624
|
-
env = os.environ.copy()
|
|
625
|
-
if "GH_TOKEN" not in env:
|
|
626
|
-
if "GITHUB_TOKEN" in env:
|
|
627
|
-
env["GH_TOKEN"] = env["GITHUB_TOKEN"]
|
|
628
|
-
else:
|
|
629
|
-
env["GH_TOKEN"] = str(c2cciutils.gopass("gs/ci/github/token/gopass"))
|
|
630
|
-
subprocess.run(
|
|
631
|
-
[
|
|
632
|
-
"gh",
|
|
633
|
-
"pr",
|
|
634
|
-
"create",
|
|
635
|
-
f"--base={current_branch}",
|
|
636
|
-
*pull_request_extra_arguments,
|
|
637
|
-
],
|
|
638
|
-
check=True,
|
|
639
|
-
env=env,
|
|
640
|
-
)
|
|
641
|
-
else:
|
|
642
|
-
subprocess.run(["git", "reset", "--hard"], check=True)
|
|
643
|
-
subprocess.run(["git", "checkout", git_hash], check=True)
|
|
644
|
-
|
|
645
|
-
return diff_proc.returncode != 0
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
# https://docs.renovatebot.com/modules/datasource/#github-releases-datasource
|
|
2
|
-
k3d-io/k3d: v5.
|
|
3
|
-
postgresql:
|
|
2
|
+
k3d-io/k3d: v5.7.4 # github-releases
|
|
3
|
+
postgresql: 16.0.0 # helm - https://charts.bitnami.com/bitnami
|
|
4
4
|
helm/chart-releaser: v1.6.1 # github-releases
|
|
@@ -2,31 +2,33 @@
|
|
|
2
2
|
Automatically generated file from a JSON schema.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
from typing import Literal, TypedDict, Union
|
|
7
6
|
|
|
8
|
-
# Application configuration.
|
|
9
|
-
#
|
|
10
|
-
# An application configuration
|
|
7
|
+
# | Application configuration.
|
|
8
|
+
# |
|
|
9
|
+
# | An application configuration
|
|
11
10
|
ApplicationConfiguration = TypedDict(
|
|
12
11
|
"ApplicationConfiguration",
|
|
13
12
|
{
|
|
14
|
-
# URL pattern.
|
|
15
|
-
#
|
|
16
|
-
# URL pattern, to be used for files that didn't come from GitHub release, available arguments: {version}
|
|
13
|
+
# | URL pattern.
|
|
14
|
+
# |
|
|
15
|
+
# | URL pattern, to be used for files that didn't come from GitHub release, available arguments: {version}
|
|
17
16
|
"url-pattern": str,
|
|
17
|
+
# | The type of file.
|
|
18
|
+
# |
|
|
19
|
+
# | The type of file
|
|
18
20
|
"type": "TheTypeOfFile",
|
|
19
|
-
# The filename to get.
|
|
20
|
-
#
|
|
21
|
-
# The
|
|
21
|
+
# | The filename to get.
|
|
22
|
+
# |
|
|
23
|
+
# | The name of the file to get in the GitHub release
|
|
22
24
|
"get-file-name": str,
|
|
23
|
-
# The created tile name.
|
|
24
|
-
#
|
|
25
|
-
# The name of the final tile
|
|
25
|
+
# | The created tile name.
|
|
26
|
+
# |
|
|
27
|
+
# | The name of the final tile we will create
|
|
26
28
|
"to-file-name": str,
|
|
27
|
-
# The tile name to get in the tar file.
|
|
29
|
+
# | The tile name to get in the tar file.
|
|
28
30
|
"tar-file-name": str,
|
|
29
|
-
# The commands to run after the tile creation.
|
|
31
|
+
# | The commands to run after the tile creation.
|
|
30
32
|
"finish-commands": list[list[str]],
|
|
31
33
|
},
|
|
32
34
|
total=False,
|