mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-10 19:27:16 +01:00
A repo with `.dep-freshness-no-workflow` at its root keeps the local pieces (delegate script, pre-commit hook) but the installer no longer creates or rewrites `.github/workflows/dependency-freshness.yml` there. teatr-pw deleted its workflows on purpose (no GitHub Actions minutes on a private repo; its pre-push hook runs `--all --strict`), and without this every fleet sweep would put the workflow back. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H8tUQzqQmiidbg8ZXmeQAg
54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
"""The per-repo opt-out from the CI workflow (`.dep-freshness-no-workflow`).
|
|
|
|
A repo that runs the gate only locally (teatr-pw: no GitHub Actions minutes)
|
|
deletes `.github/workflows/dependency-freshness.yml` on purpose. Without an
|
|
opt-out the next fleet sweep puts it back, so the marker must stop the
|
|
installer from creating OR rewriting it -- and must not stop anything else.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dep_freshness import install as installer
|
|
from dep_freshness.tests.conftest import write
|
|
|
|
MARKER = ".dep-freshness-no-workflow"
|
|
WORKFLOW = ".github/workflows/dependency-freshness.yml"
|
|
|
|
|
|
def test_the_marker_path_is_the_documented_one():
|
|
assert str(installer.NO_WORKFLOW_MARKER) == MARKER
|
|
|
|
|
|
def test_an_opted_out_repo_gets_the_local_pieces_but_no_workflow(repo):
|
|
write(repo, MARKER, "# no GitHub Actions here\n")
|
|
|
|
assert installer.install(repo) == [
|
|
"scripts/check_dependency_freshness.sh",
|
|
".pre-commit-config.yaml (dependency-freshness hook)",
|
|
]
|
|
assert not (repo / WORKFLOW).exists()
|
|
assert not (repo / ".github").exists()
|
|
|
|
|
|
def test_plan_does_not_report_the_workflow_as_missing(repo):
|
|
write(repo, MARKER, "")
|
|
|
|
assert WORKFLOW not in installer.plan(repo)
|
|
installer.install(repo)
|
|
assert installer.plan(repo) == []
|
|
assert installer.install(repo) == []
|
|
|
|
|
|
def test_an_existing_drifted_workflow_is_left_as_it_is(repo):
|
|
"""Opted out means hands off: no create, no rewrite, no delete."""
|
|
write(repo, MARKER, "")
|
|
write(repo, WORKFLOW, "name: kept by hand\n")
|
|
|
|
assert WORKFLOW not in installer.install(repo)
|
|
assert (repo / WORKFLOW).read_text(encoding="utf-8") == "name: kept by hand\n"
|
|
|
|
|
|
def test_without_the_marker_the_workflow_is_still_installed(repo):
|
|
assert WORKFLOW in installer.install(repo)
|
|
assert (repo / WORKFLOW).is_file()
|