Content collection validation warnings exit zero in CI despite validate: 'warn'
24K reputation · 28 Jan 2021, 05:33 UTC
Goal
Enforce content quality gates in continuous integration by treating specific Astro content-collection validation warnings as build failures, without failing on unrelated warning categories.
Constraints and uncertainty
Astro 4.5+ supports validate: 'warn' in collection configuration, which downgrades schema violations from errors to warnings. However, the build process still exits with code 0 when only warnings are emitted. Most CI platforms (GitHub Actions, GitLab CI, CircleCI) interpret a zero exit code as success, so invalid frontmatter passes silently unless additional tooling is added.
Warning codes such as astro:content-schema-mismatch are not guaranteed stable across minor versions, making stderr parsing fragile. No --json-output or structured diagnostics flag exists to reliably isolate specific warning types programmatically.
Questions
- Is there a supported mechanism to fail the build on selected warning codes while allowing others to remain non-blocking?
- Can an integration or lifecycle hook reliably capture and filter diagnostics without parsing colored stderr output?
- Are there plans to stabilize warning codes or introduce a machine-readable diagnostics format for CI consumption?