Skip to content

FIX enforce immutability in CI#1729

Merged
hannahwestra25 merged 5 commits into
microsoft:mainfrom
hannahwestra25:hawestra/enforce_alembic_immutability
May 13, 2026
Merged

FIX enforce immutability in CI#1729
hannahwestra25 merged 5 commits into
microsoft:mainfrom
hannahwestra25:hawestra/enforce_alembic_immutability

Conversation

@hannahwestra25
Copy link
Copy Markdown
Contributor

Problem

The enforce_alembic_revision_immutability pre-commit hook is meant to keep versions append-only, but it silently passes in two CI scenarios:

  • Merge-queue / push-to-main — merge-base origin/main HEAD == HEAD, so the diff is empty.
  • Shallow CI checkouts — git merge-base returns nothing and the hook falls through to "no violations" (fails open).

Changes

enforce_alembic_revision_immutability.py:

  • Added a HEAD~1..HEAD check so violations introduced by merge commits on main are caught.
  • Fail closed in CI (CI / GITHUB_ACTIONS) when merge-base or HEAD~1 is unavailable; stay permissive locally.
  • Print the offending git diff --name-status lines instead of just a generic message.
    build_and_test.yml:
  • Set fetch-depth: 0 on actions/checkout so the hook has the history it needs.

Copy link
Copy Markdown
Contributor

@behnam-o behnam-o left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, but I think we can just replace the whole git process (fetch, merge-base, diff locally) with a direct comparison? left it in a comment, if you were able to test that, that might be cleaner, otherwise this looks great. Thank you!

Comment thread .github/workflows/build_and_test.yml
@hannahwestra25 hannahwestra25 enabled auto-merge May 13, 2026 22:09
@hannahwestra25 hannahwestra25 added this pull request to the merge queue May 13, 2026
Merged via the queue into microsoft:main with commit da334ca May 13, 2026
48 checks passed
@hannahwestra25 hannahwestra25 deleted the hawestra/enforce_alembic_immutability branch May 13, 2026 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants