Skip to content

Commit 5f050a0

Browse files
committed
Final correction1
1 parent 77527b6 commit 5f050a0

File tree

2 files changed

+30
-35
lines changed

2 files changed

+30
-35
lines changed

bin/json_tests_workflow.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22
import os
33
import sys
44
import json
5+
import re
56

6-
def commit_and_push_changes(repo, branch, commit_message):
7-
try:
8-
repo.git.add(update=True)
9-
repo.index.commit(commit_message)
10-
origin = repo.remote(name='origin')
11-
origin.push(refspec=branch)
12-
print("Changes committed and pushed successfully.")
13-
except Exception as e:
14-
print(f"Error occurred while committing and pushing changes: {str(e)}")
7+
8+
def print_github_action_notice(file_name, message):
9+
print(f"::notice file={file_name}::{message}")
1510

1611
def main():
1712

@@ -52,21 +47,20 @@ def main():
5247
urls = json.loads(repo.get_contents("specification_urls.json").decoded_content.decode('utf-8'))
5348

5449
branch_name = pr.head.ref
55-
print(branch_name)
5650
changed_file_content = repo.get_contents(file, ref=branch_name).decoded_content.decode('utf-8')
51+
5752
# Parse JSON content
58-
print("--------")
5953
try:
6054
json_content = json.loads(changed_file_content)
6155
for test in json_content:
62-
print(test)
6356
if "specification" in test:
6457
for specification_object in test["specification"]:
65-
for key, value in specification_object.items():
66-
if key in ["core", "validation", "hyper-schema"]:
67-
print(urls[draft][key] + value)
68-
elif key in ["quote"]: continue
69-
else: print(urls[key] + value)
58+
for spec, section in specification_object.items():
59+
if spec in ["core", "validation", "hyper-schema"]: print_github_action_notice(file, urls[draft][spec] + section)
60+
elif spec in ["quote"]: continue
61+
elif spec in ["ecma262", "perl5"]: print_github_action_notice(file, urls[spec] + section)
62+
elif re.match("^rfc\\d+$"): print_github_action_notice(file, urls["rfc"] + spec + ".txt#" + section)
63+
else: print_github_action_notice(file, urls["iso"])
7064
except json.JSONDecodeError as e:
7165
print(f"Error parsing JSON in file '{file}': {e}")
7266

bin/specification_urls.json

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,32 @@
33
"core": "https://json-schema.org/draft-03/draft-zyp-json-schema-03.pdf"
44
},
55
"draft4": {
6-
"core": "https://json-schema.org/draft-04/draft-zyp-json-schema-04",
7-
"validation": "https://json-schema.org/draft-04/draft-fge-json-schema-validation-00"
6+
"core": "https://json-schema.org/draft-04/draft-zyp-json-schema-04#rfc.section.",
7+
"validation": "https://json-schema.org/draft-04/draft-fge-json-schema-validation-00#rfc.section.",
8+
"hyper-schema": "https://json-schema.org/draft-04/draft-luff-json-hyper-schema-00#rfc.section."
89
},
910
"draft6": {
10-
"core": "https://json-schema.org/draft-06/draft-wright-json-schema-01",
11-
"validation": "https://json-schema.org/draft-06/draft-wright-json-schema-validation-01",
12-
"hyper-schema": "https://json-schema.org/draft-06/draft-wright-json-schema-hyperschema-01"
11+
"core": "https://json-schema.org/draft-06/draft-wright-json-schema-01#rfc.section.",
12+
"validation": "https://json-schema.org/draft-06/draft-wright-json-schema-validation-01#rfc.section.",
13+
"hyper-schema": "https://json-schema.org/draft-06/draft-wright-json-schema-hyperschema-01#rfc.section."
1314
},
1415
"draft7": {
15-
"core": "https://json-schema.org/draft-07/draft-handrews-json-schema-01",
16-
"validation": "https://json-schema.org/draft-07/draft-handrews-json-schema-validation-01",
17-
"hyper-schema": "https://json-schema.org/draft-07/draft-handrews-json-schema-hyperschema-01"
16+
"core": "https://json-schema.org/draft-07/draft-handrews-json-schema-01#rfc.section.",
17+
"validation": "https://json-schema.org/draft-07/draft-handrews-json-schema-validation-01#rfc.section.",
18+
"hyper-schema": "https://json-schema.org/draft-07/draft-handrews-json-schema-hyperschema-01#rfc.section."
1819
},
1920
"draft2019-09": {
20-
"core": "https://json-schema.org/draft/2019-09/draft-handrews-json-schema-02",
21-
"validation": "https://json-schema.org/draft/2019-09/draft-handrews-json-schema-validation-02",
22-
"hyper-schema": "https://json-schema.org/draft/2019-09/draft-handrews-json-schema-hyperschema-02"
21+
"core": "https://json-schema.org/draft/2019-09/draft-handrews-json-schema-02#rfc.section.",
22+
"validation": "https://json-schema.org/draft/2019-09/draft-handrews-json-schema-validation-02#rfc.section.",
23+
"hyper-schema": "https://json-schema.org/draft/2019-09/draft-handrews-json-schema-hyperschema-02#rfc.section."
2324
},
2425
"draft2020-12": {
25-
"core": "https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01",
26-
"validation": "https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01",
27-
"hyper-schema": "https://json-schema.org/draft/2019-09/draft-handrews-json-schema-hyperschema-02"
26+
"core": "https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-",
27+
"validation": "https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-",
28+
"hyper-schema": "https://json-schema.org/draft/2019-09/draft-handrews-json-schema-hyperschema-02#rfc.section."
2829
},
29-
"rfc": "",
30-
"ecma262": "",
31-
"iso": "",
32-
"perl5": ""
30+
"ecma262": "https://262.ecma-international.org/",
31+
"perl5": "https://perldoc.perl.org/perlre#",
32+
"rfc": "https://www.rfc-editor.org/rfc/",
33+
"iso": "https://www.iso.org/obp/ui"
3334
}

0 commit comments

Comments
 (0)