From 44b9a9191fae045f6e537ab11c67dd23fa1d7c90 Mon Sep 17 00:00:00 2001 From: andylizi Date: Fri, 13 Jan 2023 16:41:12 +0800 Subject: [PATCH] Validate `features.json` during CI --- .github/workflows/{deploy.yml => ci.yml} | 34 ++++++++++- features.json | 2 +- features.schema.json | 78 ++++++++++++++++++++++++ roadmap.js | 3 + 4 files changed, 113 insertions(+), 4 deletions(-) rename .github/workflows/{deploy.yml => ci.yml} (50%) create mode 100644 features.schema.json diff --git a/.github/workflows/deploy.yml b/.github/workflows/ci.yml similarity index 50% rename from .github/workflows/deploy.yml rename to .github/workflows/ci.yml index d97e8fb5..df20106e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Build & deploy +name: CI on: push: @@ -7,21 +7,49 @@ on: branches: [ main ] jobs: - build: + test: + name: Test + runs-on: ubuntu-latest + permissions: {} + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: false # Currently not necessary + + - name: Set up Node + uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install JSON validator + run: npm install -g ajv-cli@5 ajv-formats@2 + + - name: Validate features table + run: ajv -c ajv-formats -s features.schema.json -d features.json --strict=true --errors=text + + build: + name: Build & Deploy runs-on: ubuntu-latest + permissions: + contents: write steps: - - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v3 with: submodules: recursive + - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: 2.7 bundler-cache: true + - name: Build run: bundle exec jekyll build + - name: Deploy if: github.event_name == 'push' uses: peaceiris/actions-gh-pages@v3 diff --git a/features.json b/features.json index 9907ed77..e2172311 100644 --- a/features.json +++ b/features.json @@ -1,4 +1,5 @@ { + "$schema": "./features.schema.json", "features": { "bigInt": { "description": "JS BigInt to Wasm i64 integration", @@ -146,7 +147,6 @@ "Wasmtime": { "url": "https://wasmtime.dev/", "logo": "/images/bca.svg", - "version": "0.33", "features": { "bigInt": null, "bulkMemory": "0.20", diff --git a/features.schema.json b/features.schema.json new file mode 100644 index 00000000..c79b8ab9 --- /dev/null +++ b/features.schema.json @@ -0,0 +1,78 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://github.com/WebAssembly/website/raw/main/features.schema.json", + "title": "WebAssembly feature table", + "type": "object", + "definitions": { + "feature-info": { + "type": "object", + "properties": { + "description": { "type": "string" }, + "url": { "type": "string", "format": "uri-reference" }, + "phase": { "type": "integer", "minimum": 1 } + }, + "additionalProperties": false, + "required": ["description", "url", "phase"] + }, + "browser-features": { + "type": "object", + "properties": { + "url": { "type": "string", "format": "uri" }, + "logo": { "type": "string", "format": "uri-reference" }, + "features": { + "type": "object", + "additionalProperties": { "$ref": "#/definitions/status" } + } + }, + "additionalProperties": false, + "required": ["url", "logo", "features"] + }, + "status": { + "title": "Status of this feature", + "anyOf": [ + { "$ref": "#/definitions/status-na" }, + { "$ref": "#/definitions/status-supported" }, + { "$ref": "#/definitions/status-unsupported" }, + { "$ref": "#/definitions/status-flag" }, + { "$ref": "#/definitions/status-version" }, + { "$ref": "#/definitions/status-note" } + ] + }, + "status-na": { "type": "null", "title": "Not applicable" }, + "status-supported": { "const": true, "title": "Supported in unknown version" }, + "status-unsupported": { "const": false, "title": "Unsupported" }, + "status-flag": { "const": "flag", "title": "Flag required" }, + "status-version": { "type": "string", "title": "Supported in this version", "minLength": 1 }, + "status-note": { + "type": "array", + "items": [ + { + "anyOf": [ + { "$ref": "#/definitions/status-na" }, + { "$ref": "#/definitions/status-supported" }, + { "$ref": "#/definitions/status-unsupported" }, + { "$ref": "#/definitions/status-flag" }, + { "$ref": "#/definitions/status-version" } + ] + }, + { "type": "string", "title": "Attached note", "minLength": 1 } + ], + "additionalItems": false, + "minItems": 2, + "maxItems": 2 + } + }, + "properties": { + "$schema": { "type": "string", "format": "uri-reference" }, + "features": { + "type": "object", + "additionalProperties": { "$ref": "#/definitions/feature-info" } + }, + "browsers": { + "type": "object", + "additionalProperties": { "$ref": "#/definitions/browser-features" } + } + }, + "additionalProperties": false, + "required": ["features", "browsers"] +} diff --git a/roadmap.js b/roadmap.js index d9bf0f32..b463e133 100644 --- a/roadmap.js +++ b/roadmap.js @@ -169,11 +169,14 @@ // * [true, "footnotes"] => supported, with "footnotes" // * ["version", "footnotes"] => supported since "version", with "footnotes" // ...and any combination thereof + + /** @type {null|boolean|string|[boolean|string,string]} */ let support = features[featName]; let box, note; // First extract the footnote part if it's an array if (Array.isArray(support)) { + if (support.length !== 2) throw new TypeError(); note = support[1]; support = support[0]; }