Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f223d5657 | ||
|
|
ac0ce1c158 | ||
|
|
10de782d93 | ||
|
|
bfb3a4d862 | ||
|
|
e167be1890 | ||
|
|
f9cdbec86a | ||
|
|
3687f00b83 | ||
|
|
ce8e611cc1 |
@@ -2,8 +2,25 @@
|
|||||||
|
|
||||||
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.50.6] - 2026-08-12
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- Add GitHub mirror fallback for actionlint and vale downloads
|
||||||
|
|
||||||
|
## [0.50.5] - 2026-08-12
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- Increase download retry attempts and backoff for transient GitHub outages
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- `save_vault_yaml`: pass `allow_unicode=True` to `yaml.dump` to prevent
|
||||||
|
corruption of non-ASCII vault content (matches infra's `save_yaml` pattern)
|
||||||
|
|
||||||
### Ci
|
### Ci
|
||||||
|
|
||||||
- Add composite actions (setup-env, notify-failure, quality-checks) in `.gitea/actions/`
|
- Add composite actions (setup-env, notify-failure, quality-checks) in `.gitea/actions/`
|
||||||
|
|||||||
@@ -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?
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ extra index and list devx in your dependencies:
|
|||||||
```toml
|
```toml
|
||||||
[project]
|
[project]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"devx>=0.50.4",
|
"devx>=0.50.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.pip]
|
[tool.pip]
|
||||||
@@ -101,8 +101,8 @@ pip install -e .
|
|||||||
```
|
```
|
||||||
|
|
||||||
> **Note:** If your project requires a specific devx version, pin it in
|
> **Note:** If your project requires a specific devx version, pin it in
|
||||||
> `dependencies` (for example, `"devx==0.50.4"`) or use a version constraint
|
> `dependencies` (for example, `"devx==0.50.6"`) or use a version constraint
|
||||||
> (for example, `"devx>=0.50.4,<0.51"`).
|
> (for example, `"devx>=0.50.6,<0.51"`).
|
||||||
|
|
||||||
### Optional extras
|
### Optional extras
|
||||||
|
|
||||||
|
|||||||
+8
-8
@@ -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
|
||||||
|
|
||||||
@@ -74,14 +74,14 @@ Add devx to your `pyproject.toml` dependencies and configure the registry:
|
|||||||
```toml
|
```toml
|
||||||
[project]
|
[project]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"devx>=0.50.4",
|
"devx>=0.50.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.pip]
|
[tool.pip]
|
||||||
extra-index-url = "https://git.oblachno.oblachno.fyi/api/packages/oblachno-oss/pypi/simple"
|
extra-index-url = "https://git.oblachno.oblachno.fyi/api/packages/oblachno-oss/pypi/simple"
|
||||||
```
|
```
|
||||||
|
|
||||||
Pin a specific version if needed: `"devx==0.50.4"` or `"devx>=0.50.4,<0.51"`.
|
Pin a specific version if needed: `"devx==0.50.6"` or `"devx>=0.50.6,<0.51"`.
|
||||||
|
|
||||||
### Optional extras
|
### Optional extras
|
||||||
|
|
||||||
|
|||||||
@@ -48,12 +48,12 @@ Add devx to your `pyproject.toml`:
|
|||||||
```toml
|
```toml
|
||||||
[project]
|
[project]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"devx>=0.50.4",
|
"devx>=0.50.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
dev = [
|
dev = [
|
||||||
"devx>=0.50.4",
|
"devx>=0.50.6",
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -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.50.4"
|
__version__ = "0.50.6"
|
||||||
|
|||||||
@@ -131,26 +131,37 @@ def _download_with_fallback(urls: list[str], binary_name: str) -> Path:
|
|||||||
raise click.ClickException(f"Failed to download {binary_name} from all URLs: {'; '.join(errors)}")
|
raise click.ClickException(f"Failed to download {binary_name} from all URLs: {'; '.join(errors)}")
|
||||||
|
|
||||||
|
|
||||||
def _download_and_extract_tarball(url: str, binary_name: str) -> Path:
|
def _download_and_extract_tarball(url: str, binary_name: str, *, fallback_urls: list[str] | None = None) -> Path:
|
||||||
"""Download a tarball, extract the binary, and install it to TARGET_DIR.
|
"""Download a tarball, extract the binary, and install it to TARGET_DIR.
|
||||||
|
|
||||||
Returns the path to the installed binary.
|
Returns the path to the installed binary. Falls back to ``fallback_urls``
|
||||||
|
if the primary ``url`` fails all retries.
|
||||||
"""
|
"""
|
||||||
target_dir = _ensure_target_dir()
|
target_dir = _ensure_target_dir()
|
||||||
dest = target_dir / binary_name
|
dest = target_dir / binary_name
|
||||||
with tempfile.TemporaryDirectory() as tmpdir:
|
urls = [url, *(fallback_urls or [])]
|
||||||
tarball = Path(tmpdir) / "archive.tar.gz"
|
errors: list[str] = []
|
||||||
_download(url, tarball)
|
for try_url in urls:
|
||||||
with tarfile.open(tarball, "r:gz") as tar:
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
tar.extractall(tmpdir) # nosec B202
|
tarball = Path(tmpdir) / "archive.tar.gz"
|
||||||
# Find the binary in the extracted tree
|
try:
|
||||||
extracted = Path(tmpdir).rglob(binary_name)
|
_download(try_url, tarball)
|
||||||
found = next(extracted, None)
|
except Exception as exc: # noqa: BLE001
|
||||||
if found is None:
|
errors.append(f"{try_url}: {exc}")
|
||||||
raise click.ClickException(f"Binary {binary_name} not found in archive from {url}")
|
click.echo(f" {binary_name}: fallback — {exc}")
|
||||||
shutil.copy2(found, dest)
|
continue
|
||||||
dest.chmod(0o755)
|
with tarfile.open(tarball, "r:gz") as tar:
|
||||||
return dest
|
tar.extractall(tmpdir) # nosec B202
|
||||||
|
# Find the binary in the extracted tree
|
||||||
|
extracted = Path(tmpdir).rglob(binary_name)
|
||||||
|
found = next(extracted, None)
|
||||||
|
if found is None:
|
||||||
|
errors.append(f"{try_url}: binary not found in archive")
|
||||||
|
continue
|
||||||
|
shutil.copy2(found, dest)
|
||||||
|
dest.chmod(0o755)
|
||||||
|
return dest
|
||||||
|
raise click.ClickException(f"Failed to download {binary_name} from all URLs: {'; '.join(errors)}")
|
||||||
|
|
||||||
|
|
||||||
def _download_binary(url: str, binary_name: str) -> Path:
|
def _download_binary(url: str, binary_name: str) -> Path:
|
||||||
@@ -178,11 +189,12 @@ def install_actionlint() -> bool:
|
|||||||
click.echo("actionlint: already installed")
|
click.echo("actionlint: already installed")
|
||||||
return True
|
return True
|
||||||
arch = _arch()
|
arch = _arch()
|
||||||
url = (
|
path = (
|
||||||
f"https://github.com/rhysd/actionlint/releases/download/"
|
f"rhysd/actionlint/releases/download/v{ACTIONLINT_VERSION}/actionlint_{ACTIONLINT_VERSION}_linux_{arch}.tar.gz"
|
||||||
f"v{ACTIONLINT_VERSION}/actionlint_{ACTIONLINT_VERSION}_linux_{arch}.tar.gz"
|
|
||||||
)
|
)
|
||||||
dest = _download_and_extract_tarball(url, "actionlint")
|
url = f"https://github.com/{path}"
|
||||||
|
fallback = [f"https://ghproxy.com/{path}"]
|
||||||
|
dest = _download_and_extract_tarball(url, "actionlint", fallback_urls=fallback)
|
||||||
click.echo(f"actionlint: installed to {dest}")
|
click.echo(f"actionlint: installed to {dest}")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -276,8 +288,10 @@ def install_vale() -> bool:
|
|||||||
return True
|
return True
|
||||||
machine = platform.machine().lower()
|
machine = platform.machine().lower()
|
||||||
arch = "64-bit" if machine in {"x86_64", "amd64"} else "arm64"
|
arch = "64-bit" if machine in {"x86_64", "amd64"} else "arm64"
|
||||||
url = f"https://github.com/errata-ai/vale/releases/download/v{VALE_VERSION}/vale_{VALE_VERSION}_Linux_{arch}.tar.gz"
|
path = f"errata-ai/vale/releases/download/v{VALE_VERSION}/vale_{VALE_VERSION}_Linux_{arch}.tar.gz"
|
||||||
dest = _download_and_extract_tarball(url, "vale")
|
url = f"https://github.com/{path}"
|
||||||
|
fallback = [f"https://ghproxy.com/{path}"]
|
||||||
|
dest = _download_and_extract_tarball(url, "vale", fallback_urls=fallback)
|
||||||
click.echo(f"vale: installed to {dest}")
|
click.echo(f"vale: installed to {dest}")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ def save_vault_yaml(path: Path, data: dict, vault_pass: Path | None = None) -> N
|
|||||||
data: Data to serialize.
|
data: Data to serialize.
|
||||||
vault_pass: Path to the vault-password file (optional).
|
vault_pass: Path to the vault-password file (optional).
|
||||||
"""
|
"""
|
||||||
plain = yaml.dump(data, default_flow_style=False, sort_keys=False)
|
plain = yaml.dump(data, default_flow_style=False, sort_keys=False, allow_unicode=True)
|
||||||
with open(path, "w", encoding="utf-8") as f:
|
with open(path, "w", encoding="utf-8") as f:
|
||||||
f.write(plain)
|
f.write(plain)
|
||||||
if vault_pass is not None and vault_pass.exists():
|
if vault_pass is not None and vault_pass.exists():
|
||||||
|
|||||||
@@ -201,6 +201,50 @@ class TestDownloadAndExtractTarball:
|
|||||||
with pytest.raises(ClickException, match="not found in archive"):
|
with pytest.raises(ClickException, match="not found in archive"):
|
||||||
install_tools._download_and_extract_tarball("https://example.com/actionlint.tar.gz", "actionlint")
|
install_tools._download_and_extract_tarball("https://example.com/actionlint.tar.gz", "actionlint")
|
||||||
|
|
||||||
|
def test_fallback_url_succeeds(self, tmp_path: Path) -> None:
|
||||||
|
import io
|
||||||
|
import tarfile
|
||||||
|
|
||||||
|
tarball_path = tmp_path / "archive.tar.gz"
|
||||||
|
binary_content = b"fake binary"
|
||||||
|
with tarfile.open(tarball_path, "w:gz") as tar:
|
||||||
|
info = tarfile.TarInfo(name="actionlint")
|
||||||
|
info.size = len(binary_content)
|
||||||
|
tar.addfile(info, io.BytesIO(binary_content))
|
||||||
|
|
||||||
|
target_dir = tmp_path / "bin"
|
||||||
|
target_dir.mkdir()
|
||||||
|
tarball_bytes = tarball_path.read_bytes()
|
||||||
|
|
||||||
|
def fake_download(url: str, dest: Path) -> None:
|
||||||
|
if "primary" in url:
|
||||||
|
raise OSError("connection refused")
|
||||||
|
Path(dest).write_bytes(tarball_bytes)
|
||||||
|
|
||||||
|
with patch.object(install_tools, "TARGET_DIR", target_dir):
|
||||||
|
with patch.object(install_tools, "_download", side_effect=fake_download):
|
||||||
|
result = install_tools._download_and_extract_tarball(
|
||||||
|
"https://primary.com/actionlint.tar.gz",
|
||||||
|
"actionlint",
|
||||||
|
fallback_urls=["https://fallback.com/actionlint.tar.gz"],
|
||||||
|
)
|
||||||
|
|
||||||
|
assert result == target_dir / "actionlint"
|
||||||
|
assert result.read_bytes() == binary_content
|
||||||
|
|
||||||
|
def test_all_urls_fail(self, tmp_path: Path) -> None:
|
||||||
|
target_dir = tmp_path / "bin"
|
||||||
|
target_dir.mkdir()
|
||||||
|
|
||||||
|
with patch.object(install_tools, "TARGET_DIR", target_dir):
|
||||||
|
with patch.object(install_tools, "_download", side_effect=OSError("connection refused")):
|
||||||
|
with pytest.raises(ClickException, match="Failed to download"):
|
||||||
|
install_tools._download_and_extract_tarball(
|
||||||
|
"https://primary.com/actionlint.tar.gz",
|
||||||
|
"actionlint",
|
||||||
|
fallback_urls=["https://fallback.com/actionlint.tar.gz"],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestInstallActionlint:
|
class TestInstallActionlint:
|
||||||
def test_already_installed(self) -> None:
|
def test_already_installed(self) -> None:
|
||||||
|
|||||||
@@ -75,6 +75,25 @@ class TestSaveVaultYaml:
|
|||||||
content = f.read_text()
|
content = f.read_text()
|
||||||
assert "key: value" in content
|
assert "key: value" in content
|
||||||
|
|
||||||
|
def test_save_preserves_unicode(self, tmp_path: Path) -> None:
|
||||||
|
"""allow_unicode=True writes UTF-8 instead of \\uXXXX escapes."""
|
||||||
|
f = tmp_path / "output.yml"
|
||||||
|
data = {"name": "Тест", "city": "München", "role": "管理员"}
|
||||||
|
save_vault_yaml(f, data)
|
||||||
|
content = f.read_text()
|
||||||
|
assert "Тест" in content
|
||||||
|
assert "München" in content
|
||||||
|
assert "管理员" in content
|
||||||
|
assert "\\u" not in content
|
||||||
|
|
||||||
|
def test_save_unicode_round_trip(self, tmp_path: Path) -> None:
|
||||||
|
"""Saved unicode data loads back correctly."""
|
||||||
|
f = tmp_path / "output.yml"
|
||||||
|
data = {"name": "Тест", "city": "München"}
|
||||||
|
save_vault_yaml(f, data)
|
||||||
|
loaded = load_vault_yaml(f)
|
||||||
|
assert loaded == data
|
||||||
|
|
||||||
def test_save_with_vault_pass_not_exists(self, tmp_path: Path) -> None:
|
def test_save_with_vault_pass_not_exists(self, tmp_path: Path) -> None:
|
||||||
f = tmp_path / "output.yml"
|
f = tmp_path / "output.yml"
|
||||||
vp = tmp_path / "nonexistent"
|
vp = tmp_path / "nonexistent"
|
||||||
|
|||||||
Reference in New Issue
Block a user