Repository navigation
feat: port backup script to Python, fix DCO default (#17) - #19
Merged
Merged
Conversation
Replace the 420-line bash gitops_backup.sh with a stdlib-only Python implementation (gitops_backup.py). The contract is unchanged: same options.json inputs, env overrides, status file, log rotation, token-less remote header, PR create/dedupe flow and never-checkout branch handling. tests/self_check.sh is the parity gate and runs unmodified against the new script (also verified inside the built image on Alpine's Python 3.12). Image: apk python3 added, jq/curl dropped; service loop now runs python3 /app/gitops_backup.py. Tooling: pyproject.toml (ruff, mypy --strict, pytest), ruff pre-commit hooks, new "Python Lint & Tests" CI job. Existing required check names are untouched. tests/test_gitops_backup.py runs the script end to end against a bare origin plus a fake GitHub REST server to cover pr_created, pr_open_unchanged, pr_updated (stacking onto the open PR branch) and foreign-PR filtering, which self_check.sh could not reach. Fixes #17: default commit_email is now [email protected] so Signed-off-by passes the DCO GitHub App. Saved options on existing installs are not changed. Co-authored-by: Copilot <[email protected]> Signed-off-by: Anil Belur <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces
gitops_backup.sh(bash, ~420 lines) withgitops_backup.py(stdlib-only Python). Same options, env overrides, status file, log format and git/PR behaviour.tests/self_check.shruns unmodified against the Python script — locally and inside the built image (Alpine Python 3.12).apk add python3;jq/curlremoved (90 MB amd64).tests/test_gitops_backup.pydrives the script end to end against a bare origin + fake GitHub REST API (http.server) — coverspr_created,pr_open_unchanged,pr_updatedstacking, foreign-PR filtering, config errors, file-list cap, API URL scheme check.pyproject.toml(ruff, mypy strict, pytest), ruff pre-commit hooks, new CI job Python Lint & Tests. Existing required check names unchanged.commit_email→[email protected](DCO app rejected@localhost). Existing installs keep their saved value.Version bumped to 0.5.0.
Test plan
pre-commit run --all-files(14 hooks)ruff check/ruff format --check/mypy --strictpytest— 6 passedbash tests/self_check.sh— 11 cases OK (host 3.14 and image 3.12)docker buildamd64 smoke +py_compile