Skip to content

Fail PRs when a source query does not build - #150

Merged
edmundmiller merged 3 commits into
mainfrom
ci/check-sources
Aug 18, 2026
Merged

Fail PRs when a source query does not build#150
edmundmiller merged 3 commits into
mainfrom
ci/check-sources

Conversation

@edmundmiller

@edmundmiller edmundmiller commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

evidence sources logs a failing query and then exits 0. Nothing in CI runs the
source build, so broken source SQL merges cleanly and first surfaces as a failed
Netlify build, with the affected page down until someone notices.

This adds a workflow that runs evidence sources --strict on PRs touching
sources/. The CLI already has that flag; it fails on the first query error
instead of logging and continuing.

Fork PRs cannot read secrets, so the job skips with a notice rather than
reporting a failure the contributor cannot act on. That is the deliberate gap:
a source change arriving from a fork is still unguarded, and catching it would
need pull_request_target and the credential exposure that comes with it.

Found while reviewing #139, whose pipeline_timeline.sql reads a column the
ingestion pipeline has not created yet. Against the production database that
query fails today, and CI reports nothing.

`evidence sources` logs query errors but still exits 0, so a broken
source SQL file reaches main unnoticed and only surfaces as a failed
Netlify build. Nothing in CI ran the source build at all.

Add scripts/check-sources.mjs, which compares sources/**/*.sql against
the per-query directories Evidence writes under .evidence/meta/ (created
only on success), and a workflow that runs the build plus this check on
PRs touching sources/. Fork PRs cannot read secrets, so the job skips
with a notice instead of a spurious failure.

Found while reviewing #139, where sources/nfcore_db/pipeline_timeline.sql
references a column the ingestion pipeline has not created yet; the
build error was invisible to CI.
The Evidence CLI already exposes `sources --strict` ("Fail when a source
query fails"), which is what the hand-rolled script reimplemented. It is
also more accurate: it fails at the query with the database error, while
comparing .evidence/meta directories only reports which file produced no
output and can read stale output from an earlier build.
The fork check was a shell step that read the secret to find out whether
secrets were readable, then guarded all three remaining steps on its
output. GitHub reports the same thing directly, and a skipped job already
shows as neutral rather than failed.
@edmundmiller
edmundmiller merged commit 3d4a484 into main Aug 18, 2026
2 checks passed
@edmundmiller
edmundmiller deleted the ci/check-sources branch August 18, 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.

1 participant