depdelta-cli 0.1.0__py3-none-any.whl
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.
- depdelta_cli/__init__.py +3 -0
- depdelta_cli/__main__.py +3 -0
- depdelta_cli/api.py +142 -0
- depdelta_cli/check.py +48 -0
- depdelta_cli/env.py +116 -0
- depdelta_cli/gerrit.py +40 -0
- depdelta_cli/git.py +110 -0
- depdelta_cli/gitlab.py +74 -0
- depdelta_cli/main.py +184 -0
- depdelta_cli/manifests.py +94 -0
- depdelta_cli/usage.py +391 -0
- depdelta_cli/web.py +68 -0
- depdelta_cli-0.1.0.dist-info/METADATA +166 -0
- depdelta_cli-0.1.0.dist-info/RECORD +17 -0
- depdelta_cli-0.1.0.dist-info/WHEEL +4 -0
- depdelta_cli-0.1.0.dist-info/entry_points.txt +2 -0
- depdelta_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
depdelta_cli/web.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# src/depdelta_cli/web.py
|
|
2
|
+
#
|
|
3
|
+
# JSON over HTTPS with the standard library, so the command needs nothing
|
|
4
|
+
# installed beyond Python and git.
|
|
5
|
+
|
|
6
|
+
import base64
|
|
7
|
+
import json
|
|
8
|
+
import urllib.error
|
|
9
|
+
import urllib.request
|
|
10
|
+
from dataclasses import dataclass, field
|
|
11
|
+
|
|
12
|
+
from depdelta_cli import __version__
|
|
13
|
+
|
|
14
|
+
USER_AGENT = f"depdelta-cli/{__version__}"
|
|
15
|
+
TIMEOUT_SECONDS = 60
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass
|
|
19
|
+
class Response:
|
|
20
|
+
status: int
|
|
21
|
+
body: object
|
|
22
|
+
headers: dict[str, str] = field(default_factory=dict)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class HttpError(Exception):
|
|
26
|
+
"""The server couldn't be reached."""
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _decode(raw: bytes) -> object:
|
|
30
|
+
text = raw.decode("utf-8", "replace")
|
|
31
|
+
# Gerrit prefixes JSON with )]}' against XSSI.
|
|
32
|
+
text = text.removeprefix(")]}'").strip()
|
|
33
|
+
if not text:
|
|
34
|
+
return None
|
|
35
|
+
try:
|
|
36
|
+
return json.loads(text)
|
|
37
|
+
except ValueError:
|
|
38
|
+
return text
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def request(
|
|
42
|
+
method: str,
|
|
43
|
+
url: str,
|
|
44
|
+
*,
|
|
45
|
+
body: object = None,
|
|
46
|
+
headers: dict[str, str] | None = None,
|
|
47
|
+
) -> Response:
|
|
48
|
+
"""Send ``body`` as JSON; any status comes back (only a network failure
|
|
49
|
+
raises)."""
|
|
50
|
+
data = None if body is None else json.dumps(body).encode()
|
|
51
|
+
sent = {"Accept": "application/json", "User-Agent": USER_AGENT}
|
|
52
|
+
if data is not None:
|
|
53
|
+
sent["Content-Type"] = "application/json"
|
|
54
|
+
sent.update(headers or {})
|
|
55
|
+
req = urllib.request.Request(url, data=data, headers=sent, method=method)
|
|
56
|
+
try:
|
|
57
|
+
with urllib.request.urlopen(req, timeout=TIMEOUT_SECONDS) as reply:
|
|
58
|
+
return Response(reply.status, _decode(reply.read()), dict(reply.headers))
|
|
59
|
+
except urllib.error.HTTPError as error:
|
|
60
|
+
return Response(error.code, _decode(error.read()), dict(error.headers))
|
|
61
|
+
except (urllib.error.URLError, TimeoutError, OSError) as error:
|
|
62
|
+
raise HttpError(f"{method} {url}: {error}") from error
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def basic(user: str, password: str) -> str:
|
|
66
|
+
"""An HTTP basic Authorization value."""
|
|
67
|
+
token = base64.b64encode(f"{user}:{password}".encode()).decode()
|
|
68
|
+
return f"Basic {token}"
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: depdelta-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: DepDelta for CI: review a change's dependency updates on Gerrit or GitLab.
|
|
5
|
+
Project-URL: Homepage, https://depdelta.com
|
|
6
|
+
Project-URL: Source, https://github.com/mbobiosio/depdelta-cli
|
|
7
|
+
Project-URL: Issues, https://github.com/mbobiosio/depdelta-cli/issues
|
|
8
|
+
Author: Mbuodile Obiosio
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: breaking-changes,ci,dependencies,gerrit,gitlab,renovate
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
18
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# depdelta-cli
|
|
23
|
+
|
|
24
|
+
DepDelta for CI on Gerrit and GitLab: the GitHub App's dependency review,
|
|
25
|
+
posted on the change.
|
|
26
|
+
|
|
27
|
+
On every change that touches a manifest or lockfile, `depdelta`:
|
|
28
|
+
|
|
29
|
+
1. sends the changed manifests and lockfiles (both ends) to DepDelta. Source
|
|
30
|
+
code is never sent;
|
|
31
|
+
2. gets back each update's verdict and, for npm and Maven, the declarations
|
|
32
|
+
it removes or changes;
|
|
33
|
+
3. looks for those declarations in the checkout, and sends only the hits
|
|
34
|
+
(path, line, symbol);
|
|
35
|
+
4. posts the review: a Gerrit change message (no vote), or one GitLab merge
|
|
36
|
+
request note that later pipelines edit in place.
|
|
37
|
+
|
|
38
|
+
Nine ecosystems: npm, PyPI, Maven, Composer, Cargo, RubyGems, pub.dev,
|
|
39
|
+
NuGet and Go. Needs Python 3.11+ and git, nothing else.
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
docker pull ghcr.io/mbobiosio/depdelta-cli:latest
|
|
43
|
+
# or
|
|
44
|
+
pip install depdelta-cli
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## API key
|
|
48
|
+
|
|
49
|
+
Make one in DepDelta → Settings → API keys for CI, and store it in your CI's
|
|
50
|
+
secrets as `DEPDELTA_API_KEY`. Each key gets 240 reviews an hour, waiting
|
|
51
|
+
on release notes included.
|
|
52
|
+
|
|
53
|
+
## Jenkins with Gerrit Trigger
|
|
54
|
+
|
|
55
|
+
The job runs on `patchset-created`. Gerrit Trigger sets `GERRIT_PROJECT`,
|
|
56
|
+
`GERRIT_CHANGE_NUMBER`, `GERRIT_PATCHSET_REVISION` and `GERRIT_CHANGE_URL`.
|
|
57
|
+
The review is posted with a Gerrit account's HTTP password: a service
|
|
58
|
+
account works best.
|
|
59
|
+
|
|
60
|
+
The checkout needs the patch set's parent: don't clone with depth 1 (or let
|
|
61
|
+
`depdelta` fetch it; it does when the parent is missing).
|
|
62
|
+
|
|
63
|
+
```groovy
|
|
64
|
+
pipeline {
|
|
65
|
+
agent { docker { image 'ghcr.io/mbobiosio/depdelta-cli:latest' } }
|
|
66
|
+
stages {
|
|
67
|
+
stage('DepDelta') {
|
|
68
|
+
steps {
|
|
69
|
+
withCredentials([
|
|
70
|
+
string(credentialsId: 'depdelta-api-key', variable: 'DEPDELTA_API_KEY'),
|
|
71
|
+
usernamePassword(credentialsId: 'gerrit-http',
|
|
72
|
+
usernameVariable: 'GERRIT_HTTP_USER',
|
|
73
|
+
passwordVariable: 'GERRIT_HTTP_PASSWORD'),
|
|
74
|
+
]) {
|
|
75
|
+
// A DepDelta outage shouldn't fail the build.
|
|
76
|
+
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
|
|
77
|
+
sh 'depdelta'
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Without Docker: `pip install depdelta-cli` on the agent, then the same
|
|
87
|
+
`sh 'depdelta'`.
|
|
88
|
+
|
|
89
|
+
`DEPDELTA_GERRIT_URL` overrides Gerrit's address when `GERRIT_CHANGE_URL`
|
|
90
|
+
isn't the REST root (a proxy, a different host name for agents).
|
|
91
|
+
|
|
92
|
+
Messages carry the tag `autogenerated:depdelta`, so Gerrit folds older patch
|
|
93
|
+
sets' reviews away, and notify only the change owner.
|
|
94
|
+
|
|
95
|
+
## GitLab CI
|
|
96
|
+
|
|
97
|
+
Runs in merge request pipelines. `CI_JOB_TOKEN` can't write notes: give the
|
|
98
|
+
job a project access token with the `api` scope (Reporter role is enough) as
|
|
99
|
+
`GITLAB_TOKEN`.
|
|
100
|
+
|
|
101
|
+
```yaml
|
|
102
|
+
depdelta:
|
|
103
|
+
image: ghcr.io/mbobiosio/depdelta-cli:latest
|
|
104
|
+
rules:
|
|
105
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
106
|
+
changes:
|
|
107
|
+
- "**/package.json"
|
|
108
|
+
- "**/package-lock.json"
|
|
109
|
+
- "**/pom.xml"
|
|
110
|
+
- "**/requirements*.txt"
|
|
111
|
+
- "**/pyproject.toml"
|
|
112
|
+
- "**/*.lock"
|
|
113
|
+
- "**/go.mod"
|
|
114
|
+
variables:
|
|
115
|
+
GIT_DEPTH: 0
|
|
116
|
+
script:
|
|
117
|
+
- depdelta
|
|
118
|
+
allow_failure: true
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Uses link to the files at the merge request's head commit.
|
|
122
|
+
|
|
123
|
+
## Options
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
depdelta [--repo .] [--base REV --head REV] [--print]
|
|
127
|
+
[--format markdown|text] [--wait 300]
|
|
128
|
+
[--fail-on never|breaking|review|unknown|safe]
|
|
129
|
+
[--api-url URL]
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
- `--print` prints the review instead of posting it. With `--base` and
|
|
133
|
+
`--head` (outside CI) it always prints:
|
|
134
|
+
`depdelta --base origin/main --head HEAD`.
|
|
135
|
+
- `--wait` is how long to wait for DepDelta to read release notes it hasn't
|
|
136
|
+
seen yet. After that the review posts as it stands, saying what is still
|
|
137
|
+
being read.
|
|
138
|
+
- `--fail-on breaking` exits 1 when an update is breaking, to fail the job.
|
|
139
|
+
|
|
140
|
+
Exit status: 0 posted (or nothing to review), 1 the `--fail-on` verdict was
|
|
141
|
+
met, 2 it couldn't review or post.
|
|
142
|
+
|
|
143
|
+
## Privacy
|
|
144
|
+
|
|
145
|
+
Only the changed manifests and lockfiles leave CI, plus, for updates with
|
|
146
|
+
removed or changed APIs, the path, line and symbol of each use found. The
|
|
147
|
+
source code stays in CI. Gerrit and GitLab credentials are sent only to your
|
|
148
|
+
Gerrit or GitLab.
|
|
149
|
+
|
|
150
|
+
## Development
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
uv sync
|
|
154
|
+
make check format test
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
`src/depdelta_cli/usage.py` is copied from depdelta-api
|
|
158
|
+
(`app/updates/utils/usage.py`), and `manifests.py` follows its manifest
|
|
159
|
+
names: change them there first, then here.
|
|
160
|
+
|
|
161
|
+
Releases: bump `version` in `pyproject.toml`, then tag `v<version>` and
|
|
162
|
+
push the tag. GitHub Actions publishes to PyPI and GHCR.
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
MIT
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
depdelta_cli/__init__.py,sha256=PrtKqjLUioam_zT4-GkWItPA3aFq1R5YaN6i6TWI1tI,104
|
|
2
|
+
depdelta_cli/__main__.py,sha256=PhDq9ZJjwXEVwD0xxXz02UAoTLevNIp67zUpTqUAkk0,43
|
|
3
|
+
depdelta_cli/api.py,sha256=a-WMU-kXjgoPlp6vOwJT5DWoLtbnIk5I8HBbBcrvKjA,4693
|
|
4
|
+
depdelta_cli/check.py,sha256=yrB7FjUtuHK2zFz3R08oq_CAAg8hoJG7TPAoqp3QSrU,1711
|
|
5
|
+
depdelta_cli/env.py,sha256=1RBX6pid3Iv3Le9U_DmWdSWt7cV98UPxI_Lf9MWtN2U,3560
|
|
6
|
+
depdelta_cli/gerrit.py,sha256=P-MGRtX06mWUH6GS-R1pOBLN6yTHeOQiPyVy15EgHd4,1456
|
|
7
|
+
depdelta_cli/git.py,sha256=Z9IPDm9Tzo6PZvVU6KQeL7smnyGdZhAVq-pbJBGmzgs,3843
|
|
8
|
+
depdelta_cli/gitlab.py,sha256=UJm8G6jAIgA33LqGFV30Xx1FOVENBFVywxI7k_NlNW8,2382
|
|
9
|
+
depdelta_cli/main.py,sha256=zemKoSbeSn4vnUfsqo2GxFWG58mFtTGereXE902t5cQ,6713
|
|
10
|
+
depdelta_cli/manifests.py,sha256=zYflTFoC7VypOD_UIPMWo70BR77MaJUV8csNLOKuZ-w,2460
|
|
11
|
+
depdelta_cli/usage.py,sha256=3cezotcmNq63HOyEK-eLIsHkSwWYXJ7gP5Ibh2aJK8E,14111
|
|
12
|
+
depdelta_cli/web.py,sha256=V102IjpI2ddAsMHZK9XdEt4OYzsvEyZqijmHG_h7iEE,1995
|
|
13
|
+
depdelta_cli-0.1.0.dist-info/METADATA,sha256=gUO9xrSgFvUPmSuaWe-zbXrZRVGuBmJLSkqse5SbrN0,5306
|
|
14
|
+
depdelta_cli-0.1.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
15
|
+
depdelta_cli-0.1.0.dist-info/entry_points.txt,sha256=nP5pi4zqZ3IeuLtpqWDhzPLVBtII0KMW8y6CVD-oEB8,52
|
|
16
|
+
depdelta_cli-0.1.0.dist-info/licenses/LICENSE,sha256=mzDXazQbJq8I2qLKTjgoA8lpCvb0D0m5CLJH0yDFJbg,1073
|
|
17
|
+
depdelta_cli-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mbuodile Obiosio
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|