Skip to content

CI guard: site post count must match Buttondown published#12

Merged
nycterent merged 1 commit into
mainfrom
test/post-count-guard
Jun 19, 2026
Merged

CI guard: site post count must match Buttondown published#12
nycterent merged 1 commit into
mainfrom
test/post-count-guard

Conversation

@nycterent

Copy link
Copy Markdown
Contributor

Make the count-mismatch class of bug (PR #11) impossible to ship again.

  • posts.find_dropped_published(emails) — published posts (sent/imported) missing a slug.
  • build.py asserts no dropped published posts and len(prepared) == count(sent+imported). The CI Build site step runs this on real Buttondown data → a future filter regression or a slugless published post fails the pipeline before deploy (andon).
  • 2 unit tests; real build prints 23 posts (Buttondown published: 23). 19 tests green. Squash-merge.

Adds posts.find_dropped_published() (published emails missing a slug) and
a build-time assertion that len(prepared) == count of sent+imported emails.
The CI Build step runs this on real Buttondown data, so the site count can
never silently drift from the published count again (andon). 2 unit tests.
Copilot AI review requested due to automatic review settings June 19, 2026 21:46
@nycterent nycterent merged commit 531de85 into main Jun 19, 2026
2 checks passed
@nycterent nycterent deleted the test/post-count-guard branch June 19, 2026 21:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a build-time/CI guard to ensure the rendered site’s published post count cannot silently drift from Buttondown’s published (sent+imported) count, preventing regressions like PR #11.

Changes:

  • Added posts.find_dropped_published(emails) to detect published emails that would be skipped due to missing/blank slugs.
  • Updated build.py to fail the build if any published posts would be dropped and to assert len(prepared) == published.
  • Added unit tests for find_dropped_published.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/test_posts.py Adds tests covering the new dropped-published detection behavior.
posts.py Introduces find_dropped_published helper for detecting slugless published emails.
build.py Adds CI/build guardrails: fail on slugless published posts and on published count mismatches.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread build.py
Comment on lines +93 to +102
# Guard: every published post (sent/imported) must become a page, so the
# site count can't silently drift from Buttondown's published count.
dropped = posts.find_dropped_published(emails)
if dropped:
raise ValueError(f"published posts dropped (missing slug): {dropped}")

published = sum(1 for e in emails if e.get("status") in posts.PUBLISHED_STATUSES)
print(f" {len(prepared)} posts (Buttondown published: {published})")
if len(prepared) != published:
raise ValueError(f"post count {len(prepared)} != Buttondown published {published}")
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