c2cciutils 1.7.0.dev176__tar.gz → 1.7.6.dev31__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.7.0.dev176 → c2cciutils-1.7.6.dev31}/LICENSE +1 -1
- c2cciutils-1.7.0.dev176/README.md → c2cciutils-1.7.6.dev31/PKG-INFO +59 -44
- c2cciutils-1.7.0.dev176/PKG-INFO → c2cciutils-1.7.6.dev31/README.md +16 -91
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/__init__.py +0 -220
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/applications-versions.yaml +2 -2
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/applications_definition.py +17 -17
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/configuration.py +81 -550
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/env.py +0 -7
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/lib/docker.py +0 -2
- c2cciutils-1.7.6.dev31/c2cciutils/lib/oidc.py +186 -0
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/package-lock.json +115 -61
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/package.json +1 -1
- c2cciutils-1.7.6.dev31/c2cciutils/publish.py +237 -0
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/schema.json +3 -230
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/scripts/clean.py +0 -1
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/scripts/docker_logs.py +2 -2
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/scripts/docker_versions_gen.py +0 -1
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/scripts/download_applications.py +0 -2
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/scripts/k8s/db.py +3 -1
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/scripts/k8s/wait.py +2 -2
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/scripts/main.py +2 -10
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/scripts/publish.py +17 -34
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/scripts/trigger_image_update.py +0 -1
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/scripts/version.py +0 -1
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/pyproject.toml +22 -35
- c2cciutils-1.7.0.dev176/c2cciutils/audit.py +0 -229
- c2cciutils-1.7.0.dev176/c2cciutils/pr_checks.py +0 -286
- c2cciutils-1.7.0.dev176/c2cciutils/publish.py +0 -469
- c2cciutils-1.7.0.dev176/c2cciutils/scripts/audit.py +0 -41
- c2cciutils-1.7.0.dev176/c2cciutils/scripts/docker_versions_update.py +0 -85
- c2cciutils-1.7.0.dev176/c2cciutils/scripts/pr_checks.py +0 -78
- c2cciutils-1.7.0.dev176/c2cciutils/security.py +0 -59
- c2cciutils-1.7.0.dev176/setup.py +0 -79
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/applications.yaml +0 -0
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/branches.graphql +0 -0
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/commits.graphql +0 -0
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/default_branch.graphql +0 -0
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/schema-applications.json +0 -0
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/scripts/__init__.py +0 -0
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/scripts/env.py +0 -0
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/scripts/k8s/__init__.py +0 -0
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/scripts/k8s/install.py +0 -0
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/scripts/k8s/logs.py +0 -0
- {c2cciutils-1.7.0.dev176 → c2cciutils-1.7.6.dev31}/c2cciutils/scripts/pin_pipenv.py +0 -0
|
@@ -1,48 +1,57 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: c2cciutils
|
|
3
|
+
Version: 1.7.6.dev31
|
|
4
|
+
Summary: Common utilities for Camptocamp CI
|
|
5
|
+
Home-page: https://github.com/camptocamp/c2cciutils
|
|
6
|
+
License: FreeBSD
|
|
7
|
+
Keywords: ci
|
|
8
|
+
Author: Camptocamp
|
|
9
|
+
Author-email: info@camptocamp.com
|
|
10
|
+
Requires-Python: >=3.9,<4.0
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: License :: Other/Proprietary License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Provides-Extra: audit
|
|
26
|
+
Provides-Extra: checks
|
|
27
|
+
Provides-Extra: pr-checks
|
|
28
|
+
Provides-Extra: publish
|
|
29
|
+
Provides-Extra: publish-plugins
|
|
30
|
+
Provides-Extra: version
|
|
31
|
+
Requires-Dist: PyYAML (>=6.0.0,<7.0.0)
|
|
32
|
+
Requires-Dist: debian-inspector (>=31.0.0,<32.0.0)
|
|
33
|
+
Requires-Dist: defusedxml (>=0.0.0,<1.0.0)
|
|
34
|
+
Requires-Dist: id (>=1.0.0,<2.0.0) ; extra == "publish"
|
|
35
|
+
Requires-Dist: multi-repo-automation (>=1.0.0,<2.0.0) ; extra == "version"
|
|
36
|
+
Requires-Dist: requests (>=2.0.0,<3.0.0)
|
|
37
|
+
Requires-Dist: ruamel.yaml (>=0.0.0,<1.0.0)
|
|
38
|
+
Requires-Dist: security-md (<=2)
|
|
39
|
+
Requires-Dist: twine (>=5.0.0,<6.0.0) ; extra == "publish"
|
|
40
|
+
Project-URL: Repository, https://github.com/camptocamp/c2cciutils
|
|
41
|
+
Description-Content-Type: text/markdown
|
|
42
|
+
|
|
1
43
|
# C2C CI utils
|
|
2
44
|
|
|
3
45
|
## Publishing
|
|
4
46
|
|
|
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
|
-
```
|
|
47
|
+
The main goals of C2C CI utils is to offer the commands to publish the project,
|
|
48
|
+
see the [documentation](https://github.com/camptocamp/c2cciutils/wiki/Publishing).
|
|
31
49
|
|
|
32
50
|
## Changelog
|
|
33
51
|
|
|
34
52
|
When we create a tag by default with the `changelog` workflow a release is created on GitHub, a changelog is
|
|
35
53
|
generated and added to the release.
|
|
36
54
|
|
|
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
55
|
## Checks
|
|
47
56
|
|
|
48
57
|
C2C CI utils will no more provide a tool to do a check of the project, this is replaced by `pre-commit`,
|
|
@@ -77,21 +86,16 @@ workflow will delete the workflows older than 500 days.
|
|
|
77
86
|
|
|
78
87
|
C2cciutils make easier to have those workflows in a project:
|
|
79
88
|
|
|
80
|
-
- `audit.yaml`: Audit the stabilization branches of the application against vulnerabilities in the python and node dependency
|
|
81
89
|
- `auto-review.yaml`: Auto review the Renovate pull requests
|
|
82
90
|
- `backport.yaml`: Trigger the backports (work with labels)
|
|
83
91
|
- `clean.yaml`: Clean the Docker images related on a deleted feature branch
|
|
84
92
|
- `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
93
|
|
|
89
94
|
All the provided commands used in the workflow:
|
|
90
95
|
|
|
91
96
|
- `c2cciutils`: some generic tools.
|
|
92
97
|
- `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.
|
|
98
|
+
- `c2cciutils-env`: Print some environment information.
|
|
95
99
|
- `c2cciutils-publish`: Publish the project.
|
|
96
100
|
- `c2cciutils-clean`: Delete Docker images on Docker Hub after corresponding branch have been deleted.
|
|
97
101
|
|
|
@@ -152,7 +156,6 @@ You can override the configuration with the file `ci/config.yaml`.
|
|
|
152
156
|
At the base of the configuration you have:
|
|
153
157
|
|
|
154
158
|
- `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
159
|
- `publish`: The publishing configuration, see `c2cciutils/publish.py` for more information.
|
|
157
160
|
|
|
158
161
|
Many actions can be disabled by setting the corresponding configuration part to `False`.
|
|
@@ -248,11 +251,22 @@ Then by default:
|
|
|
248
251
|
- Commit on `master` branch after the tag 1.3.0 => release `1.4.0.dev1`
|
|
249
252
|
- Commit on `1.3` branch after the tag 1.3.0 => release `1.3.1.dev1`
|
|
250
253
|
|
|
254
|
+
#### Authentication
|
|
255
|
+
|
|
256
|
+
If the file `~/.pypirc` exists we consider that we ar already logged in also
|
|
257
|
+
we will do the login with the `pypi` server with OpenID Connect (OIDC).
|
|
258
|
+
|
|
259
|
+
The OIDC login is recommended because it didn't needs any additional secrets,
|
|
260
|
+
but it need some configuration on pypi in the package,
|
|
261
|
+
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).
|
|
262
|
+
|
|
263
|
+
#### Integration if the package directly in a Docker image
|
|
264
|
+
|
|
251
265
|
To make it working in the `Dockerfile` you should have in the `poetry` stage:
|
|
252
266
|
|
|
253
267
|
```Dockerfile
|
|
254
268
|
ENV POETRY_DYNAMIC_VERSIONING_BYPASS=dev
|
|
255
|
-
RUN poetry export --extras=checks --extras=publish --
|
|
269
|
+
RUN poetry export --extras=checks --extras=publish --output=requirements.txt \
|
|
256
270
|
&& poetry export --with=dev --output=requirements-dev.txt
|
|
257
271
|
```
|
|
258
272
|
|
|
@@ -290,7 +304,7 @@ repository:
|
|
|
290
304
|
# List of kinds of versions you want to publish, that can be: rebuild (specified using --type),
|
|
291
305
|
# version_tag, version_branch, feature_branch, feature_tag (for pull request)
|
|
292
306
|
version:
|
|
293
|
-
# List of tags we want to publish interpreted with `
|
|
307
|
+
# List of tags we want to publish interpreted with `format(version=version)`
|
|
294
308
|
# e.g. if you use `{version}-lite` when you publish the version `1.2.3` the source tag
|
|
295
309
|
# (that should be built by the application build) is `latest-lite`, and it will be published
|
|
296
310
|
# with the tag `1.2.3-lite`.
|
|
@@ -448,3 +462,4 @@ Install the pre-commit hooks:
|
|
|
448
462
|
pip install pre-commit
|
|
449
463
|
pre-commit install --allow-missing-config
|
|
450
464
|
```
|
|
465
|
+
|
|
@@ -1,94 +1,15 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: c2cciutils
|
|
3
|
-
Version: 1.7.0.dev176
|
|
4
|
-
Summary: Common utilities for Camptocamp CI
|
|
5
|
-
Home-page: https://github.com/camptocamp/c2cciutils
|
|
6
|
-
License: FreeBSD
|
|
7
|
-
Keywords: ci
|
|
8
|
-
Author: Camptocamp
|
|
9
|
-
Author-email: info@camptocamp.com
|
|
10
|
-
Requires-Python: >=3.9,<4.0
|
|
11
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
-
Classifier: Environment :: Console
|
|
13
|
-
Classifier: Intended Audience :: Developers
|
|
14
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
-
Classifier: License :: Other/Proprietary License
|
|
16
|
-
Classifier: Operating System :: OS Independent
|
|
17
|
-
Classifier: Programming Language :: Python
|
|
18
|
-
Classifier: Programming Language :: Python :: 3
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
-
Classifier: Typing :: Typed
|
|
22
|
-
Provides-Extra: audit
|
|
23
|
-
Provides-Extra: checks
|
|
24
|
-
Provides-Extra: pr_checks
|
|
25
|
-
Provides-Extra: publish
|
|
26
|
-
Provides-Extra: publish_plugins
|
|
27
|
-
Provides-Extra: version
|
|
28
|
-
Requires-Dist: Markdown (>=3.0.0,<4.0.0)
|
|
29
|
-
Requires-Dist: PyYAML (>=6.0.0,<7.0.0)
|
|
30
|
-
Requires-Dist: codespell (==2.2.6); extra == "pr_checks"
|
|
31
|
-
Requires-Dist: debian-inspector (>=31.0.0,<32.0.0)
|
|
32
|
-
Requires-Dist: defusedxml (>=0.0.0,<1.0.0)
|
|
33
|
-
Requires-Dist: google-api-python-client (>=2.0.0,<3.0.0); extra == "publish"
|
|
34
|
-
Requires-Dist: google-auth-httplib2 (>=0.0.0,<1.0.0); extra == "publish"
|
|
35
|
-
Requires-Dist: google-auth-oauthlib (>=1.0.0,<2.0.0); extra == "publish"
|
|
36
|
-
Requires-Dist: markdown-table (>=2020.0.0,<2021.0.0)
|
|
37
|
-
Requires-Dist: multi-repo-automation (>=1.0.0,<2.0.0); extra == "version"
|
|
38
|
-
Requires-Dist: python-magic (>=0.0.0,<1.0.0)
|
|
39
|
-
Requires-Dist: requests (>=2.0.0,<3.0.0)
|
|
40
|
-
Requires-Dist: ruamel.yaml (>=0.0.0,<1.0.0)
|
|
41
|
-
Requires-Dist: toml (>=0.0.0,<1.0.0)
|
|
42
|
-
Requires-Dist: tomlkit (>=0.0.0,<1.0.0); extra == "publish"
|
|
43
|
-
Requires-Dist: twine (>=5.0.0,<6.0.0); extra == "publish"
|
|
44
|
-
Project-URL: Repository, https://github.com/camptocamp/c2cciutils
|
|
45
|
-
Description-Content-Type: text/markdown
|
|
46
|
-
|
|
47
1
|
# C2C CI utils
|
|
48
2
|
|
|
49
3
|
## Publishing
|
|
50
4
|
|
|
51
|
-
The main goals of C2C CI utils is to offer the commands
|
|
52
|
-
|
|
53
|
-
Have stabilization branches named by default `<major>.<minor>`.
|
|
54
|
-
Have the release named by default `<major>.<minor>.<patch>`.
|
|
55
|
-
|
|
56
|
-
With C2C CI utils you can publish a python package and a Docker image from the same repository.
|
|
57
|
-
|
|
58
|
-
The default publishing are:
|
|
59
|
-
|
|
60
|
-
- Push on the `<major>.<minor>` branch will publish Docker images.
|
|
61
|
-
- Create the tag `<major>.<minor>.<patch>` will publish the Docker images, and the Python package.
|
|
62
|
-
- Push on a feature branch (whatever other name) will publish the Docker images.
|
|
63
|
-
- Delete a feature branch will delete the Docker images.
|
|
64
|
-
- Push on the `master` branch will publish the Docker images with the master tag (Publishing a python package is also possible).
|
|
65
|
-
- The version at the last line of the `SECURITY.md` of the `master` branch will be also published using the `latest` tag,
|
|
66
|
-
this will respect the `tags` present in the configuration
|
|
67
|
-
- 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,
|
|
68
|
-
this will respect the `tags` present in the configuration (only for Docker).
|
|
69
|
-
|
|
70
|
-
The Docker images are published on Docker Hub and GitHub Container Registry.
|
|
71
|
-
|
|
72
|
-
You can run the publishing locally in dry-run mode:
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
GITHUB_REF=... c2cciutils-publish --dry-run ...
|
|
76
|
-
```
|
|
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).
|
|
77
7
|
|
|
78
8
|
## Changelog
|
|
79
9
|
|
|
80
10
|
When we create a tag by default with the `changelog` workflow a release is created on GitHub, a changelog is
|
|
81
11
|
generated and added to the release.
|
|
82
12
|
|
|
83
|
-
## Security
|
|
84
|
-
|
|
85
|
-
The security is managed by the `c2cciutils-audit` command with Snyk, it will audit the dependencies of the project on every
|
|
86
|
-
stabilization branches, if possible a pull request is created automatically to update the dependencies.
|
|
87
|
-
|
|
88
|
-
When we publish a Docker image the generated image is monitored by Snyk, this means that Snyk will search
|
|
89
|
-
for all the dependencies and send the list to the Snyk web site to be monitored.
|
|
90
|
-
We also do a test of the image and log the result (This will never cause the build to fail).
|
|
91
|
-
|
|
92
13
|
## Checks
|
|
93
14
|
|
|
94
15
|
C2C CI utils will no more provide a tool to do a check of the project, this is replaced by `pre-commit`,
|
|
@@ -123,21 +44,16 @@ workflow will delete the workflows older than 500 days.
|
|
|
123
44
|
|
|
124
45
|
C2cciutils make easier to have those workflows in a project:
|
|
125
46
|
|
|
126
|
-
- `audit.yaml`: Audit the stabilization branches of the application against vulnerabilities in the python and node dependency
|
|
127
47
|
- `auto-review.yaml`: Auto review the Renovate pull requests
|
|
128
48
|
- `backport.yaml`: Trigger the backports (work with labels)
|
|
129
49
|
- `clean.yaml`: Clean the Docker images related on a deleted feature branch
|
|
130
50
|
- `main.yaml`: Main workflow especially with the c2cciutils-checks command
|
|
131
|
-
- `changelog.yaml`: Generate the changelog and create the release on GitHub
|
|
132
|
-
- `delete-old-workflows-run.yaml`: Delete the old workflows
|
|
133
|
-
- `pr-checks.yaml`: Run the checks on the pull requests
|
|
134
51
|
|
|
135
52
|
All the provided commands used in the workflow:
|
|
136
53
|
|
|
137
54
|
- `c2cciutils`: some generic tools.
|
|
138
55
|
- `c2cciutils-version`: Create a new version of the project.
|
|
139
|
-
- `c2cciutils-
|
|
140
|
-
- `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.
|
|
141
57
|
- `c2cciutils-publish`: Publish the project.
|
|
142
58
|
- `c2cciutils-clean`: Delete Docker images on Docker Hub after corresponding branch have been deleted.
|
|
143
59
|
|
|
@@ -198,7 +114,6 @@ You can override the configuration with the file `ci/config.yaml`.
|
|
|
198
114
|
At the base of the configuration you have:
|
|
199
115
|
|
|
200
116
|
- `version`: Contains some regular expressions to find the versions branches and tags, and to convert them into application versions.
|
|
201
|
-
- `audit`: The audit configuration, see `c2cciutils/audit.py` for more information.
|
|
202
117
|
- `publish`: The publishing configuration, see `c2cciutils/publish.py` for more information.
|
|
203
118
|
|
|
204
119
|
Many actions can be disabled by setting the corresponding configuration part to `False`.
|
|
@@ -294,11 +209,22 @@ Then by default:
|
|
|
294
209
|
- Commit on `master` branch after the tag 1.3.0 => release `1.4.0.dev1`
|
|
295
210
|
- Commit on `1.3` branch after the tag 1.3.0 => release `1.3.1.dev1`
|
|
296
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
|
+
|
|
297
223
|
To make it working in the `Dockerfile` you should have in the `poetry` stage:
|
|
298
224
|
|
|
299
225
|
```Dockerfile
|
|
300
226
|
ENV POETRY_DYNAMIC_VERSIONING_BYPASS=dev
|
|
301
|
-
RUN poetry export --extras=checks --extras=publish --
|
|
227
|
+
RUN poetry export --extras=checks --extras=publish --output=requirements.txt \
|
|
302
228
|
&& poetry export --with=dev --output=requirements-dev.txt
|
|
303
229
|
```
|
|
304
230
|
|
|
@@ -336,7 +262,7 @@ repository:
|
|
|
336
262
|
# List of kinds of versions you want to publish, that can be: rebuild (specified using --type),
|
|
337
263
|
# version_tag, version_branch, feature_branch, feature_tag (for pull request)
|
|
338
264
|
version:
|
|
339
|
-
# List of tags we want to publish interpreted with `
|
|
265
|
+
# List of tags we want to publish interpreted with `format(version=version)`
|
|
340
266
|
# e.g. if you use `{version}-lite` when you publish the version `1.2.3` the source tag
|
|
341
267
|
# (that should be built by the application build) is `latest-lite`, and it will be published
|
|
342
268
|
# with the tag `1.2.3-lite`.
|
|
@@ -494,4 +420,3 @@ Install the pre-commit hooks:
|
|
|
494
420
|
pip install pre-commit
|
|
495
421
|
pre-commit install --allow-missing-config
|
|
496
422
|
```
|
|
497
|
-
|
|
@@ -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.5 # github-releases
|
|
3
|
+
postgresql: 16.0.6 # helm - https://charts.bitnami.com/bitnami
|
|
4
4
|
helm/chart-releaser: v1.6.1 # github-releases
|
|
@@ -4,31 +4,31 @@ Automatically generated file from a JSON schema.
|
|
|
4
4
|
|
|
5
5
|
from typing import Literal, TypedDict, Union
|
|
6
6
|
|
|
7
|
-
# Application configuration.
|
|
8
|
-
#
|
|
9
|
-
# An application configuration
|
|
7
|
+
# | Application configuration.
|
|
8
|
+
# |
|
|
9
|
+
# | An application configuration
|
|
10
10
|
ApplicationConfiguration = TypedDict(
|
|
11
11
|
"ApplicationConfiguration",
|
|
12
12
|
{
|
|
13
|
-
# URL pattern.
|
|
14
|
-
#
|
|
15
|
-
# 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}
|
|
16
16
|
"url-pattern": str,
|
|
17
|
-
# The type of file.
|
|
18
|
-
#
|
|
19
|
-
# The type of file
|
|
17
|
+
# | The type of file.
|
|
18
|
+
# |
|
|
19
|
+
# | The type of file
|
|
20
20
|
"type": "TheTypeOfFile",
|
|
21
|
-
# The filename to get.
|
|
22
|
-
#
|
|
23
|
-
# The name of the file to get in the GitHub release
|
|
21
|
+
# | The filename to get.
|
|
22
|
+
# |
|
|
23
|
+
# | The name of the file to get in the GitHub release
|
|
24
24
|
"get-file-name": str,
|
|
25
|
-
# The created tile name.
|
|
26
|
-
#
|
|
27
|
-
# The name of the final tile we will create
|
|
25
|
+
# | The created tile name.
|
|
26
|
+
# |
|
|
27
|
+
# | The name of the final tile we will create
|
|
28
28
|
"to-file-name": str,
|
|
29
|
-
# The tile name to get in the tar file.
|
|
29
|
+
# | The tile name to get in the tar file.
|
|
30
30
|
"tar-file-name": str,
|
|
31
|
-
# The commands to run after the tile creation.
|
|
31
|
+
# | The commands to run after the tile creation.
|
|
32
32
|
"finish-commands": list[list[str]],
|
|
33
33
|
},
|
|
34
34
|
total=False,
|