depdelta-cli 0.1.0__tar.gz → 0.2.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.
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/.github/workflows/release.yml +0 -1
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/.gitignore +1 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/PKG-INFO +74 -13
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/README.md +72 -12
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/pyproject.toml +2 -1
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/src/depdelta_cli/__init__.py +1 -1
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/src/depdelta_cli/api.py +13 -1
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/src/depdelta_cli/git.py +13 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/src/depdelta_cli/main.py +23 -7
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/src/depdelta_cli/manifests.py +7 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/tests/test_api.py +28 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/tests/test_git.py +19 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/tests/test_main.py +46 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/tests/test_manifests.py +7 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/uv.lock +1 -1
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/.dockerignore +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/.github/workflows/ci.yml +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/Dockerfile +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/LICENSE +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/Makefile +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/src/depdelta_cli/__main__.py +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/src/depdelta_cli/check.py +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/src/depdelta_cli/env.py +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/src/depdelta_cli/gerrit.py +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/src/depdelta_cli/gitlab.py +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/src/depdelta_cli/usage.py +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/src/depdelta_cli/web.py +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/tests/conftest.py +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/tests/helpers.py +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/tests/test_check.py +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/tests/test_env.py +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/tests/test_gerrit.py +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/tests/test_gitlab.py +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/tests/test_usage.py +0 -0
- {depdelta_cli-0.1.0 → depdelta_cli-0.2.0}/tests/test_web.py +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: depdelta-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: DepDelta for CI: review a change's dependency updates on Gerrit or GitLab.
|
|
5
5
|
Project-URL: Homepage, https://depdelta.com
|
|
6
|
+
Project-URL: Documentation, https://depdelta.com/ci
|
|
6
7
|
Project-URL: Source, https://github.com/mbobiosio/depdelta-cli
|
|
7
8
|
Project-URL: Issues, https://github.com/mbobiosio/depdelta-cli/issues
|
|
8
9
|
Author: Mbuodile Obiosio
|
|
@@ -21,8 +22,26 @@ Description-Content-Type: text/markdown
|
|
|
21
22
|
|
|
22
23
|
# depdelta-cli
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
[](https://pypi.org/project/depdelta-cli/)
|
|
26
|
+
[](https://github.com/mbobiosio/depdelta-cli/actions/workflows/ci.yml)
|
|
27
|
+
[](LICENSE)
|
|
28
|
+
|
|
29
|
+
Know what a dependency update breaks before you merge, on Gerrit and GitLab.
|
|
30
|
+
|
|
31
|
+
[DepDelta](https://depdelta.com) reads every release's notes, security
|
|
32
|
+
advisories and published API between two versions of a package, and says
|
|
33
|
+
what changed and what will break: see
|
|
34
|
+
[eslint 8.57.0 → 9.0.0](https://depdelta.com/npm/eslint/compare/8.57.0...9.0.0)
|
|
35
|
+
for an example. `depdelta` brings that review to your CI. On every change that
|
|
36
|
+
updates a dependency (from Renovate or anyone) it posts the breaking changes,
|
|
37
|
+
security fixes, removed APIs and where your code uses them, right on the
|
|
38
|
+
change.
|
|
39
|
+
|
|
40
|
+
On GitHub, the [DepDelta GitHub app](https://depdelta.com/github-app) does
|
|
41
|
+
this with no CI job. Setup guide, example review and FAQ:
|
|
42
|
+
**[depdelta.com/ci](https://depdelta.com/ci)**.
|
|
43
|
+
|
|
44
|
+
## How it works
|
|
26
45
|
|
|
27
46
|
On every change that touches a manifest or lockfile, `depdelta`:
|
|
28
47
|
|
|
@@ -33,10 +52,21 @@ On every change that touches a manifest or lockfile, `depdelta`:
|
|
|
33
52
|
3. looks for those declarations in the checkout, and sends only the hits
|
|
34
53
|
(path, line, symbol);
|
|
35
54
|
4. posts the review: a Gerrit change message (no vote), or one GitLab merge
|
|
36
|
-
request note that later pipelines edit in place.
|
|
55
|
+
request note that later pipelines edit in place. Each update links to its
|
|
56
|
+
full comparison on depdelta.com.
|
|
57
|
+
|
|
58
|
+
Beyond each update, the review says what the change does to your lockfiles:
|
|
59
|
+
packages before and after, new and removed direct dependencies (dev or
|
|
60
|
+
production, and what each pulls in), and packages that newly run code at
|
|
61
|
+
install time (an npm install script, a Python package built from source, a
|
|
62
|
+
Composer plugin, a Cargo build script).
|
|
37
63
|
|
|
38
64
|
Nine ecosystems: npm, PyPI, Maven, Composer, Cargo, RubyGems, pub.dev,
|
|
39
|
-
NuGet and Go.
|
|
65
|
+
NuGet and Go. For Android and other Gradle builds that means
|
|
66
|
+
`build.gradle(.kts)`, `settings.gradle(.kts)`, version catalogs
|
|
67
|
+
(`gradle/libs.versions.toml`, libraries and plugins) and
|
|
68
|
+
`gradle.lockfile`; plugins count as updates too (AGP, Kotlin, KSP, Hilt).
|
|
69
|
+
Needs Python 3.11+ and git, nothing else.
|
|
40
70
|
|
|
41
71
|
```
|
|
42
72
|
docker pull ghcr.io/mbobiosio/depdelta-cli:latest
|
|
@@ -46,9 +76,10 @@ pip install depdelta-cli
|
|
|
46
76
|
|
|
47
77
|
## API key
|
|
48
78
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
79
|
+
Sign in at [depdelta.com](https://depdelta.com) with GitHub or Google,
|
|
80
|
+
make a key in [Settings → API keys for CI](https://depdelta.com/settings),
|
|
81
|
+
and store it in your CI's secrets as `DEPDELTA_API_KEY`. Each key gets 240
|
|
82
|
+
reviews an hour, waiting on release notes included.
|
|
52
83
|
|
|
53
84
|
## Jenkins with Gerrit Trigger
|
|
54
85
|
|
|
@@ -138,14 +169,44 @@ depdelta [--repo .] [--base REV --head REV] [--print]
|
|
|
138
169
|
- `--fail-on breaking` exits 1 when an update is breaking, to fail the job.
|
|
139
170
|
|
|
140
171
|
Exit status: 0 posted (or nothing to review), 1 the `--fail-on` verdict was
|
|
141
|
-
met, 2 it couldn't review or
|
|
172
|
+
met or `.depdelta.yml` blocks new install-time code, 2 it couldn't review or
|
|
173
|
+
post.
|
|
174
|
+
|
|
175
|
+
## .depdelta.yml
|
|
176
|
+
|
|
177
|
+
An optional file at the repository root, read at the change's head commit.
|
|
178
|
+
The GitHub app reads the same file.
|
|
179
|
+
|
|
180
|
+
```yaml
|
|
181
|
+
install_scripts: warn # off | warn (default) | block
|
|
182
|
+
allow_install_scripts: # never flagged
|
|
183
|
+
- esbuild
|
|
184
|
+
- sharp
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
- `warn` flags each package that newly runs code at install.
|
|
188
|
+
- `block` flags them too, and `depdelta` exits 1, so the job fails until the
|
|
189
|
+
package is allowed or removed.
|
|
190
|
+
- `off` leaves install-time code out of the review.
|
|
191
|
+
|
|
192
|
+
`depdelta` sends the file as it is; DepDelta reads it. A file it can't read
|
|
193
|
+
falls back to the defaults, and the review says why.
|
|
142
194
|
|
|
143
195
|
## Privacy
|
|
144
196
|
|
|
145
197
|
Only the changed manifests and lockfiles leave CI, plus, for updates with
|
|
146
198
|
removed or changed APIs, the path, line and symbol of each use found. The
|
|
147
199
|
source code stays in CI. Gerrit and GitLab credentials are sent only to your
|
|
148
|
-
Gerrit or GitLab.
|
|
200
|
+
Gerrit or GitLab. The [privacy policy](https://depdelta.com/privacy) has the
|
|
201
|
+
details.
|
|
202
|
+
|
|
203
|
+
## Links
|
|
204
|
+
|
|
205
|
+
- Website: [depdelta.com](https://depdelta.com)
|
|
206
|
+
- CI setup guide: [depdelta.com/ci](https://depdelta.com/ci)
|
|
207
|
+
- GitHub app: [depdelta.com/github-app](https://depdelta.com/github-app)
|
|
208
|
+
- Check a whole project's dependencies: [depdelta.com/report](https://depdelta.com/report)
|
|
209
|
+
- Issues: [github.com/mbobiosio/depdelta-cli/issues](https://github.com/mbobiosio/depdelta-cli/issues)
|
|
149
210
|
|
|
150
211
|
## Development
|
|
151
212
|
|
|
@@ -154,9 +215,9 @@ uv sync
|
|
|
154
215
|
make check format test
|
|
155
216
|
```
|
|
156
217
|
|
|
157
|
-
`src/depdelta_cli/usage.py` is
|
|
158
|
-
|
|
159
|
-
|
|
218
|
+
`src/depdelta_cli/usage.py` is the same usage matcher the DepDelta service
|
|
219
|
+
and GitHub app run, and `manifests.py` uses the same manifest names: changes
|
|
220
|
+
to either start in the service, then are copied here.
|
|
160
221
|
|
|
161
222
|
Releases: bump `version` in `pyproject.toml`, then tag `v<version>` and
|
|
162
223
|
push the tag. GitHub Actions publishes to PyPI and GHCR.
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
# depdelta-cli
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
[](https://pypi.org/project/depdelta-cli/)
|
|
4
|
+
[](https://github.com/mbobiosio/depdelta-cli/actions/workflows/ci.yml)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
Know what a dependency update breaks before you merge, on Gerrit and GitLab.
|
|
8
|
+
|
|
9
|
+
[DepDelta](https://depdelta.com) reads every release's notes, security
|
|
10
|
+
advisories and published API between two versions of a package, and says
|
|
11
|
+
what changed and what will break: see
|
|
12
|
+
[eslint 8.57.0 → 9.0.0](https://depdelta.com/npm/eslint/compare/8.57.0...9.0.0)
|
|
13
|
+
for an example. `depdelta` brings that review to your CI. On every change that
|
|
14
|
+
updates a dependency (from Renovate or anyone) it posts the breaking changes,
|
|
15
|
+
security fixes, removed APIs and where your code uses them, right on the
|
|
16
|
+
change.
|
|
17
|
+
|
|
18
|
+
On GitHub, the [DepDelta GitHub app](https://depdelta.com/github-app) does
|
|
19
|
+
this with no CI job. Setup guide, example review and FAQ:
|
|
20
|
+
**[depdelta.com/ci](https://depdelta.com/ci)**.
|
|
21
|
+
|
|
22
|
+
## How it works
|
|
5
23
|
|
|
6
24
|
On every change that touches a manifest or lockfile, `depdelta`:
|
|
7
25
|
|
|
@@ -12,10 +30,21 @@ On every change that touches a manifest or lockfile, `depdelta`:
|
|
|
12
30
|
3. looks for those declarations in the checkout, and sends only the hits
|
|
13
31
|
(path, line, symbol);
|
|
14
32
|
4. posts the review: a Gerrit change message (no vote), or one GitLab merge
|
|
15
|
-
request note that later pipelines edit in place.
|
|
33
|
+
request note that later pipelines edit in place. Each update links to its
|
|
34
|
+
full comparison on depdelta.com.
|
|
35
|
+
|
|
36
|
+
Beyond each update, the review says what the change does to your lockfiles:
|
|
37
|
+
packages before and after, new and removed direct dependencies (dev or
|
|
38
|
+
production, and what each pulls in), and packages that newly run code at
|
|
39
|
+
install time (an npm install script, a Python package built from source, a
|
|
40
|
+
Composer plugin, a Cargo build script).
|
|
16
41
|
|
|
17
42
|
Nine ecosystems: npm, PyPI, Maven, Composer, Cargo, RubyGems, pub.dev,
|
|
18
|
-
NuGet and Go.
|
|
43
|
+
NuGet and Go. For Android and other Gradle builds that means
|
|
44
|
+
`build.gradle(.kts)`, `settings.gradle(.kts)`, version catalogs
|
|
45
|
+
(`gradle/libs.versions.toml`, libraries and plugins) and
|
|
46
|
+
`gradle.lockfile`; plugins count as updates too (AGP, Kotlin, KSP, Hilt).
|
|
47
|
+
Needs Python 3.11+ and git, nothing else.
|
|
19
48
|
|
|
20
49
|
```
|
|
21
50
|
docker pull ghcr.io/mbobiosio/depdelta-cli:latest
|
|
@@ -25,9 +54,10 @@ pip install depdelta-cli
|
|
|
25
54
|
|
|
26
55
|
## API key
|
|
27
56
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
57
|
+
Sign in at [depdelta.com](https://depdelta.com) with GitHub or Google,
|
|
58
|
+
make a key in [Settings → API keys for CI](https://depdelta.com/settings),
|
|
59
|
+
and store it in your CI's secrets as `DEPDELTA_API_KEY`. Each key gets 240
|
|
60
|
+
reviews an hour, waiting on release notes included.
|
|
31
61
|
|
|
32
62
|
## Jenkins with Gerrit Trigger
|
|
33
63
|
|
|
@@ -117,14 +147,44 @@ depdelta [--repo .] [--base REV --head REV] [--print]
|
|
|
117
147
|
- `--fail-on breaking` exits 1 when an update is breaking, to fail the job.
|
|
118
148
|
|
|
119
149
|
Exit status: 0 posted (or nothing to review), 1 the `--fail-on` verdict was
|
|
120
|
-
met, 2 it couldn't review or
|
|
150
|
+
met or `.depdelta.yml` blocks new install-time code, 2 it couldn't review or
|
|
151
|
+
post.
|
|
152
|
+
|
|
153
|
+
## .depdelta.yml
|
|
154
|
+
|
|
155
|
+
An optional file at the repository root, read at the change's head commit.
|
|
156
|
+
The GitHub app reads the same file.
|
|
157
|
+
|
|
158
|
+
```yaml
|
|
159
|
+
install_scripts: warn # off | warn (default) | block
|
|
160
|
+
allow_install_scripts: # never flagged
|
|
161
|
+
- esbuild
|
|
162
|
+
- sharp
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
- `warn` flags each package that newly runs code at install.
|
|
166
|
+
- `block` flags them too, and `depdelta` exits 1, so the job fails until the
|
|
167
|
+
package is allowed or removed.
|
|
168
|
+
- `off` leaves install-time code out of the review.
|
|
169
|
+
|
|
170
|
+
`depdelta` sends the file as it is; DepDelta reads it. A file it can't read
|
|
171
|
+
falls back to the defaults, and the review says why.
|
|
121
172
|
|
|
122
173
|
## Privacy
|
|
123
174
|
|
|
124
175
|
Only the changed manifests and lockfiles leave CI, plus, for updates with
|
|
125
176
|
removed or changed APIs, the path, line and symbol of each use found. The
|
|
126
177
|
source code stays in CI. Gerrit and GitLab credentials are sent only to your
|
|
127
|
-
Gerrit or GitLab.
|
|
178
|
+
Gerrit or GitLab. The [privacy policy](https://depdelta.com/privacy) has the
|
|
179
|
+
details.
|
|
180
|
+
|
|
181
|
+
## Links
|
|
182
|
+
|
|
183
|
+
- Website: [depdelta.com](https://depdelta.com)
|
|
184
|
+
- CI setup guide: [depdelta.com/ci](https://depdelta.com/ci)
|
|
185
|
+
- GitHub app: [depdelta.com/github-app](https://depdelta.com/github-app)
|
|
186
|
+
- Check a whole project's dependencies: [depdelta.com/report](https://depdelta.com/report)
|
|
187
|
+
- Issues: [github.com/mbobiosio/depdelta-cli/issues](https://github.com/mbobiosio/depdelta-cli/issues)
|
|
128
188
|
|
|
129
189
|
## Development
|
|
130
190
|
|
|
@@ -133,9 +193,9 @@ uv sync
|
|
|
133
193
|
make check format test
|
|
134
194
|
```
|
|
135
195
|
|
|
136
|
-
`src/depdelta_cli/usage.py` is
|
|
137
|
-
|
|
138
|
-
|
|
196
|
+
`src/depdelta_cli/usage.py` is the same usage matcher the DepDelta service
|
|
197
|
+
and GitHub app run, and `manifests.py` uses the same manifest names: changes
|
|
198
|
+
to either start in the service, then are copied here.
|
|
139
199
|
|
|
140
200
|
Releases: bump `version` in `pyproject.toml`, then tag `v<version>` and
|
|
141
201
|
push the tag. GitHub Actions publishes to PyPI and GHCR.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "depdelta-cli"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.2.0"
|
|
4
4
|
description = "DepDelta for CI: review a change's dependency updates on Gerrit or GitLab."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -21,6 +21,7 @@ classifiers = [
|
|
|
21
21
|
|
|
22
22
|
[project.urls]
|
|
23
23
|
Homepage = "https://depdelta.com"
|
|
24
|
+
Documentation = "https://depdelta.com/ci"
|
|
24
25
|
Source = "https://github.com/mbobiosio/depdelta-cli"
|
|
25
26
|
Issues = "https://github.com/mbobiosio/depdelta-cli/issues"
|
|
26
27
|
|
|
@@ -32,6 +32,10 @@ class Review:
|
|
|
32
32
|
retry_after: int | None
|
|
33
33
|
verdict: str | None
|
|
34
34
|
updates: list[dict]
|
|
35
|
+
#: `.depdelta.yml` sets install_scripts: block and something is flagged.
|
|
36
|
+
blocked: bool = False
|
|
37
|
+
#: What was wrong with `.depdelta.yml`, one line each.
|
|
38
|
+
notes: tuple[str, ...] = ()
|
|
35
39
|
|
|
36
40
|
|
|
37
41
|
def _message(body: object) -> str:
|
|
@@ -60,6 +64,8 @@ def _review(data: dict) -> Review:
|
|
|
60
64
|
retry_after=data.get("retry_after"),
|
|
61
65
|
verdict=data.get("verdict"),
|
|
62
66
|
updates=list(data.get("updates") or []),
|
|
67
|
+
blocked=data.get("blocked") is True,
|
|
68
|
+
notes=tuple(str(n) for n in data.get("notes") or ()),
|
|
63
69
|
)
|
|
64
70
|
|
|
65
71
|
|
|
@@ -84,6 +90,7 @@ class DepDelta:
|
|
|
84
90
|
usage: list[dict] | None = None,
|
|
85
91
|
fmt: str = "markdown",
|
|
86
92
|
source_url: str | None = None,
|
|
93
|
+
config: str | None = None,
|
|
87
94
|
) -> Review:
|
|
88
95
|
"""One ask; server errors and network failures are tried again."""
|
|
89
96
|
payload: dict = {
|
|
@@ -93,6 +100,8 @@ class DepDelta:
|
|
|
93
100
|
}
|
|
94
101
|
if source_url:
|
|
95
102
|
payload["source_url"] = source_url
|
|
103
|
+
if config is not None:
|
|
104
|
+
payload["config"] = config
|
|
96
105
|
for attempt in range(1, ATTEMPTS + 1):
|
|
97
106
|
try:
|
|
98
107
|
reply = web.request(
|
|
@@ -127,13 +136,16 @@ class DepDelta:
|
|
|
127
136
|
usage: list[dict] | None = None,
|
|
128
137
|
fmt: str = "markdown",
|
|
129
138
|
source_url: str | None = None,
|
|
139
|
+
config: str | None = None,
|
|
130
140
|
wait: float = 300,
|
|
131
141
|
) -> Review:
|
|
132
142
|
"""Ask until the review is ready or ``wait`` seconds pass; then the
|
|
133
143
|
last answer (still `indexing`) is the review."""
|
|
134
144
|
deadline = self.clock() + wait
|
|
135
145
|
while True:
|
|
136
|
-
review = self.ask(
|
|
146
|
+
review = self.ask(
|
|
147
|
+
files, usage=usage, fmt=fmt, source_url=source_url, config=config
|
|
148
|
+
)
|
|
137
149
|
if review.status != "indexing":
|
|
138
150
|
return review
|
|
139
151
|
pause = review.retry_after or POLL_SECONDS
|
|
@@ -52,6 +52,19 @@ def _show(repo: str, rev: str, path: str) -> str | None:
|
|
|
52
52
|
return result.stdout.decode("utf-8", "replace")
|
|
53
53
|
|
|
54
54
|
|
|
55
|
+
#: The repository's DepDelta settings, read at the change's head.
|
|
56
|
+
CONFIG_PATH = ".depdelta.yml"
|
|
57
|
+
#: DepDelta reads at most this much of it; past it, sending one character
|
|
58
|
+
#: more is enough for the review to say the file is too big.
|
|
59
|
+
MAX_CONFIG = 16 * 1024
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def config_file(repo: str, head: str) -> str | None:
|
|
63
|
+
"""The `.depdelta.yml` text at ``head``, or None when there's none."""
|
|
64
|
+
text = _show(repo, head, CONFIG_PATH)
|
|
65
|
+
return text[: MAX_CONFIG + 1] if text is not None else None
|
|
66
|
+
|
|
67
|
+
|
|
55
68
|
def changed_manifests(repo: str, base: str, head: str) -> list[ChangedFile]:
|
|
56
69
|
"""The manifests and lockfiles the change touched, at both ends."""
|
|
57
70
|
names = _out(repo, "diff", "--name-only", "--no-renames", base, head, "--")
|
|
@@ -9,8 +9,12 @@
|
|
|
9
9
|
# 3. The command looks for those in the checkout and sends what it found;
|
|
10
10
|
# the review then says where the code is hit.
|
|
11
11
|
#
|
|
12
|
+
# The repository's `.depdelta.yml` (at the change's head) goes along as is:
|
|
13
|
+
# DepDelta reads it, so this command needs no YAML parser.
|
|
14
|
+
#
|
|
12
15
|
# Exit status: 0 posted (or nothing to review), 1 the --fail-on verdict was
|
|
13
|
-
# met, 2 it couldn't review
|
|
16
|
+
# met or `.depdelta.yml` blocks new install-time code, 2 it couldn't review
|
|
17
|
+
# or post.
|
|
14
18
|
|
|
15
19
|
import argparse
|
|
16
20
|
import os
|
|
@@ -21,7 +25,13 @@ from depdelta_cli import __version__, check, gerrit, gitlab, web
|
|
|
21
25
|
from depdelta_cli.api import DEFAULT_API_URL, ApiError, DepDelta, Review
|
|
22
26
|
from depdelta_cli.env import Change, EnvError, GerritChange, GitLabMergeRequest
|
|
23
27
|
from depdelta_cli.env import detect as detect_change
|
|
24
|
-
from depdelta_cli.git import
|
|
28
|
+
from depdelta_cli.git import (
|
|
29
|
+
GitError,
|
|
30
|
+
changed_manifests,
|
|
31
|
+
config_file,
|
|
32
|
+
ensure_commit,
|
|
33
|
+
source_files,
|
|
34
|
+
)
|
|
25
35
|
|
|
26
36
|
#: depdelta-api pull_diff MAX_FILES: manifests reviewed per change.
|
|
27
37
|
MAX_FILES = 40
|
|
@@ -96,17 +106,17 @@ def _review(
|
|
|
96
106
|
files: list,
|
|
97
107
|
fmt: str,
|
|
98
108
|
source_url: str | None,
|
|
109
|
+
config: str | None,
|
|
99
110
|
) -> Review:
|
|
100
|
-
|
|
111
|
+
options = {"fmt": fmt, "source_url": source_url, "config": config}
|
|
112
|
+
review = client.review(files, wait=args.wait, **options)
|
|
101
113
|
wanted = check.ecosystems(review.updates)
|
|
102
114
|
if not wanted:
|
|
103
115
|
return review
|
|
104
116
|
sources = source_files(args.repo, wanted)
|
|
105
117
|
usage = check.usage(review.updates, sources)
|
|
106
118
|
log(f"Usage check: {sum(u['total'] for u in usage)} uses found.")
|
|
107
|
-
return client.review(
|
|
108
|
-
files, usage=usage, fmt=fmt, source_url=source_url, wait=args.wait
|
|
109
|
-
)
|
|
119
|
+
return client.review(files, usage=usage, wait=args.wait, **options)
|
|
110
120
|
|
|
111
121
|
|
|
112
122
|
def _post(change: Change, review: Review, env: Mapping[str, str]) -> None:
|
|
@@ -160,8 +170,11 @@ def run(argv: Sequence[str] | None = None, env: Mapping[str, str] | None = None)
|
|
|
160
170
|
"text" if change and change.platform == "gerrit" else "markdown"
|
|
161
171
|
)
|
|
162
172
|
source_url = change.source_url if change else None
|
|
163
|
-
|
|
173
|
+
config = config_file(args.repo, head)
|
|
174
|
+
review = _review(DepDelta(key, api_url), args, files, fmt, source_url, config)
|
|
164
175
|
log(f"{review.label} ({len(review.updates)} updates).")
|
|
176
|
+
for note in review.notes:
|
|
177
|
+
log(f".depdelta.yml: {note}.")
|
|
165
178
|
if change is None or args.print_only:
|
|
166
179
|
print(review.body)
|
|
167
180
|
else:
|
|
@@ -177,6 +190,9 @@ def run(argv: Sequence[str] | None = None, env: Mapping[str, str] | None = None)
|
|
|
177
190
|
) as error:
|
|
178
191
|
log(str(error))
|
|
179
192
|
return 2
|
|
193
|
+
if review.blocked:
|
|
194
|
+
log("New install-time code, and .depdelta.yml sets install_scripts: block.")
|
|
195
|
+
return 1
|
|
180
196
|
return 1 if failed(review, args.fail_on) else 0
|
|
181
197
|
|
|
182
198
|
|
|
@@ -23,6 +23,10 @@ MANIFEST_NAMES = frozenset(
|
|
|
23
23
|
"gems.rb",
|
|
24
24
|
"go.mod",
|
|
25
25
|
"go.sum",
|
|
26
|
+
# Gradle dependency locking.
|
|
27
|
+
"gradle.lockfile",
|
|
28
|
+
"buildscript-gradle.lockfile",
|
|
29
|
+
"settings-gradle.lockfile",
|
|
26
30
|
"libs.versions.toml",
|
|
27
31
|
"npm-shrinkwrap.json",
|
|
28
32
|
"package-lock.json",
|
|
@@ -37,6 +41,9 @@ MANIFEST_NAMES = frozenset(
|
|
|
37
41
|
"pubspec.yaml",
|
|
38
42
|
"pyproject.toml",
|
|
39
43
|
"requirements.txt",
|
|
44
|
+
# pluginManagement { plugins { … } }: plugin versions.
|
|
45
|
+
"settings.gradle",
|
|
46
|
+
"settings.gradle.kts",
|
|
40
47
|
"uv.lock",
|
|
41
48
|
"yarn.lock",
|
|
42
49
|
}
|
|
@@ -160,3 +160,31 @@ def test_review_gives_up_waiting(monkeypatch, clock):
|
|
|
160
160
|
assert got.status == "indexing"
|
|
161
161
|
assert clock.slept == [20]
|
|
162
162
|
assert len(fake.calls) == 2
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def test_ask_sends_the_config(monkeypatch, clock):
|
|
166
|
+
data = {
|
|
167
|
+
"status": "ready",
|
|
168
|
+
"label": "x",
|
|
169
|
+
"body": "b",
|
|
170
|
+
"blocked": True,
|
|
171
|
+
"notes": ["install_scripts must be off, warn or block; using warn"],
|
|
172
|
+
}
|
|
173
|
+
fake = FakeWeb(ok({"data": data}))
|
|
174
|
+
monkeypatch.setattr(web, "request", fake)
|
|
175
|
+
|
|
176
|
+
got = client(clock).ask(FILES, config="install_scripts: block\n")
|
|
177
|
+
|
|
178
|
+
assert fake.calls[0]["body"]["config"] == "install_scripts: block\n"
|
|
179
|
+
assert got.blocked is True
|
|
180
|
+
assert got.notes == ("install_scripts must be off, warn or block; using warn",)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def test_ask_without_config_sends_none(monkeypatch, clock):
|
|
184
|
+
fake = FakeWeb(review())
|
|
185
|
+
monkeypatch.setattr(web, "request", fake)
|
|
186
|
+
|
|
187
|
+
got = client(clock).ask(FILES)
|
|
188
|
+
|
|
189
|
+
assert "config" not in fake.calls[0]["body"]
|
|
190
|
+
assert (got.blocked, got.notes) == (False, ())
|
|
@@ -8,6 +8,7 @@ from depdelta_cli.git import (
|
|
|
8
8
|
GitError,
|
|
9
9
|
SourceFiles,
|
|
10
10
|
changed_manifests,
|
|
11
|
+
config_file,
|
|
11
12
|
ensure_commit,
|
|
12
13
|
source_files,
|
|
13
14
|
)
|
|
@@ -117,3 +118,21 @@ def test_source_files_not_a_repository(tmp_path):
|
|
|
117
118
|
|
|
118
119
|
def test_show_missing_file(repo):
|
|
119
120
|
assert module._show(str(repo), "HEAD", "nope") is None
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def test_config_file_success(repo, commit):
|
|
124
|
+
head = commit({".depdelta.yml": "install_scripts: block\n"})
|
|
125
|
+
|
|
126
|
+
assert config_file(str(repo), head) == "install_scripts: block\n"
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def test_config_file_missing(repo, commit):
|
|
130
|
+
assert config_file(str(repo), commit({"a.ts": "1"})) is None
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def test_config_file_cut_past_the_limit(repo, commit, monkeypatch):
|
|
134
|
+
monkeypatch.setattr(module, "MAX_CONFIG", 4)
|
|
135
|
+
head = commit({".depdelta.yml": "abcdefgh"})
|
|
136
|
+
|
|
137
|
+
# One character more than DepDelta reads: enough for it to say so.
|
|
138
|
+
assert config_file(str(repo), head) == "abcde"
|
|
@@ -256,3 +256,49 @@ def test_failed(verdicts, fail_on, expected):
|
|
|
256
256
|
|
|
257
257
|
def test_marker_matches_the_api():
|
|
258
258
|
assert gitlab.MARKER == "<!-- depdelta:review -->"
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def _blocked(blocked: bool = True, notes: list | None = None):
|
|
262
|
+
return ok(
|
|
263
|
+
{
|
|
264
|
+
"data": {
|
|
265
|
+
"status": "ready",
|
|
266
|
+
"label": "🟢 Safe",
|
|
267
|
+
"body": "### DepDelta review",
|
|
268
|
+
"verdict": "safe",
|
|
269
|
+
"updates": [],
|
|
270
|
+
"blocked": blocked,
|
|
271
|
+
"notes": notes or [],
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def test_run_sends_the_config_and_blocks(repo, commit, monkeypatch, capsys):
|
|
278
|
+
base = commit({"package.json": '{"dependencies": {}}'})
|
|
279
|
+
head = commit(
|
|
280
|
+
{
|
|
281
|
+
"package.json": '{"dependencies": {"runner": "1.0.0"}}',
|
|
282
|
+
".depdelta.yml": "install_scripts: block\nextra: [\n",
|
|
283
|
+
}
|
|
284
|
+
)
|
|
285
|
+
fake = FakeWeb(_blocked(notes=["not valid YAML; using the defaults"]))
|
|
286
|
+
monkeypatch.setattr(web, "request", fake)
|
|
287
|
+
|
|
288
|
+
code = run(["--repo", str(repo), "--base", base, "--head", head], KEY)
|
|
289
|
+
|
|
290
|
+
assert code == 1
|
|
291
|
+
assert fake.calls[0]["body"]["config"] == "install_scripts: block\nextra: [\n"
|
|
292
|
+
err = capsys.readouterr().err
|
|
293
|
+
assert ".depdelta.yml: not valid YAML; using the defaults." in err
|
|
294
|
+
assert "sets install_scripts: block" in err
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def test_run_not_blocked_passes(repo, commit, monkeypatch):
|
|
298
|
+
base = commit({"package.json": '{"dependencies": {}}'})
|
|
299
|
+
head = commit({"package.json": '{"dependencies": {"runner": "1.0.0"}}'})
|
|
300
|
+
fake = FakeWeb(_blocked(blocked=False))
|
|
301
|
+
monkeypatch.setattr(web, "request", fake)
|
|
302
|
+
|
|
303
|
+
assert run(["--repo", str(repo), "--base", base, "--head", head], KEY) == 0
|
|
304
|
+
assert "config" not in fake.calls[0]["body"]
|
|
@@ -14,6 +14,13 @@ from depdelta_cli.manifests import is_manifest, skipped
|
|
|
14
14
|
"requirements-dev.txt",
|
|
15
15
|
"gradle/libs.versions.toml",
|
|
16
16
|
"gradle/deps.versions.toml",
|
|
17
|
+
"build.gradle",
|
|
18
|
+
"app/build.gradle.kts",
|
|
19
|
+
"settings.gradle.kts",
|
|
20
|
+
"settings.gradle",
|
|
21
|
+
"app/gradle.lockfile",
|
|
22
|
+
"buildscript-gradle.lockfile",
|
|
23
|
+
"settings-gradle.lockfile",
|
|
17
24
|
"src/App/App.csproj",
|
|
18
25
|
"Lib.fsproj",
|
|
19
26
|
"Gemfile.lock",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|