From 17c580745d9503dc365b571ec068be0ba238c1c9 Mon Sep 17 00:00:00 2001 From: logonoff Date: Fri, 1 Nov 2024 13:36:56 -0400 Subject: [PATCH] feat: add validation --- .github/workflows/validate-workshops.yml | 12 +++++ README.md | 2 + schema.json | 60 ++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 .github/workflows/validate-workshops.yml create mode 100644 schema.json diff --git a/.github/workflows/validate-workshops.yml b/.github/workflows/validate-workshops.yml new file mode 100644 index 0000000..ce09677 --- /dev/null +++ b/.github/workflows/validate-workshops.yml @@ -0,0 +1,12 @@ +on: [push, pull_request] + +jobs: + validate-workshops: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Validate metadata files against schema + uses: thiagodnf/yaml-schema-checker@v0.0.12 + with: + yamlFiles: '[0-9][0-9][0-9][0-9]/metadata.yml' + jsonSchemaFile: 'schema.json' diff --git a/README.md b/README.md index 7726c89..6d75ec7 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ Each file in /:year/metadata.yml has the following schema: | slides | string | Yes | The filename of the slides of the workshop. The slides must be in the same directory as the metadata.yml file. | | recording | string | Yes | The URL to the recording of the workshop. | +You may view the [JSON schema](./schema.json) for detailed information. + ## Static API The "API" allows programmatic access to the workshop archive. It is not a true API, but rather a collection of YML files that can be accessed through GET requests. diff --git a/schema.json b/schema.json new file mode 100644 index 0000000..5c3c08c --- /dev/null +++ b/schema.json @@ -0,0 +1,60 @@ +{ + "title": "Workshops", + "description": "An object containing a year's worth of workshops.", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://github.com/utmgdsc/workshops/blob/main/schema.json", + "patternProperties": { + "^.*$": { + "description": "The category name, e.g., \"Web Development\", \"Machine Learning\", etc.", + "type": "array", + "items": { + "description": "The metadata of a workshop.", + "type": "object", + "properties": { + "name": { + "description": "The name of the workshop.", + "type": "string" + }, + "host": { + "description": "An array of the names of the hosts of the workshop.", + "items": { + "type": "string" + }, + "type": "array" + }, + "description": { + "description": "The description of the workshop, e.g., it could be from an Instagram caption or announcement.", + "type": "string" + }, + "date": { + "description": "The date of the workshop in MM-DD format, since the year is already specified in the file path.", + "type": "string", + "pattern": "^([0][1-9]|[[1][0-2])-([0-2][0-9]|3[0-1])$" + }, + "code": { + "description": "The URL to the starter code code of the workshop.", + "type": "string", + "format": "uri" + }, + "slides": { + "description": "The filename of the slides of the workshop. The slides must be in the same directory as the metadata.yml file.", + "type": "string" + }, + "recording": { + "description": "The URL to the recording of the workshop.", + "type": "string", + "format": "uri" + } + }, + "additionalProperties": false, + "required": [ + "name", + "host", + "description", + "date" + ] + }, + "additionalProperties": false + } + } +}