Skip to content

Commit bd7ccb0

Browse files
committed
check JSON validity
1 parent 54d5cd1 commit bd7ccb0

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

.github/workflows/check_new_entry.yml renamed to .github/workflows/validate_json.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
name: Check JSON Entries
1+
name: Validate JSON Entries
2+
description: Validate JSON entries in awesome_open_geoscience.json
23

34
on:
45
push:

scripts/validate_json_entries.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@
1818
}
1919

2020
def validate_entries(json_file):
21-
with open(json_file, 'r', encoding='utf-8') as f:
22-
data = json.load(f)
21+
try:
22+
with open(json_file, 'r', encoding='utf-8') as f:
23+
data = json.load(f)
24+
except json.JSONDecodeError as e:
25+
print(f"Error: Invalid JSON in {json_file}\n{e}")
26+
sys.exit(1) # Exit with a non-zero code to fail the GitHub Action
2327

24-
# Validate schema
28+
# Validate against schema
2529
jsonschema.validate(instance=data, schema=schema)
2630

27-
# Check duplicates
31+
# Check for duplicates
2832
seen = set()
2933
duplicates = []
3034
for entry in data:

0 commit comments

Comments
 (0)