Skip to content

Commit 76366a9

Browse files
committed
fix(json): missing comma and validation ci step
1 parent 398f8de commit 76366a9

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Validate JSON
2+
3+
on:
4+
push:
5+
paths:
6+
- "**.json"
7+
pull_request:
8+
paths:
9+
- "**.json"
10+
11+
jobs:
12+
validate-json:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: "20"
21+
22+
- name: Create validation script
23+
run: |
24+
cat > validate-json.js << 'EOF'
25+
const fs = require('fs');
26+
const path = require('path');
27+
28+
// Schema for org.json
29+
const orgSchema = {
30+
type: 'array',
31+
items: {
32+
type: 'object',
33+
required: ['id', 'name', 'description', 'org_url', 'logo_url'],
34+
properties: {
35+
id: { type: 'string' },
36+
name: { type: 'string' },
37+
description: { type: 'string' },
38+
org_url: {
39+
type: 'string',
40+
format: 'uri'
41+
},
42+
logo_url: {
43+
type: 'string',
44+
format: 'uri'
45+
}
46+
}
47+
}
48+
};
49+
50+
function validateJson(filePath) {
51+
try {
52+
const content = fs.readFileSync(filePath, 'utf8');
53+
JSON.parse(content); // This will throw if JSON is invalid
54+
console.log(`✅ ${filePath} is valid JSON`);
55+
return true;
56+
} catch (error) {
57+
console.error(`❌ ${filePath} is invalid JSON:`, error.message);
58+
process.exit(1);
59+
}
60+
}
61+
62+
// Find and validate all JSON files
63+
const jsonFiles = fs.readdirSync('.')
64+
.filter(file => file.endsWith('.json'));
65+
66+
jsonFiles.forEach(validateJson);
67+
EOF
68+
69+
- name: Install validation dependencies
70+
run: npm install ajv ajv-formats
71+
72+
- name: Validate JSON files
73+
run: node validate-json.js

org.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
{
3838
"id": "gainforest",
3939
"name": "GainForest",
40-
"description": "GainForest.Earth is a decentralized science non-profit that develops equitable nature tech to inform transparent environmental decision making."
40+
"description": "GainForest.Earth is a decentralized science non-profit that develops equitable nature tech to inform transparent environmental decision making.",
4141
"org_url": "https://gainforest.earth/",
4242
"logo_url": "https://gainforest-images.s3.eu-west-2.amazonaws.com/gainforest-logo.png"
4343
}

0 commit comments

Comments
 (0)