pygitpub 0.0.60__tar.gz → 0.0.61__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.
- {pygitpub-0.0.60 → pygitpub-0.0.61}/PKG-INFO +2 -2
- {pygitpub-0.0.60 → pygitpub-0.0.61}/README.md +1 -1
- {pygitpub-0.0.60 → pygitpub-0.0.61}/pyproject.toml +1 -1
- {pygitpub-0.0.60 → pygitpub-0.0.61}/src/pygitpub/main.py +47 -3
- {pygitpub-0.0.60 → pygitpub-0.0.61}/src/pygitpub/static.py +1 -1
- {pygitpub-0.0.60 → pygitpub-0.0.61}/.gitignore +0 -0
- {pygitpub-0.0.60 → pygitpub-0.0.61}/LICENSE +0 -0
- {pygitpub-0.0.60 → pygitpub-0.0.61}/src/pygitpub/__init__.py +0 -0
- {pygitpub-0.0.60 → pygitpub-0.0.61}/src/pygitpub/configs.py +0 -0
- {pygitpub-0.0.60 → pygitpub-0.0.61}/src/pygitpub/utils/__init__.py +0 -0
- {pygitpub-0.0.60 → pygitpub-0.0.61}/src/pygitpub/utils/lua.py +0 -0
- {pygitpub-0.0.60 → pygitpub-0.0.61}/src/pygitpub/utils/misc.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pygitpub
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.61
|
|
4
4
|
Summary: Pygitpub will help you work with github
|
|
5
5
|
Project-URL: Homepage, https://github.com/veltzer/pygitpub
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/veltzer/pygitpub/issues
|
|
@@ -41,7 +41,7 @@ project website: https://veltzer.github.io/pygitpub
|
|
|
41
41
|
|
|
42
42
|
author: Mark Veltzer
|
|
43
43
|
|
|
44
|
-
version: 0.0.
|
|
44
|
+
version: 0.0.61
|
|
45
45
|
|
|
46
46
|

|
|
47
47
|
|
|
@@ -194,15 +194,17 @@ def repos_list() -> None:
|
|
|
194
194
|
|
|
195
195
|
|
|
196
196
|
@register_endpoint(
|
|
197
|
-
description="Cleanup old failing or un-needed runs
|
|
197
|
+
description="Cleanup old failing or un-needed runs, deployments, and releases in all repositories",
|
|
198
198
|
configs=[
|
|
199
199
|
ConfigGithub,
|
|
200
200
|
ConfigOutput,
|
|
201
201
|
ConfigAlgo,
|
|
202
202
|
],
|
|
203
203
|
)
|
|
204
|
-
def
|
|
204
|
+
def cleanup() -> None:
|
|
205
|
+
# pylint: disable=too-many-branches
|
|
205
206
|
for repo in yield_repos():
|
|
207
|
+
# 1. Cleanup workflow runs
|
|
206
208
|
for workflow in repo.get_workflows():
|
|
207
209
|
existing = 0
|
|
208
210
|
for run in workflow.get_runs():
|
|
@@ -216,7 +218,9 @@ def runs_cleanup() -> None:
|
|
|
216
218
|
if run.head_branch != "master":
|
|
217
219
|
delete_it = True
|
|
218
220
|
# if its not a paged build and it failed then delete it
|
|
219
|
-
if workflow.name != "pages-build-deployment" and run.conclusion
|
|
221
|
+
if workflow.name != "pages-build-deployment" and run.conclusion in (
|
|
222
|
+
"failure", "cancelled", "timed_out", "startup_failure", "action_required"
|
|
223
|
+
):
|
|
220
224
|
delete_it = True
|
|
221
225
|
if existing >= 4:
|
|
222
226
|
delete_it = True
|
|
@@ -226,6 +230,46 @@ def runs_cleanup() -> None:
|
|
|
226
230
|
else:
|
|
227
231
|
existing += 1
|
|
228
232
|
|
|
233
|
+
# 2. Cleanup deployments
|
|
234
|
+
existing_deployments = 0
|
|
235
|
+
for deployment in repo.get_deployments():
|
|
236
|
+
state = None
|
|
237
|
+
for status in deployment.get_statuses():
|
|
238
|
+
state = status.state
|
|
239
|
+
break
|
|
240
|
+
|
|
241
|
+
delete_it = False
|
|
242
|
+
if state in ("failure", "error") or existing_deployments >= 4:
|
|
243
|
+
delete_it = True
|
|
244
|
+
else:
|
|
245
|
+
existing_deployments += 1
|
|
246
|
+
|
|
247
|
+
if delete_it:
|
|
248
|
+
print(f"deleting deployment {repo.name} {deployment.id}")
|
|
249
|
+
try:
|
|
250
|
+
deployment.create_status("inactive")
|
|
251
|
+
except github.GithubException as e:
|
|
252
|
+
print(f"Failed to deactivate deployment: {e}")
|
|
253
|
+
try:
|
|
254
|
+
# pylint: disable=protected-access
|
|
255
|
+
status, _, _ = deployment._requester.requestJson("DELETE", deployment.url)
|
|
256
|
+
if status != 204:
|
|
257
|
+
print(f"Failed to delete deployment: HTTP {status}")
|
|
258
|
+
except github.GithubException as e:
|
|
259
|
+
print(f"Failed to delete deployment: {e}")
|
|
260
|
+
|
|
261
|
+
# 3. Cleanup releases
|
|
262
|
+
existing_releases = 0
|
|
263
|
+
for release in repo.get_releases():
|
|
264
|
+
if existing_releases >= 4:
|
|
265
|
+
print(f"deleting release {repo.name} {release.title}")
|
|
266
|
+
try:
|
|
267
|
+
release.delete_release()
|
|
268
|
+
except github.GithubException as e:
|
|
269
|
+
print(f"Failed to delete release: {e}")
|
|
270
|
+
else:
|
|
271
|
+
existing_releases += 1
|
|
272
|
+
|
|
229
273
|
|
|
230
274
|
@register_endpoint(
|
|
231
275
|
description="Show all runs in all workflows in all repos",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|