Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release Revision

on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g. v2.1)'
required: true
type: string

jobs:
bump-version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Git
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"

- name: Bump revision and tag
run: |
VERSION=${{ github.event.inputs.version }}
git tag $VERSION
git push origin $VERSION

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.version }}
name: Release ${{ github.event.inputs.version }}
generate_release_notes: true
23 changes: 17 additions & 6 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,21 @@ on:

jobs:
validate:
name: Validate example payloads against JSON Schemas
name: Validate ${{ matrix.example }} against ${{ matrix.schema }}
runs-on: ubuntu-latest
permissions:
contents: read

strategy:
matrix:
include:
# This block will be auto-generated by a script step below
# Placeholder for manual fallback
- schema: schemas/vitals/v2.0.json
example: examples/vitals/v2.0.example.json
- schema: schemas/vitals/v2.1.json
example: examples/vitals/v2.1.example.json

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -25,9 +35,10 @@ jobs:
- name: Install AJV CLI
run: npm install --global ajv-cli@5

- name: Validate vitals v2.0 example
- name: Validate schema ${{ matrix.schema }}
run: |
ajv compile -s ${{ matrix.schema }}

- name: Validate example ${{ matrix.example }} against ${{ matrix.schema }}
run: |
ajv validate \
--spec=draft7 \
-s schemas/vitals/v2.0.json \
-d examples/vitals/v2.0.example.json
ajv validate --spec=draft7 -s ${{ matrix.schema }} -d ${{ matrix.example }}
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ medtech-telemetry-contract/
├── schemas/
│ └── vitals/
│ └── v2.0.json # JSON Schema — vitals payload v2.0
│ └── v2.1.json # JSON Schema — vitals payload v2.1 (if present)
├── examples/
│ └── vitals/
│ └── v2.0.example.json # Canonical example payload for v2.0
│ └── v2.1.example.json # Canonical example payload for v2.1 (if present)
├── docs/
│ └── vitals-v2.0.md # Human-readable field docs, units, invariants
└── .github/
└── workflows/
└── validate.yml # CI: validates every example against its schema
└── release.yml # CI: workflow to tag and release new schema versions
```

Future contracts (e.g. `schemas/predictions/sepsis/v1.0.json`) follow the same
Expand All @@ -39,11 +42,11 @@ pattern: schema → example → doc.

## Versioning Policy

- Each schema lives at a **fixed, immutable path** (e.g. `schemas/vitals/v2.0.json`).
- Breaking changes introduce a new file (`v2.1.json`, `v3.0.json`), **never** mutate an existing one.
- Releases are tagged: `vitals/v2.0`, `vitals/v2.1`, etc.
- Consumers should pin to a **specific commit SHA** for immutable builds (Yocto),
and may also track the corresponding human-readable tag for release notes.

- **Versioned filenames:** Each schema and example file is named with its version (e.g. `v2.0.json`, `v2.1.json`). When a new version is released, create new files with the updated version in the filename. Do not overwrite or mutate existing versioned files.
- **Immutable contracts:** Never change a published schema file. Breaking changes require a new versioned file (e.g. `v2.1.json`, `v3.0.json`).
- **Release workflow:** Use the `release.yml` GitHub Actions workflow to tag and release new schema versions. Tags should match the version (e.g. `vitals/v2.1`).
- **Pinning:** Consumers should pin to a specific commit SHA for immutable builds (e.g. Yocto), and may also track the corresponding tag for release notes.

---

Expand Down Expand Up @@ -98,10 +101,17 @@ function validateVitals(payload) {

## CI Validation

Every push and pull-request runs `.github/workflows/validate.yml`, which uses
[AJV CLI](https://github.com/ajv-validator/ajv-cli) to validate every example
payload in `examples/` against its corresponding schema in `schemas/`. This
ensures that the example and the schema never diverge.

### CI Validation

Every push and pull-request runs `.github/workflows/validate.yml`, which uses [AJV CLI](https://github.com/ajv-validator/ajv-cli) to validate every example payload in `examples/` against its corresponding schema in `schemas/`. The workflow automatically checks all versioned schemas and examples, ensuring that the example and the schema never diverge.

### Release Workflow

To release a new schema version:
1. Add new versioned schema and example files (e.g. `v2.1.json`, `v2.1.example.json`).
2. Run the `release.yml` workflow from the GitHub Actions tab, specifying the new version (e.g. `v2.1`).
3. The workflow will tag the release and create a GitHub Release entry.

---

Expand Down
Loading