Version the rule schema with releases
Build and publish rule engine / release (push) Failing after 2m32s
Build and publish rule engine / release (push) Failing after 2m32s
This commit is contained in:
@@ -8,7 +8,8 @@ remains responsible for validating and committing effects.
|
|||||||
## Contract
|
## Contract
|
||||||
|
|
||||||
Requests use NATS subject `ai-spel.rules.evaluate.v1` and contract version 1.
|
Requests use NATS subject `ai-spel.rules.evaluate.v1` and contract version 1.
|
||||||
The canonical JSON Schema is `contracts/rule-evaluation-v1.schema.json`.
|
The canonical JSON Schema is `contracts/rule-evaluation-v1.schema.json`; its
|
||||||
|
versioned `$id` is updated by the release version-bump workflow.
|
||||||
Responses echo the correlation ID and have status `evaluated` or `rejected`.
|
Responses echo the correlation ID and have status `evaluated` or `rejected`.
|
||||||
|
|
||||||
The NATS user may subscribe only to the evaluation subject and publish only to
|
The NATS user may subscribe only to the evaluation subject and publish only to
|
||||||
|
|||||||
@@ -9,9 +9,22 @@ match = re.search(r'(?ms)(^\[workspace\.package\]\s+.*?^version\s*=\s*")(\d+)\.(
|
|||||||
if not match:
|
if not match:
|
||||||
raise SystemExit("Missing [workspace.package].version")
|
raise SystemExit("Missing [workspace.package].version")
|
||||||
major, minor, patch = map(int, match.group(2, 3, 4))
|
major, minor, patch = map(int, match.group(2, 3, 4))
|
||||||
|
current_version = f"{major}.{minor}.{patch}"
|
||||||
version = f"{major}.{minor}.{patch + 1}"
|
version = f"{major}.{minor}.{patch + 1}"
|
||||||
cargo_path.write_text(cargo[:match.start(2)] + version + cargo[match.end(4):])
|
cargo_path.write_text(cargo[:match.start(2)] + version + cargo[match.end(4):])
|
||||||
|
|
||||||
|
lock_path = Path("Cargo.lock")
|
||||||
|
lock = lock_path.read_text()
|
||||||
|
lock_pattern = rf'(?ms)^\[\[package\]\]\nname\s*=\s*"ai-spel-rule-engine"\nversion\s*=\s*"{re.escape(current_version)}"'
|
||||||
|
if not re.search(lock_pattern, lock):
|
||||||
|
raise SystemExit(f"Missing ai-spel-rule-engine {current_version} package in {lock_path}")
|
||||||
|
lock_path.write_text(re.sub(
|
||||||
|
lock_pattern,
|
||||||
|
f'[[package]]\nname = "ai-spel-rule-engine"\nversion = "{version}"',
|
||||||
|
lock,
|
||||||
|
count=1,
|
||||||
|
))
|
||||||
|
|
||||||
for path, pattern in (
|
for path, pattern in (
|
||||||
(Path("deploy/helm/ai-spel-rule-engine/Chart.yaml"), r'(?m)^version:\s*\d+\.\d+\.\d+\s*$'),
|
(Path("deploy/helm/ai-spel-rule-engine/Chart.yaml"), r'(?m)^version:\s*\d+\.\d+\.\d+\s*$'),
|
||||||
(Path("deploy/helm/ai-spel-rule-engine/Chart.yaml"), r'(?m)^appVersion:\s*"\d+\.\d+\.\d+"\s*$'),
|
(Path("deploy/helm/ai-spel-rule-engine/Chart.yaml"), r'(?m)^appVersion:\s*"\d+\.\d+\.\d+"\s*$'),
|
||||||
@@ -24,4 +37,16 @@ for path, pattern in (
|
|||||||
f'appVersion: "{version}"' if pattern.startswith(r'(?m)^appVersion') else f' targetRevision: "{version}"'
|
f'appVersion: "{version}"' if pattern.startswith(r'(?m)^appVersion') else f' targetRevision: "{version}"'
|
||||||
)
|
)
|
||||||
path.write_text(re.sub(pattern, replacement, contents, count=1))
|
path.write_text(re.sub(pattern, replacement, contents, count=1))
|
||||||
|
|
||||||
|
schema_path = Path("contracts/rule-evaluation-v1.schema.json")
|
||||||
|
schema = schema_path.read_text()
|
||||||
|
schema_pattern = r'(?m)^ "\$id": "https://gitea\.k3s\.k0\.nu/ai-spel/ai-spel-rule-engine/raw/tag/v\d+\.\d+\.\d+/contracts/rule-evaluation-v1\.schema\.json",$'
|
||||||
|
if not re.search(schema_pattern, schema):
|
||||||
|
raise SystemExit(f"Missing versioned schema id in {schema_path}")
|
||||||
|
schema_path.write_text(re.sub(
|
||||||
|
schema_pattern,
|
||||||
|
f' "$id": "https://gitea.k3s.k0.nu/ai-spel/ai-spel-rule-engine/raw/tag/v{version}/contracts/rule-evaluation-v1.schema.json",',
|
||||||
|
schema,
|
||||||
|
count=1,
|
||||||
|
))
|
||||||
print(version)
|
print(version)
|
||||||
|
|||||||
Reference in New Issue
Block a user