mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 11:46:35 +00:00
Refactor scripts/install/lint.sh (~870 LOC bash) into a Python package
under utils/install/. scripts/install/lint.sh becomes a 7-line wrapper
that delegates to `python3 -m utils.install.lint`.
Layout:
- utils/install/{primitives,pip,npm,github_release,system_pkg}.py:
channel-agnostic installers
- utils/install/lint/<tool>.py: one ensure() per tool (actionlint,
shfmt, mbake, ruff, ansible_lint, galaxy_importer, markdownlint_cli2,
eslint, shellcheck, ansible_commands, ansible_collections)
- utils/install/lint/__main__.py: CLI + group dispatch + stamp logic
INFINITO_LINT_RUNNER dispatch:
- New env var (host | docker, default docker), tracked in env/static.env
+ passthrough handler + drift test.
- scripts/install/wrapper.sh routes `make install-lint` to host or
container based on the runner.
- scripts/lint/wrapper.sh already dispatched; container branch now uses
bash (not --login) so /etc/profile does not reset PATH, and forwards
BASH_ENV so the .env keys land in the lint script's env.
Stamp logic:
- Per-interpreter stamp at build/install-lint-<sha256(sys.executable)>.stamp
so host venv and container venv track installs independently despite
bind-mounted build/.
- `--force` drops the stamp; group args bypass the stamp.
Tests + docs:
- 43 unit tests under tests/unit/utils/install/{,lint/} cover primitives,
pip/npm/github_release/system_pkg fallback chains, and the main CLI
(stamp logic, group dispatch, error path).
- utils/install/README.md + utils/install/lint/README.md document the
structure and the per-tool ensure() contract.
- docs/contributing/tools/make.md install-lint row updated to mention
the runner dispatch + per-env stamp + install-lint-force.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
"""GitHub-release asset helpers (latest-tag resolver + downloader)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from urllib.request import urlopen
|
|
|
|
from utils.install.primitives import download_file
|
|
|
|
|
|
def resolve_latest_tag(latest_url: str) -> str:
|
|
# GitHub redirects /releases/latest -> /releases/tag/v<version>;
|
|
# final-URL last segment minus a leading 'v' is the version.
|
|
with urlopen(latest_url) as response: # noqa: S310 - trusted github URL
|
|
final_url = response.geturl()
|
|
|
|
final_url = final_url.rstrip("/")
|
|
if not final_url:
|
|
raise RuntimeError("Failed to resolve latest release URL.")
|
|
if final_url == latest_url:
|
|
raise RuntimeError("Latest release URL did not resolve to a versioned tag.")
|
|
|
|
tag = final_url.rsplit("/", 1)[-1]
|
|
tag = tag.removeprefix("v")
|
|
if not tag or tag in (final_url, "latest"):
|
|
raise RuntimeError(f"Failed to determine version from {final_url}.")
|
|
return tag
|
|
|
|
|
|
def download_release_asset(url: str, output: str) -> None:
|
|
download_file(url, output)
|
|
|
|
|
|
__all__ = ["download_release_asset", "resolve_latest_tag"]
|