Run IOModel validation in pre-commit hooks and CI pipelines.
For Git-projects, validation belongs in the same gates as code: a pre-commit hook to catch issues early, and CI to block invalid model or spec changes from merging.
Pre-commit
Validate changed model and spec files before they are committed.
# lefthook.yml
pre-commit:
commands:
iomodel-validate:
glob: "{models,specs}/**/*.{yaml,mdx}"
run: iomodel validate --json --quietGitHub Actions
# .github/workflows/iomodel-ci.yml
name: IOModel CI
on: [pull_request, push]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npx @iomodel/cli validate --json > validation.json
- uses: actions/upload-artifact@v4
if: always()
with:
name: validation
path: validation.jsonExit codes drive the gate
| Exit code | CI result |
|---|---|
0 | Pass (warnings allowed) |
1 | Fail — validation errors |
2 | Fail — fatal error (broken YAML, no project) |
Format checks too
Add iomodel format --check to CI to enforce consistent YAML. It exits
non-zero when files need formatting.
Recommended setup
Add a pre-commit hook
Catch errors locally before they reach review.
Add a CI job
Validate on every pull request and push.
Publish results
Upload the JSON report (or post it as a PR comment) for visibility.
Keep CI fast by validating the whole project on PRs and relying on the editor and pre-commit for incremental feedback during authoring.
Last updated on