Skip to content

Commit 709a9b9

Browse files
ramishjbenjagm
andauthored
Added Workflow to verify ambassaor.json schema (#758)
* 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>
1 parent 2c14f8c commit 709a9b9

File tree

3 files changed

+171
-22
lines changed

3 files changed

+171
-22
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Validate Ambassadors JSON
2+
3+
on:
4+
push:
5+
paths:
6+
- 'programs/ambassadors/ambassadors.json'
7+
pull_request:
8+
paths:
9+
- 'programs/ambassadors/ambassadors.json'
10+
11+
jobs:
12+
validate-json:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout Repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Node 20
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20'
23+
24+
- name: Install Dependencies
25+
run: npm install ajv ajv-formats
26+
27+
- name: Validate ambassadors.json
28+
run: |
29+
node -e "
30+
const Ajv = require('ajv/dist/2020');
31+
const addFormats = require('ajv-formats');
32+
const path = require('path');
33+
const fs = require('fs');
34+
const ambassadorsDir = path.join(process.env.GITHUB_WORKSPACE, 'programs', 'ambassadors');
35+
const schemaPath = path.join(ambassadorsDir, 'ambassadors-schema.json');
36+
const dataPath = path.join(ambassadorsDir, 'ambassadors.json');
37+
try {
38+
const schema = JSON.parse(fs.readFileSync(schemaPath, 'utf-8'));
39+
const data = JSON.parse(fs.readFileSync(dataPath, 'utf-8'));
40+
const ajv = new Ajv({ allErrors: true });
41+
addFormats(ajv);
42+
const validate = ajv.compile(schema);
43+
const valid = validate(data);
44+
if (!valid) {
45+
console.error('Validation failed:', validate.errors);
46+
process.exit(1);
47+
} else {
48+
console.log('ambassadors.json is valid.');
49+
}
50+
} catch (error) {
51+
console.error('Error validating ambassadors.json:', error);
52+
process.exit(1);
53+
}"
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"type": "array",
4+
"description": "Array of contributor profiles",
5+
"items": {
6+
"type": "object",
7+
"description": "Contributor profile",
8+
"properties": {
9+
"name": {
10+
"type": "string",
11+
"description": "Full name of the contributor"
12+
},
13+
"img": {
14+
"type": "string",
15+
"format": "uri",
16+
"description": "URL to the contributor's profile image"
17+
},
18+
"bio": {
19+
"type": "string",
20+
"description": "Brief biography of the contributor"
21+
},
22+
"title": {
23+
"type": "string",
24+
"description": "Professional title of the contributor"
25+
},
26+
"github": {
27+
"type": "string",
28+
"description": "GitHub profile URL of the contributor"
29+
},
30+
"twitter": {
31+
"type": "string",
32+
"description": "Twitter profile URL of the contributor"
33+
},
34+
"mastodon": {
35+
"type": "string",
36+
"description": "Mastodon profile URL of the contributor"
37+
},
38+
"linkedin": {
39+
"type": "string",
40+
"description": "LinkedIn profile URL of the contributor"
41+
},
42+
"company": {
43+
"type": "string",
44+
"description": "Company where the contributor works"
45+
},
46+
"country": {
47+
"type": "string",
48+
"description": "Country where the contributor is based"
49+
},
50+
"contributions": {
51+
"type": "array",
52+
"description": "List of contributions made by the contributor",
53+
"items": {
54+
"type": "object",
55+
"description": "Details of a specific contribution",
56+
"properties": {
57+
"type": {
58+
"type": "string",
59+
"enum": ["article", "talk", "video", "other", "book", "paper", "initiative", "project", "working group"],
60+
"description": "Type of the contribution"
61+
},
62+
"title": {
63+
"type": "string",
64+
"description": "Title of the contribution"
65+
},
66+
"date": {
67+
"type": "object",
68+
"description": "Date of the contribution",
69+
"properties": {
70+
"year": {
71+
"type": "integer",
72+
"minimum": 1900,
73+
"maximum": 2100,
74+
"description": "Year of the contribution"
75+
},
76+
"month": {
77+
"type": "string",
78+
"enum": ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
79+
"description": "Month of the contribution"
80+
}
81+
},
82+
"required": ["year", "month"]
83+
},
84+
"link": {
85+
"type": "string",
86+
"format": "uri",
87+
"description": "URL link to the contribution"
88+
}
89+
},
90+
"required": ["type", "title", "date", "link"]
91+
}
92+
}
93+
},
94+
"required": ["name", "img", "bio", "title", "github", "company", "country", "contributions"]
95+
}
96+
}

programs/ambassadors/ambassadors.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
[
2-
{
3-
"name": "I am the first Ambassador",
4-
"img": "https://avatars.githubusercontent.com/u/40007659?v=4",
5-
"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.",
6-
"title": "Schema Designer at ACME",
7-
"github": "iamthefirst",
8-
"twitter": "iamthefirst",
9-
"linkedin": "iamthefirst",
10-
"company": "ACME",
11-
"country": "🇺🇸",
12-
"contributions": [
13-
{
14-
"type": "article",
15-
"title": "Title of my first contribution",
16-
"date": {
17-
"year": 2024,
18-
"month": "May"
19-
},
20-
"link": "link-to-my-contribution"
21-
}
22-
]
23-
}
2+
{
3+
"name": "I am the first Ambassador",
4+
"img": "https://avatars.githubusercontent.com/u/40007659?v=4",
5+
"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.",
6+
"title": "Schema Designer at ACME",
7+
"github": "iamthefirst",
8+
"twitter": "iamthefirst",
9+
"linkedin": "iamthefirst",
10+
"company": "ACME",
11+
"country": "🇺🇸",
12+
"contributions": [
13+
{
14+
"type": "article",
15+
"title": "Title of my first contribution",
16+
"date": {
17+
"year": 2024,
18+
"month": "May"
19+
},
20+
"link": "https://github.com/my-contri"
21+
}
22+
]
23+
}
2424
]

0 commit comments

Comments
 (0)