CI guard: site post count must match Buttondown published#12
Merged
Conversation
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.
There was a problem hiding this comment.
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.pyto fail the build if any published posts would be dropped and to assertlen(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 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}") |
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.
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.pyasserts no dropped published posts andlen(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).23 posts (Buttondown published: 23). 19 tests green. Squash-merge.