-
-
Notifications
You must be signed in to change notification settings - Fork 52
Added Workflow to verify ambassaor.json schema #758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 45 commits
61b331d
d4ccdfa
37a16c5
7004de4
bc0301f
baaae11
724a856
60bd8dc
5c9dfc7
b24135b
261511e
9c34895
56635fb
a21cd44
7a99bb6
4d37b38
5edf727
a6a6fcc
6f4bf57
f3b9cd0
e7a58bc
cb707ad
83ee27d
8dc36ca
bf66dc5
86ce0d8
7a9bd19
a472f6a
05c338e
4e5f49f
46b51e6
50b9097
48ec5b8
7d3c563
5573ee3
8025764
10bd026
c880b3e
91d6af8
1aca772
3cb88ac
d4c2655
880f5f7
0110c60
a1c5369
fa09281
9adb1a8
8a440dd
762d2d1
2e4d8b9
96d0586
4b668fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
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.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16' | ||
|
||
- name: Install Dependencies | ||
run: npm install ajv ajv-formats | ||
|
||
- name: Validate ambassadors.json | ||
run: | | ||
node -e " | ||
const Ajv = require('ajv'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To run the validation against a 2020-12 schema the dependency to use is: Right now the action is failing: |
||
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); | ||
}" | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we change the json schema version to use the current 2020-12? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @benjagm Sir , could please advice what should we do... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ramishj, The image you uploaded is not visible, could you try uploading again please? |
||
"type": "array", | ||
benjagm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string" | ||
}, | ||
"img": { | ||
"type": "string", | ||
"format": "uri" | ||
}, | ||
"bio": { | ||
"type": "string" | ||
}, | ||
"title": { | ||
"type": "string" | ||
}, | ||
"github": { | ||
"type": "string" | ||
}, | ||
"twitter": { | ||
"type": "string" | ||
}, | ||
"linkedin": { | ||
"type": "string" | ||
}, | ||
"company": { | ||
"type": "string" | ||
}, | ||
"country": { | ||
"type": "string" | ||
}, | ||
"contributions": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"type": { | ||
"type": "string", | ||
"enum": ["article", "talk", "video", "other"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have pending PRs which have more types than this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets add:
|
||
}, | ||
"title": { | ||
"type": "string" | ||
}, | ||
"date": { | ||
"type": "object", | ||
"properties": { | ||
"year": { | ||
"type": "integer", | ||
"minimum": 1900, | ||
"maximum": 2100 | ||
}, | ||
"month": { | ||
"type": "string", | ||
"enum": [ | ||
"January", "February", "March", "April", "May", "June", | ||
"July", "August", "September", "October", "November", | ||
"December" | ||
] | ||
} | ||
}, | ||
"required": ["year", "month"] | ||
}, | ||
"link": { | ||
"type": "string", | ||
"format": "uri" | ||
} | ||
}, | ||
"required": ["type", "title", "date", "link"] | ||
} | ||
} | ||
}, | ||
"required": ["name", "img", "bio", "title", "github", "twitter", "linkedin", "company", "country", "contributions"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make twitter and linkedin optional. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
[ | ||
{ | ||
"name": "I am the first Ambassador", | ||
"img": "https://avatars.githubusercontent.com/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://avatars.githubusercontent.com/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" | ||
} | ||
] | ||
} | ||
] |
Uh oh!
There was an error while loading. Please reload this page.