CI and regeneration¶
Push a change to your spec, and a pull request appears with every SDK regenerated. Each package has
a new version and a changelog entry, and the pull request lists the API changes, breaking ones
first. Add this workflow to the repository that holds your spec and oryva.yml:
on:
push:
branches: [main]
paths: [openapi.yaml, oryva.yml]
jobs:
sdks:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v7
- uses: Hopline-AI/oryva-releases@v0
with:
config: oryva.yml
previous-ir: sdks/python/.oryva/ir.json # any target's committed API model
current-version: 1.0.0 # optional: suggests the next version
fail-on-breaking: "false"
key: ${{ secrets.ORYVA_KEY }} # optional: see oryva keys
The GitHub Action¶
On each push that changes the spec or the config, the Action:
- installs oryva and ruff;
- regenerates every target in the config;
- writes the change report to the job summary;
- opens or updates a pull request on the branch
oryva/regenerate, with the change report as its description.
Without key, the free tier applies. To use a key, store it as a repository secret named
ORYVA_KEY; see oryva keys.
| Input | Default | |
|---|---|---|
config |
oryva.yml |
Path to oryva.yml. |
version |
latest |
The oryva release to install, such as v0.1.0, or skip when oryva is already on PATH. |
previous-ir |
Path to one target's committed .oryva/ir.json. Turns on the change report. |
|
current-version |
The SDKs' current version, so the report can suggest the next one. | |
fail-on-breaking |
"false" |
Fail the run when the change is breaking, after opening the pull request. |
create-pr |
"true" |
Open or update a pull request with the regenerated code. |
branch |
oryva/regenerate |
The pull request's branch. |
token |
github.token |
The token that opens the pull request. |
key |
An oryva key, from a repository secret. |
The breaking output is "true" when the change is breaking.
Regenerate by hand¶
oryva generate with no arguments reads ./oryva.yml and rewrites every target. Each target's
.oryva/manifest.json lists the files oryva wrote, with a hash for each. That list is how the next
run tells your edits from its own output.
If you edited a generated file, the run stops before it writes anything:
error: generated files in sdks/python were edited by hand:
README.md
Move custom code into files oryva doesn't generate, or rerun with --force to overwrite your edits.
Move your code into files oryva doesn't generate, or rerun with --force to overwrite your edits.
Each run also:
- deletes generated files the new output no longer has, and any directory left empty;
- leaves alone every file the manifest doesn't list, and stops, naming the path, if oryva needs one of them;
- sets each package's version and adds a
CHANGELOG.mdentry, as below.
Versions¶
Each run compares the spec with the API model in the target's .oryva/ir.json, and bumps the
version by what changed:
| Change | Bump |
|---|---|
| Breaking | major, or minor while on 0.x |
| Addition | minor |
| Anything else | patch |
To jump ahead, set version in oryva.yml higher. A prerelease such as 1.0.0-beta.1 stays a
prerelease: any change bumps its last number, to 1.0.0-beta.2, until you set version: 1.0.0.
A version that isn't SemVer is an error.
When nothing changed, the version stays and the run says so:
No API changes since the last run.
Changelog¶
Each run that changes the version adds an entry at the top of the target's CHANGELOG.md. After a
run that renamed a query parameter:
# Changelog
## 2.0.0
### Breaking (1)
- customers.list: param email removed
### Minor (1)
- customers.list: param email_address added
CHANGELOG.md is the one generated file you may edit. The next run keeps your text and puts its
entry above it.
Breaking changes¶
oryva diff compares two specs, or two ir.json files, and prints the breaking, minor and patch
changes. With --version, it also prints the next version:
oryva diff main-openapi.yaml openapi.yaml --version 1.0.0
# API changes
## Breaking (1)
- customers.list: param email removed
## Minor (1)
- customers.list: param email_address added
Next version: 1.0.0 -> 2.0.0
It exits with 1 when a change is breaking, so a CI step can stop on it. --json prints the same
report as JSON. In the Action, fail-on-breaking: "true" fails the run on a breaking change, after
it opens the pull request.