Public Access
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11ce99756c | ||
|
|
6149167ba2 | ||
|
|
014ab0b63f | ||
|
|
2a3ee1ec96 | ||
|
|
5d4968eb21 | ||
|
|
33cfbb0f41 | ||
|
|
598238e4d6 | ||
|
|
925b99b7db |
@@ -108,7 +108,8 @@ jobs:
|
|||||||
--repo "${{ github.repository }}" \
|
--repo "${{ github.repository }}" \
|
||||||
--run-id "${{ github.run_id }}" \
|
--run-id "${{ github.run_id }}" \
|
||||||
--workflow "build-images/build-and-push" \
|
--workflow "build-images/build-and-push" \
|
||||||
--commit "${{ github.sha }}"
|
--commit "${{ github.sha }}" \
|
||||||
|
--auto-login
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
needs: [build-and-push]
|
needs: [build-and-push]
|
||||||
|
|||||||
@@ -122,7 +122,8 @@ jobs:
|
|||||||
--repo "${{ github.repository }}" \
|
--repo "${{ github.repository }}" \
|
||||||
--run-id "${{ github.run_id }}" \
|
--run-id "${{ github.run_id }}" \
|
||||||
--workflow "post-merge/release" \
|
--workflow "post-merge/release" \
|
||||||
--commit "${{ github.sha }}"
|
--commit "${{ github.sha }}" \
|
||||||
|
--auto-login
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
needs: [release]
|
needs: [release]
|
||||||
@@ -160,7 +161,8 @@ jobs:
|
|||||||
--repo "${{ github.repository }}" \
|
--repo "${{ github.repository }}" \
|
||||||
--run-id "${{ github.run_id }}" \
|
--run-id "${{ github.run_id }}" \
|
||||||
--workflow "post-merge/publish" \
|
--workflow "post-merge/publish" \
|
||||||
--commit "${{ github.sha }}"
|
--commit "${{ github.sha }}" \
|
||||||
|
--auto-login
|
||||||
|
|
||||||
sync-wiki:
|
sync-wiki:
|
||||||
needs: [detect-type]
|
needs: [detect-type]
|
||||||
@@ -195,7 +197,8 @@ jobs:
|
|||||||
--repo "${{ github.repository }}" \
|
--repo "${{ github.repository }}" \
|
||||||
--run-id "${{ github.run_id }}" \
|
--run-id "${{ github.run_id }}" \
|
||||||
--workflow "post-merge/sync-wiki" \
|
--workflow "post-merge/sync-wiki" \
|
||||||
--commit "${{ github.sha }}"
|
--commit "${{ github.sha }}" \
|
||||||
|
--auto-login
|
||||||
|
|
||||||
badges:
|
badges:
|
||||||
needs: [detect-type]
|
needs: [detect-type]
|
||||||
@@ -235,7 +238,8 @@ jobs:
|
|||||||
--repo "${{ github.repository }}" \
|
--repo "${{ github.repository }}" \
|
||||||
--run-id "${{ github.run_id }}" \
|
--run-id "${{ github.run_id }}" \
|
||||||
--workflow "post-merge/badges" \
|
--workflow "post-merge/badges" \
|
||||||
--commit "${{ github.sha }}"
|
--commit "${{ github.sha }}" \
|
||||||
|
--auto-login
|
||||||
|
|
||||||
vikunja:
|
vikunja:
|
||||||
needs: [detect-type]
|
needs: [detect-type]
|
||||||
@@ -271,7 +275,8 @@ jobs:
|
|||||||
--repo "${{ github.repository }}" \
|
--repo "${{ github.repository }}" \
|
||||||
--run-id "${{ github.run_id }}" \
|
--run-id "${{ github.run_id }}" \
|
||||||
--workflow "post-merge/vikunja" \
|
--workflow "post-merge/vikunja" \
|
||||||
--commit "${{ github.sha }}"
|
--commit "${{ github.sha }}" \
|
||||||
|
--auto-login
|
||||||
|
|
||||||
configure-repo:
|
configure-repo:
|
||||||
needs: [detect-type]
|
needs: [detect-type]
|
||||||
@@ -304,4 +309,5 @@ jobs:
|
|||||||
--repo "${{ github.repository }}" \
|
--repo "${{ github.repository }}" \
|
||||||
--run-id "${{ github.run_id }}" \
|
--run-id "${{ github.run_id }}" \
|
||||||
--workflow "post-merge/configure-repo" \
|
--workflow "post-merge/configure-repo" \
|
||||||
--commit "${{ github.sha }}"
|
--commit "${{ github.sha }}" \
|
||||||
|
--auto-login
|
||||||
|
|||||||
@@ -2,6 +2,19 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [0.23.4] - 2026-06-27
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- Add --auto-login to all notify_failure calls in workflows
|
||||||
|
- Classify .gitea/** as user-facing for devx, support glob in user_facing_overrides
|
||||||
|
|
||||||
|
## [0.23.3] - 2026-06-27
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- Correct clean_images delete URL and add retry with error handling
|
||||||
|
|
||||||
## [0.23.2] - 2026-06-27
|
## [0.23.2] - 2026-06-27
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ quality badges.
|
|||||||
|
|
||||||
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
|
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
|
||||||
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/src/branch/master/LICENSE)
|
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/src/branch/master/LICENSE)
|
||||||
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
|
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
|
||||||
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
|
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
|
||||||
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/wiki)
|
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/wiki)
|
||||||
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
|
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
|
||||||
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/releases)
|
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/releases)
|
||||||
[](https://www.python.org/downloads/)
|
[](https://www.python.org/downloads/)
|
||||||
|
|
||||||
## Why devx?
|
## Why devx?
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -12,12 +12,12 @@ project to be reusable across all oblachno-oss repositories.
|
|||||||
|
|
||||||
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
|
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
|
||||||
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/src/branch/master/LICENSE)
|
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/src/branch/master/LICENSE)
|
||||||
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
|
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
|
||||||
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
|
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
|
||||||
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/wiki)
|
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/wiki)
|
||||||
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
|
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
|
||||||
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/releases)
|
[](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/releases)
|
||||||
[](https://www.python.org/downloads/)
|
[](https://www.python.org/downloads/)
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
|
|||||||
+6
-2
@@ -139,8 +139,12 @@ infrastructure_overrides = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
# User-facing overrides — safety override for broad infrastructure patterns
|
# User-facing overrides — safety override for broad infrastructure patterns
|
||||||
# (empty — add when an infrastructure pattern is too broad)
|
# devx workflow files (.gitea/**) are reference implementations that
|
||||||
user_facing_overrides = []
|
# downstream repos (grm, infra) copy from. Changes to them affect how
|
||||||
|
# consumer projects run their CI, so they must trigger a release.
|
||||||
|
user_facing_overrides = [
|
||||||
|
".gitea/**",
|
||||||
|
]
|
||||||
|
|
||||||
# Tag patterns — additional categories for CI conditional execution
|
# Tag patterns — additional categories for CI conditional execution
|
||||||
# Orthogonal to release impact (user-facing vs infrastructure)
|
# Orthogonal to release impact (user-facing vs infrastructure)
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
"""devx — reusable development and CI/CD tools for oblachno-oss projects."""
|
"""devx — reusable development and CI/CD tools for oblachno-oss projects."""
|
||||||
|
|
||||||
__version__ = "0.23.2"
|
__version__ = "0.23.4"
|
||||||
|
|||||||
@@ -393,11 +393,12 @@ class ChangeClassifier:
|
|||||||
tags = self._compute_tags(file_path)
|
tags = self._compute_tags(file_path)
|
||||||
|
|
||||||
# 1. User-facing overrides (highest priority — safety)
|
# 1. User-facing overrides (highest priority — safety)
|
||||||
if file_path in self._user_overrides:
|
for pattern in self._user_overrides:
|
||||||
|
if _matches_glob(file_path, pattern):
|
||||||
return FileClassification(
|
return FileClassification(
|
||||||
path=file_path,
|
path=file_path,
|
||||||
is_user_facing=True,
|
is_user_facing=True,
|
||||||
reason="User-facing override (safety override)",
|
reason=f"User-facing override (matches '{pattern}')",
|
||||||
matched_rule="user_facing_overrides",
|
matched_rule="user_facing_overrides",
|
||||||
tags=tags,
|
tags=tags,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ Authentication uses ``CI_GITEA_TOKEN`` environment variable.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import click
|
import click
|
||||||
@@ -85,15 +86,37 @@ def delete_package_version(
|
|||||||
token: str,
|
token: str,
|
||||||
*,
|
*,
|
||||||
timeout: int = 30,
|
timeout: int = 30,
|
||||||
|
package_type: str = "container",
|
||||||
|
max_retries: int = 3,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Delete a specific version of a container package.
|
"""Delete a specific version of a container package.
|
||||||
|
|
||||||
|
Uses the Gitea API endpoint ``DELETE /packages/{owner}/{type}/{name}/{version}``.
|
||||||
|
Retries on transient failures (5xx, timeouts) up to ``max_retries`` times.
|
||||||
|
|
||||||
Returns True on success, False on failure.
|
Returns True on success, False on failure.
|
||||||
"""
|
"""
|
||||||
url = f"{api_url}/packages/{owner}/{name}/{version}"
|
url = f"{api_url}/packages/{owner}/{package_type}/{name}/{version}"
|
||||||
headers = {"Authorization": f"token {token}"}
|
headers = {"Authorization": f"token {token}"}
|
||||||
|
for attempt in range(max_retries):
|
||||||
|
try:
|
||||||
resp = requests.delete(url, headers=headers, timeout=timeout)
|
resp = requests.delete(url, headers=headers, timeout=timeout)
|
||||||
return resp.status_code in (204, 200)
|
except requests.RequestException:
|
||||||
|
if attempt < max_retries - 1:
|
||||||
|
time.sleep(2**attempt)
|
||||||
|
continue
|
||||||
|
return False
|
||||||
|
if resp.status_code in (204, 200):
|
||||||
|
return True
|
||||||
|
# 404 means already deleted — treat as success
|
||||||
|
if resp.status_code == 404:
|
||||||
|
return True
|
||||||
|
# 5xx is transient — retry
|
||||||
|
if 500 <= resp.status_code < 600 and attempt < max_retries - 1:
|
||||||
|
time.sleep(2**attempt)
|
||||||
|
continue
|
||||||
|
return False
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def sort_versions_by_date(
|
def sort_versions_by_date(
|
||||||
@@ -171,6 +194,7 @@ def main(
|
|||||||
|
|
||||||
total_deleted = 0
|
total_deleted = 0
|
||||||
total_kept = 0
|
total_kept = 0
|
||||||
|
total_failed = 0
|
||||||
for name in names:
|
for name in names:
|
||||||
click.echo(f"\n{'=' * 60}")
|
click.echo(f"\n{'=' * 60}")
|
||||||
click.echo(f"Package: {owner}/{name}")
|
click.echo(f"Package: {owner}/{name}")
|
||||||
@@ -182,6 +206,7 @@ def main(
|
|||||||
_("Failed to list versions for {name}: {error}", name=name, error=exc),
|
_("Failed to list versions for {name}: {error}", name=name, error=exc),
|
||||||
err=True,
|
err=True,
|
||||||
)
|
)
|
||||||
|
total_failed += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not versions:
|
if not versions:
|
||||||
@@ -203,6 +228,7 @@ def main(
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
deleted_count = 0
|
deleted_count = 0
|
||||||
|
failed_count = 0
|
||||||
for v in to_delete:
|
for v in to_delete:
|
||||||
version = str(v.get("version", ""))
|
version = str(v.get("version", ""))
|
||||||
if delete_package_version(base_url, owner, name, version, token):
|
if delete_package_version(base_url, owner, name, version, token):
|
||||||
@@ -210,11 +236,15 @@ def main(
|
|||||||
deleted_count += 1
|
deleted_count += 1
|
||||||
else:
|
else:
|
||||||
click.echo(f" FAILED to delete: {version}", err=True)
|
click.echo(f" FAILED to delete: {version}", err=True)
|
||||||
|
failed_count += 1
|
||||||
|
|
||||||
total_deleted += deleted_count
|
total_deleted += deleted_count
|
||||||
total_kept += kept_count
|
total_kept += kept_count
|
||||||
|
total_failed += failed_count
|
||||||
|
|
||||||
click.echo(f"\nDone. Deleted {total_deleted}, kept {total_kept}.")
|
click.echo(f"\nDone. Deleted {total_deleted}, kept {total_kept}, failed {total_failed}.")
|
||||||
|
if total_failed > 0:
|
||||||
|
raise click.ClickException(_("Failed to delete {count} image version(s)", count=total_failed))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__": # pragma: no cover
|
if __name__ == "__main__": # pragma: no cover
|
||||||
|
|||||||
@@ -1391,6 +1391,14 @@
|
|||||||
"ru": "CI_GITEA_TOKEN environment variable required",
|
"ru": "CI_GITEA_TOKEN environment variable required",
|
||||||
"zh": "CI_GITEA_TOKEN environment variable required"
|
"zh": "CI_GITEA_TOKEN environment variable required"
|
||||||
},
|
},
|
||||||
|
"Failed to delete {count} image version(s)": {
|
||||||
|
"bg": "Failed to delete {count} image version(s)",
|
||||||
|
"de": "Failed to delete {count} image version(s)",
|
||||||
|
"en": "Failed to delete {count} image version(s)",
|
||||||
|
"pl": "Failed to delete {count} image version(s)",
|
||||||
|
"ru": "Failed to delete {count} image version(s)",
|
||||||
|
"zh": "Failed to delete {count} image version(s)"
|
||||||
|
},
|
||||||
"CI_GITEA_TOKEN is not set. Required to create a PR.": {
|
"CI_GITEA_TOKEN is not set. Required to create a PR.": {
|
||||||
"bg": "CI_GITEA_TOKEN не е зададен. Необходим за създаване на PR.",
|
"bg": "CI_GITEA_TOKEN не е зададен. Необходим за създаване на PR.",
|
||||||
"de": "CI_GITEA_TOKEN nicht gesetzt. Erforderlich zum Erstellen eines PR.",
|
"de": "CI_GITEA_TOKEN nicht gesetzt. Erforderlich zum Erstellen eines PR.",
|
||||||
|
|||||||
@@ -321,6 +321,25 @@ class TestCleanImagesAPI:
|
|||||||
from devx.tools.clean_images import delete_package_version
|
from devx.tools.clean_images import delete_package_version
|
||||||
|
|
||||||
mock_resp = MagicMock(status_code=204)
|
mock_resp = MagicMock(status_code=204)
|
||||||
|
with patch("devx.tools.clean_images.requests.delete", return_value=mock_resp) as mock_del:
|
||||||
|
assert (
|
||||||
|
delete_package_version(
|
||||||
|
"https://git.example.com/api/v1",
|
||||||
|
"oblachno-oss",
|
||||||
|
"ci-base",
|
||||||
|
"0.1.0",
|
||||||
|
"token",
|
||||||
|
)
|
||||||
|
is True
|
||||||
|
)
|
||||||
|
# Verify URL includes container type
|
||||||
|
url = mock_del.call_args.args[0]
|
||||||
|
assert "/container/" in url
|
||||||
|
|
||||||
|
def test_delete_package_version_404_treated_as_success(self) -> None:
|
||||||
|
from devx.tools.clean_images import delete_package_version
|
||||||
|
|
||||||
|
mock_resp = MagicMock(status_code=404)
|
||||||
with patch("devx.tools.clean_images.requests.delete", return_value=mock_resp):
|
with patch("devx.tools.clean_images.requests.delete", return_value=mock_resp):
|
||||||
assert (
|
assert (
|
||||||
delete_package_version(
|
delete_package_version(
|
||||||
@@ -336,7 +355,7 @@ class TestCleanImagesAPI:
|
|||||||
def test_delete_package_version_failure(self) -> None:
|
def test_delete_package_version_failure(self) -> None:
|
||||||
from devx.tools.clean_images import delete_package_version
|
from devx.tools.clean_images import delete_package_version
|
||||||
|
|
||||||
mock_resp = MagicMock(status_code=404)
|
mock_resp = MagicMock(status_code=403)
|
||||||
with patch("devx.tools.clean_images.requests.delete", return_value=mock_resp):
|
with patch("devx.tools.clean_images.requests.delete", return_value=mock_resp):
|
||||||
assert (
|
assert (
|
||||||
delete_package_version(
|
delete_package_version(
|
||||||
@@ -349,6 +368,110 @@ class TestCleanImagesAPI:
|
|||||||
is False
|
is False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_delete_package_version_retries_on_5xx(self) -> None:
|
||||||
|
from devx.tools.clean_images import delete_package_version
|
||||||
|
|
||||||
|
responses = [
|
||||||
|
MagicMock(status_code=500),
|
||||||
|
MagicMock(status_code=502),
|
||||||
|
MagicMock(status_code=204),
|
||||||
|
]
|
||||||
|
with patch("devx.tools.clean_images.requests.delete", side_effect=responses):
|
||||||
|
with patch("devx.tools.clean_images.time.sleep"):
|
||||||
|
assert (
|
||||||
|
delete_package_version(
|
||||||
|
"https://git.example.com/api/v1",
|
||||||
|
"oblachno-oss",
|
||||||
|
"ci-base",
|
||||||
|
"0.1.0",
|
||||||
|
"token",
|
||||||
|
max_retries=3,
|
||||||
|
)
|
||||||
|
is True
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_delete_package_version_retries_on_exception(self) -> None:
|
||||||
|
import requests as req
|
||||||
|
|
||||||
|
from devx.tools.clean_images import delete_package_version
|
||||||
|
|
||||||
|
responses = [
|
||||||
|
req.ConnectionError("network down"),
|
||||||
|
MagicMock(status_code=204),
|
||||||
|
]
|
||||||
|
with patch("devx.tools.clean_images.requests.delete", side_effect=responses):
|
||||||
|
with patch("devx.tools.clean_images.time.sleep"):
|
||||||
|
assert (
|
||||||
|
delete_package_version(
|
||||||
|
"https://git.example.com/api/v1",
|
||||||
|
"oblachno-oss",
|
||||||
|
"ci-base",
|
||||||
|
"0.1.0",
|
||||||
|
"token",
|
||||||
|
max_retries=3,
|
||||||
|
)
|
||||||
|
is True
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_delete_package_version_exhausts_retries_on_exception(self) -> None:
|
||||||
|
import requests as req
|
||||||
|
|
||||||
|
from devx.tools.clean_images import delete_package_version
|
||||||
|
|
||||||
|
with patch(
|
||||||
|
"devx.tools.clean_images.requests.delete",
|
||||||
|
side_effect=req.ConnectionError("network down"),
|
||||||
|
):
|
||||||
|
with patch("devx.tools.clean_images.time.sleep"):
|
||||||
|
assert (
|
||||||
|
delete_package_version(
|
||||||
|
"https://git.example.com/api/v1",
|
||||||
|
"oblachno-oss",
|
||||||
|
"ci-base",
|
||||||
|
"0.1.0",
|
||||||
|
"token",
|
||||||
|
max_retries=2,
|
||||||
|
)
|
||||||
|
is False
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_delete_package_version_exhausts_retries_on_5xx(self) -> None:
|
||||||
|
from devx.tools.clean_images import delete_package_version
|
||||||
|
|
||||||
|
with patch(
|
||||||
|
"devx.tools.clean_images.requests.delete",
|
||||||
|
return_value=MagicMock(status_code=500),
|
||||||
|
):
|
||||||
|
with patch("devx.tools.clean_images.time.sleep"):
|
||||||
|
assert (
|
||||||
|
delete_package_version(
|
||||||
|
"https://git.example.com/api/v1",
|
||||||
|
"oblachno-oss",
|
||||||
|
"ci-base",
|
||||||
|
"0.1.0",
|
||||||
|
"token",
|
||||||
|
max_retries=2,
|
||||||
|
)
|
||||||
|
is False
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_delete_package_version_zero_retries(self) -> None:
|
||||||
|
from devx.tools.clean_images import delete_package_version
|
||||||
|
|
||||||
|
with patch("devx.tools.clean_images.requests.delete") as mock_del:
|
||||||
|
assert (
|
||||||
|
delete_package_version(
|
||||||
|
"https://git.example.com/api/v1",
|
||||||
|
"oblachno-oss",
|
||||||
|
"ci-base",
|
||||||
|
"0.1.0",
|
||||||
|
"token",
|
||||||
|
max_retries=0,
|
||||||
|
)
|
||||||
|
is False
|
||||||
|
)
|
||||||
|
mock_del.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
class TestCLIBuildImage:
|
class TestCLIBuildImage:
|
||||||
def test_single_image_build(self, tmp_path: Path) -> None:
|
def test_single_image_build(self, tmp_path: Path) -> None:
|
||||||
@@ -557,7 +680,7 @@ class TestCLICleanImages:
|
|||||||
clean_main,
|
clean_main,
|
||||||
["--owner", "oblachno-oss", "--name", "ci-base", "--dry-run"],
|
["--owner", "oblachno-oss", "--name", "ci-base", "--dry-run"],
|
||||||
)
|
)
|
||||||
assert result.exit_code == 0
|
assert result.exit_code != 0
|
||||||
assert "Failed to list" in result.output
|
assert "Failed to list" in result.output
|
||||||
|
|
||||||
def test_delete_failure_in_cli(self) -> None:
|
def test_delete_failure_in_cli(self) -> None:
|
||||||
@@ -571,13 +694,15 @@ class TestCLICleanImages:
|
|||||||
{"version": "0.3.0", "created_at": "2025-03-01"},
|
{"version": "0.3.0", "created_at": "2025-03-01"},
|
||||||
]
|
]
|
||||||
list_resp.raise_for_status = MagicMock()
|
list_resp.raise_for_status = MagicMock()
|
||||||
delete_resp = MagicMock(status_code=500)
|
delete_resp = MagicMock(status_code=403)
|
||||||
with patch.dict("os.environ", {"CI_GITEA_TOKEN": "fake"}):
|
with patch.dict("os.environ", {"CI_GITEA_TOKEN": "fake"}):
|
||||||
with patch("devx.tools.clean_images.requests.get", return_value=list_resp):
|
with patch("devx.tools.clean_images.requests.get", return_value=list_resp):
|
||||||
with patch("devx.tools.clean_images.requests.delete", return_value=delete_resp):
|
with patch("devx.tools.clean_images.requests.delete", return_value=delete_resp):
|
||||||
|
with patch("devx.tools.clean_images.time.sleep"):
|
||||||
result = runner.invoke(
|
result = runner.invoke(
|
||||||
clean_main,
|
clean_main,
|
||||||
["--owner", "oblachno-oss", "--name", "ci-base", "--keep", "2"],
|
["--owner", "oblachno-oss", "--name", "ci-base", "--keep", "2"],
|
||||||
)
|
)
|
||||||
assert result.exit_code == 0
|
assert result.exit_code != 0
|
||||||
assert "FAILED" in result.output
|
assert "FAILED" in result.output
|
||||||
|
assert "failed" in result.output.lower()
|
||||||
|
|||||||
@@ -264,6 +264,16 @@ class TestChangeClassifier:
|
|||||||
assert fc.is_user_facing
|
assert fc.is_user_facing
|
||||||
assert fc.matched_rule == "user_facing_overrides"
|
assert fc.matched_rule == "user_facing_overrides"
|
||||||
|
|
||||||
|
def test_user_facing_override_glob_matches_nested(self) -> None:
|
||||||
|
"""User-facing overrides support glob patterns like infrastructure."""
|
||||||
|
classifier = self._make_classifier(
|
||||||
|
infrastructure=[".gitea/**"],
|
||||||
|
user_facing_overrides=[".gitea/**"],
|
||||||
|
)
|
||||||
|
fc = classifier.classify_file(".gitea/workflows/ci.yml")
|
||||||
|
assert fc.is_user_facing
|
||||||
|
assert fc.matched_rule == "user_facing_overrides"
|
||||||
|
|
||||||
def test_user_facing_override_beats_infrastructure_override(self) -> None:
|
def test_user_facing_override_beats_infrastructure_override(self) -> None:
|
||||||
"""User-facing overrides beat infrastructure overrides (safety first)."""
|
"""User-facing overrides beat infrastructure overrides (safety first)."""
|
||||||
classifier = self._make_classifier(
|
classifier = self._make_classifier(
|
||||||
@@ -489,7 +499,7 @@ class TestMain:
|
|||||||
@patch("devx.ci.classify_changes.get_changed_files")
|
@patch("devx.ci.classify_changes.get_changed_files")
|
||||||
@patch("devx.ci.classify_changes.get_latest_tag", return_value="v0.3.0")
|
@patch("devx.ci.classify_changes.get_latest_tag", return_value="v0.3.0")
|
||||||
def test_workflow_only_exits_2(self, mock_tag: MagicMock, mock_changes: MagicMock) -> None:
|
def test_workflow_only_exits_2(self, mock_tag: MagicMock, mock_changes: MagicMock) -> None:
|
||||||
mock_changes.return_value = [".gitea/workflows/ci.yml", "docs/index.md"]
|
mock_changes.return_value = ["docs/index.md", "README.md"]
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
result = runner.invoke(main, [])
|
result = runner.invoke(main, [])
|
||||||
assert result.exit_code == 2
|
assert result.exit_code == 2
|
||||||
@@ -572,7 +582,7 @@ class TestMain:
|
|||||||
@patch("devx.ci.classify_changes.get_changed_files")
|
@patch("devx.ci.classify_changes.get_changed_files")
|
||||||
@patch("devx.ci.classify_changes.get_latest_tag", return_value="v0.3.0")
|
@patch("devx.ci.classify_changes.get_latest_tag", return_value="v0.3.0")
|
||||||
def test_quiet_workflow_only(self, mock_tag: MagicMock, mock_changes: MagicMock) -> None:
|
def test_quiet_workflow_only(self, mock_tag: MagicMock, mock_changes: MagicMock) -> None:
|
||||||
mock_changes.return_value = [".gitea/workflows/ci.yml"]
|
mock_changes.return_value = ["docs/index.md"]
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
result = runner.invoke(main, ["--quiet"])
|
result = runner.invoke(main, ["--quiet"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
@@ -631,7 +641,7 @@ class TestMain:
|
|||||||
@patch("devx.ci.classify_changes.get_changed_files")
|
@patch("devx.ci.classify_changes.get_changed_files")
|
||||||
@patch("devx.ci.classify_changes.get_latest_tag", return_value="v0.3.0")
|
@patch("devx.ci.classify_changes.get_latest_tag", return_value="v0.3.0")
|
||||||
def test_check_user_facing_false(self, mock_tag: MagicMock, mock_changes: MagicMock) -> None:
|
def test_check_user_facing_false(self, mock_tag: MagicMock, mock_changes: MagicMock) -> None:
|
||||||
mock_changes.return_value = [".gitea/workflows/ci.yml", "tests/test_foo.py"]
|
mock_changes.return_value = ["docs/index.md", "tests/test_foo.py"]
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
result = runner.invoke(main, ["--check", "user-facing", "--quiet"])
|
result = runner.invoke(main, ["--check", "user-facing", "--quiet"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|||||||
Reference in New Issue
Block a user