From 919c0774fc87785b7a6992d90919741178378681 Mon Sep 17 00:00:00 2001 From: Jeff Verkoeyen Date: Sat, 26 Oct 2024 16:36:56 -0700 Subject: [PATCH] Migrate to central schemas --- ...{json-yaml-validate.yml => presubmits.yml} | 26 ++- schema/status.json | 26 --- schema/v3.json | 167 ------------------ 3 files changed, 11 insertions(+), 208 deletions(-) rename .github/workflows/{json-yaml-validate.yml => presubmits.yml} (53%) delete mode 100644 schema/status.json delete mode 100644 schema/v3.json diff --git a/.github/workflows/json-yaml-validate.yml b/.github/workflows/presubmits.yml similarity index 53% rename from .github/workflows/json-yaml-validate.yml rename to .github/workflows/presubmits.yml index a183681..8fde996 100644 --- a/.github/workflows/json-yaml-validate.yml +++ b/.github/workflows/presubmits.yml @@ -10,28 +10,24 @@ permissions: pull-requests: write jobs: - json-yaml-validate: + validate-signals: runs-on: ubuntu-latest steps: + # Step 1: Check out the current repository - uses: actions/checkout@v4 - - name: Validate signalsets - id: json-yaml-validate-v3 - uses: GrantBirki/json-yaml-validate@v2.7.1 + # Step 2: Check out the central schema repository + - name: Checkout schemas repo + uses: actions/checkout@v4 with: - comment: "true" - base_dir: signalsets/v3/ - json_schema: schema/v3.json - - json-yaml-validate-meta: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 + repository: OBDb/.schemas + path: .schemas + # Step 3: Validate with schema from the central repository - name: Validate signalsets - id: json-yaml-validate + id: json-yaml-validate-v3 uses: GrantBirki/json-yaml-validate@v2.7.1 with: comment: "true" - base_dir: meta/ - json_schema: schema/status.json + base_dir: signalsets/v3/ + json_schema: .schemas/signals.json diff --git a/schema/status.json b/schema/status.json deleted file mode 100644 index 409c6f1..0000000 --- a/schema/status.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "testers": { - "type": "object", - "patternProperties": { - "^[0-9]{4}$": { - "type": "object", - "properties": { - "username": { - "type": "string" - }, - "onboarded": { - "type": "string", - "format": "date" - } - }, - "required": ["username", "onboarded"] - } - }, - "additionalProperties": false - } - }, - "required": ["testers"] - } \ No newline at end of file diff --git a/schema/v3.json b/schema/v3.json deleted file mode 100644 index c7246ac..0000000 --- a/schema/v3.json +++ /dev/null @@ -1,167 +0,0 @@ -{ - "type": "object", - "properties": { - "diagnosticLevel": { - "type": "string", - "minLength": 2, - "maxLength": 2 - }, - "commands": { - "type": "array", - "uniqueItems": true, - "minItems": 0, - "items": { - "type": "object", - "properties": { - "hdr": { "type": "string", "minLength": 3, "maxLength": 4 }, - "rax": { "type": "string", "minLength": 2, "maxLength": 3 }, - "fcm1": { "type": "boolean" }, - "cmd": { - "type": "object", - "properties": { - "01": { "type": "string", "minLength": 2, "maxLength": 2 }, - "21": { "type": "string", "minLength": 2, "maxLength": 2 }, - "22": { "type": "string", "minLength": 4, "maxLength": 4 } - } - }, - "freq": { "type": "number", "exclusiveMinimum": 0 }, - "signals": { - "type": "array", - "uniqueItems": true, - "minItems": 1, - "items": { - "type": "object", - "properties": { - "id": { "type": "string" }, - "name": { "type": "string" }, - "fmt": { - "type": "object", - "properties": { - "bix": { "type": "integer" }, - "len": { "type": "integer" }, - "sign": { "type": "boolean" }, - "min": { "type": "number" }, - "max": { "type": "number" }, - "add": { "type": "number" }, - "mul": { "type": "number" }, - "div": { "type": "number" }, - "unit": { "enum": [ - "ampereHours", - "amps", - "ascii", - "bars", - "celsius", - "centimeters", - "coulombs", - "degrees", - "fahrenheit", - "feet", - "gallons", - "gramsPerSecond", - "gravity", - "hex", - "hours", - "inches", - "joules", - "kelvin", - "kiloampereHours", - "kiloamps", - "kilogramsPerHour", - "kilojoules", - "kilometers", - "kilometersPerHour", - "kilopascal", - "kilovolts", - "kilowattHours", - "kilowatts", - "liters", - "meters", - "metersPerSecond", - "miles", - "milesPerHour", - "milliampereHours", - "milliamps", - "millivolts", - "milliwatts", - "minutes", - "normal", - "noyes", - "offon", - "percent", - "psi", - "radians", - "rpm", - "scalar", - "seconds", - "unknown", - "volts", - "watts", - "yards", - "yesno" - ]}, - "omin": { "type": "number" }, - "omax": { "type": "number" }, - "oval": { "type": "number" }, - "map": { "type": "object" } - } - }, - "path": { "type": "string" }, - "suggestedMetric": { "enum": [ - "electricRange", - "frontLeftTirePressure", - "frontRightTirePressure", - "fuelRange", - "fuelTankLevel", - "isCharging", - "odometer", - "pluggedIn", - "rearLeftTirePressure", - "rearRightTirePressure", - "speed", - "stateOfCharge", - "stateOfHealth" - ]}, - "description": { "type": "string" } - }, - "required": [ - "id", - "fmt", - "name" - ] - } - } - }, - "required": [ - "hdr", - "cmd", - "freq", - "signals" - ] - } - }, - "signalGroups": { - "type": "array", - "uniqueItems": true, - "minItems": 1, - "items": { - "type": "object", - "properties": { - "id": { "type": "string" }, - "matchingRegex": { "type": "string" }, - "suggestedMetricGroup": { "enum": [ - "batteryModulesStateOfCharge", - "batteryModulesVoltage" - ]}, - "name": { "type": "string" } - }, - "required": [ - "id", - "matchingRegex" - ] - } - } - }, - "required": [ - "commands" - ] -}