Skip to content

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

Merged
merged 52 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
61b331d
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
d4ccdfa
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
37a16c5
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
7004de4
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
bc0301f
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
baaae11
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
724a856
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
60bd8dc
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
5c9dfc7
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
b24135b
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
261511e
Create blank.yml
ramishj Jun 19, 2024
9c34895
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
56635fb
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
a21cd44
Create Validate Ambassadors JSON.yml
ramishj Jun 19, 2024
7a99bb6
Delete .github/workflows/validate-ambassadors.yml
ramishj Jun 19, 2024
4d37b38
Delete .github/workflows/blank.yml
ramishj Jun 19, 2024
5edf727
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
a6a6fcc
Merge branch 'main' of https://github.com/ramishj/community
ramishj Jun 19, 2024
6f4bf57
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
f3b9cd0
Update Validate Ambassadors JSON.yml
ramishj Jun 19, 2024
e7a58bc
Update Validate Ambassadors JSON.yml
ramishj Jun 19, 2024
cb707ad
Update Validate Ambassadors JSON.yml
ramishj Jun 19, 2024
83ee27d
Update Validate Ambassadors JSON.yml
ramishj Jun 19, 2024
8dc36ca
Update Validate Ambassadors JSON.yml
ramishj Jun 19, 2024
bf66dc5
Update Validate Ambassadors JSON.yml
ramishj Jun 19, 2024
86ce0d8
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
7a9bd19
Update Validate Ambassadors JSON.yml
ramishj Jun 19, 2024
a472f6a
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
05c338e
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
4e5f49f
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
46b51e6
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
50b9097
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
48ec5b8
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
7d3c563
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
5573ee3
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
8025764
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
10bd026
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
c880b3e
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
91d6af8
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
1aca772
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
3cb88ac
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
d4c2655
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
880f5f7
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
0110c60
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
a1c5369
Added Workflow to verify ambassaor.json schema
ramishj Jun 19, 2024
fa09281
Update .github/workflows/Validate Ambassadors JSON.yml
ramishj Jun 21, 2024
9adb1a8
Update ambassadors-schema.json
ramishj Jun 21, 2024
8a440dd
Update Validate Ambassadors JSON.yml
ramishj Jun 21, 2024
762d2d1
add mastodon optional property
benjagm Jun 23, 2024
2e4d8b9
Update Validate Ambassadors JSON.yml
ramishj Jun 24, 2024
96d0586
Update Validate Ambassadors JSON.yml
ramishj Jun 24, 2024
4b668fb
Update Validate Ambassadors JSON.yml
ramishj Jun 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/Validate Ambassadors JSON.yml
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');
Copy link
Collaborator

Choose a reason for hiding this comment

The 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: ajv/dist/2020

Right now the action is failing:
https://github.com/json-schema-org/community/actions/runs/9631882401

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);
}"


77 changes: 77 additions & 0 deletions programs/ambassadors/ambassadors-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
Copy link
Collaborator

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried updating it but got this error while testing should i chnage the script and manually check for each entry in schema?
Uploading Screenshot 2024-06-21 at 8.31.38 PM.png…

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benjagm Sir , could please advice what should we do...

Copy link
Member

@JeelRajodiya JeelRajodiya Jun 23, 2024

Choose a reason for hiding this comment

The 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?

The below is the screenshot
image

"type": "array",
"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"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have pending PRs which have more types than this.
@benjagm did you want to expand this list (and/or the list in the document)?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets add:

  • book
  • paper
  • initiative
  • project
  • working group

},
"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"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make twitter and linkedin optional.

}
}
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://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"
}
]
}
]
Loading