From 6d50224ff734e1a7ee0b9cb3f5cfd6d60507eab3 Mon Sep 17 00:00:00 2001 From: Aaron Barnes Date: Mon, 1 Jun 2026 13:59:09 -0600 Subject: [PATCH] [SPN-2931] Stop regen from deleting .github/ tree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #23 (auto/sdk-update) was deleting our entire .github/ directory on every regen — CODEOWNERS, generate.yml, publish-pypi.yml, publish-testpypi.yml, and sdk-update.yml itself all showed as removed in the bot PR. Root cause: scripts/post_generate.py runs shutil.rmtree(PROJECT_ROOT / ".github") as part of its "cleanup generator artifacts" pass. That logic was written when .github/ was 100% openapi-generator output (the Python template still writes a default .github/workflows/python.yml). Since then we've added our own workflows under .github/, but the cleanup kept indiscriminately rm-rf'ing the whole tree. Fix: 1. Add .github/** to .openapi-generator-ignore so the generator never writes there in the first place. This makes the cleanup step a no-op for .github/ regardless of what the upstream template emits. 2. Remove ".github" from post_generate.py's unwanted list with a comment explaining why it's intentionally absent (so a future maintainer doesn't re-add it). Verified locally: ran `make generate` after the change; .github/ contents are byte-identical to before, git status reports a clean working tree for the directory. Next bot run on auto/sdk-update should drop the five .github deletions from the diff. Co-Authored-By: Claude Sonnet 4.6 --- .openapi-generator-ignore | 9 +++++++++ scripts/post_generate.py | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.openapi-generator-ignore b/.openapi-generator-ignore index 7da38a1..67dea58 100644 --- a/.openapi-generator-ignore +++ b/.openapi-generator-ignore @@ -31,3 +31,12 @@ scripts/** # Protect custom tests and examples tests/** examples/** + +# Protect our own CI workflows + CODEOWNERS. The Python openapi-generator +# template writes a default .github/workflows/python.yml on every regen, +# and post_generate.py used to `shutil.rmtree('.github')` to clean it up — +# which collateral-deleted our entire .github/ tree (generate.yml, +# publish-pypi.yml, publish-testpypi.yml, sdk-update.yml, CODEOWNERS). +# Adding the directory here means the generator never writes there in the +# first place, so there's nothing for the cleanup step to nuke. +.github/** diff --git a/scripts/post_generate.py b/scripts/post_generate.py index 0f39f7f..2af949d 100755 --- a/scripts/post_generate.py +++ b/scripts/post_generate.py @@ -31,9 +31,16 @@ def cleanup_generator_artifacts() -> None: """Remove unwanted files the generator may leave at the project root.""" print("Cleaning up generator artifacts...") + # NOTE: do NOT add ".github" to this list. The Python openapi-generator + # template used to write a default .github/workflows/python.yml, and an + # earlier version of this script `shutil.rmtree`'d the whole .github/ + # dir to clean that up — which collateral-deleted our own workflows + # (generate.yml, publish-pypi.yml, publish-testpypi.yml, sdk-update.yml) + # and CODEOWNERS on every regen. We now block the generator from writing + # to .github/ via .openapi-generator-ignore instead, so there's nothing + # to clean up here. for unwanted in [ ".gitlab-ci.yml", - ".github", "test-requirements.txt", ]: path = PROJECT_ROOT / unwanted