feat: add daily contract check for API schema drift detection#338
Open
Astro-Han wants to merge 1 commit intojackwener:mainfrom
Open
feat: add daily contract check for API schema drift detection#338Astro-Han wants to merge 1 commit intojackwener:mainfrom
Astro-Han wants to merge 1 commit intojackwener:mainfrom
Conversation
This was referenced Mar 24, 2026
a10741d to
2d8ed0c
Compare
…ner#50) Add a CI workflow that runs 25 public API commands daily, extracts schema snapshots (field names, types, presence rates), and diffs against the previous baseline to detect structural changes. - Four drift types: field_added, field_removed, type_changed, presence_dropped - Snapshots stored as CI artifacts (90-day retention), not committed to repo - Drift preserves old baseline until adapter is fixed - Atomic file writes to prevent CI cancel corruption - Total outage (0 passed) triggers CI failure - 22 unit tests covering extraction, diff, and reporting
f5068bf to
c2c0668
Compare
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.
Description
Add a daily CI workflow that detects schema drift in CLI command output, catching upstream API structural changes before users encounter broken adapters.
Related issue: #50
How it works
contract-check.yml) runs 25 public API commands across 15 sitesschema.ts) captures field names, types (distinguishing arrays from objects), and presence rates from command outputfield_added,field_removed,type_changed,presence_droppedKey design decisions
failed(with consecutive failure tracking) but don't trigger CI failure; only actual schema drift does. Exception: if ALL commands fail (total outage), CI fails.dawidd6/action-download-artifact(pinned to commit SHA) because GitHub's officialactions/download-artifactonly supports same-run downloads. This action is the standard solution for cross-workflow artifact access.Covered commands (25 across 15 sites)
hackernews (top/best/new/show/ask/jobs), v2ex, bloomberg, apple-podcasts, arxiv, bbc, devto, lobsters, stackoverflow, steam, wikipedia, sinafinance, weread, xiaoyuzhou, yollomi
Type of Change
Checklist
Follow-up suggestion
tests/contract/schema.test.tsis currently only executed in the dailycontract-checkworkflow. Consider addingtests/contract/to theunit-testjob path inci.ymlso these tests also run on PR submissions:Screenshots / Output
Local first run (17/25 passed, 8 failed due to network)
Second run — 0 false positives
Unit tests — 22 passed