Skip to content

Feature branch #745

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

Closed
wants to merge 52 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
40bcb8b
Corrected replaced unevaluated with additoinalProperties
suprith-hub Apr 17, 2024
4eac02c
First workflow
suprith-hub Apr 23, 2024
810d148
First workflow2
suprith-hub Apr 23, 2024
eecc7b7
Merge branch 'main' of https://github.com/Era-cell/JSON-Schema-Test-S…
suprith-hub Apr 23, 2024
3558c2c
Fake add to tests
suprith-hub Apr 23, 2024
9ca30b3
Fake add to tests from feature -B
suprith-hub Apr 23, 2024
ce52852
Python file location changed
suprith-hub Apr 23, 2024
bac5565
Location corrected
suprith-hub Apr 23, 2024
79dc92f
TOKEN
suprith-hub Apr 23, 2024
1f02ec4
Deleted for .github
suprith-hub Apr 23, 2024
31bf1bb
Merge branch 'main' into feature-branch
suprith-hub Apr 23, 2024
f1b17cf
Merge branch 'main' of https://github.com/Era-cell/JSON-Schema-Test-S…
suprith-hub Apr 23, 2024
cbdd175
change day2
suprith-hub Apr 24, 2024
1dcd27a
Merge branch 'main' of https://github.com/Era-cell/JSON-Schema-Test-S…
suprith-hub Apr 24, 2024
5edfcd9
Merge branch 'feature-branch' of https://github.com/Era-cell/JSON-Sch…
suprith-hub Apr 24, 2024
c6b937c
Reading all jsons and spec urls added
suprith-hub Apr 24, 2024
730fdc5
Merge branch 'main' of https://github.com/Era-cell/JSON-Schema-Test-S…
suprith-hub Apr 24, 2024
df3bdec
path corrected
suprith-hub Apr 24, 2024
582e12b
logging logs check
suprith-hub Apr 24, 2024
9bc2f49
Merge branch 'main' of https://github.com/Era-cell/JSON-Schema-Test-S…
suprith-hub Apr 24, 2024
ab5f5ba
Chack 2
suprith-hub Apr 24, 2024
f29d090
Wrong location sepcification
suprith-hub Apr 24, 2024
7552e24
Location of spec corrected
suprith-hub Apr 24, 2024
6ee2089
Merge branch 'main' into feature-branch
suprith-hub Apr 24, 2024
540a269
Log2
suprith-hub Apr 24, 2024
b897a92
New test Pr
suprith-hub Apr 24, 2024
ce7b149
Merge branch 'feature-branch' of https://github.com/Era-cell/JSON-Sch…
suprith-hub Apr 24, 2024
7fd1ef0
---
suprith-hub Apr 24, 2024
eb8fd76
Branch name specified
suprith-hub Apr 24, 2024
bfe85f4
Lets see now
suprith-hub Apr 24, 2024
77527b6
Stupidity corrected
suprith-hub Apr 24, 2024
5f050a0
Final correction1
suprith-hub Apr 24, 2024
26c5e98
Merge branch 'main' of https://github.com/Era-cell/JSON-Schema-Test-S…
suprith-hub Apr 24, 2024
a538187
lets see3
suprith-hub Apr 24, 2024
96f7683
Final correction2 - file names beautufied
suprith-hub Apr 24, 2024
24784f9
test all
suprith-hub Apr 24, 2024
302abe6
Merge branch 'main' of https://github.com/Era-cell/JSON-Schema-Test-S…
suprith-hub Apr 24, 2024
1c17519
regex correction
suprith-hub Apr 24, 2024
891d026
First workflow2
suprith-hub Apr 23, 2024
7b84fb4
Merge branch 'main' of https://github.com/Era-cell/JSON-Schema-Test-S…
suprith-hub Apr 24, 2024
564e695
Walking through all leaf files
suprith-hub Apr 30, 2024
e4df56e
Merge branch 'main' into feature-branch
suprith-hub Apr 30, 2024
7b40efe
Base path for neighbouring file?
suprith-hub Apr 30, 2024
e88a2da
Works for all OS
suprith-hub Apr 30, 2024
a4fb199
Merge branch 'main' into feature-branch
suprith-hub Apr 30, 2024
9a2612a
hellola
suprith-hub Apr 30, 2024
8a04495
Merge branch 'feature-branch' of https://github.com/Era-cell/JSON-Sch…
suprith-hub Apr 30, 2024
2b1ffb7
Best practices followed with optimized code
suprith-hub Apr 30, 2024
7cdc3fa
Merge branch 'main' into feature-branch
suprith-hub Apr 30, 2024
15465ca
last test :)
suprith-hub Apr 30, 2024
043179b
Merge branch 'feature-branch' of https://github.com/Era-cell/JSON-Sch…
suprith-hub Apr 30, 2024
2ee8932
Clear exi
suprith-hub Apr 30, 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
21 changes: 21 additions & 0 deletions .github/workflows/show_specification_annotations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Show Specification Annotations

on:
pull_request:
paths:
- 'tests/**'

jobs:
annotate:
runs-on: ubuntu-latest

steps:
uses: actions/checkout@v4

- name: Generate Annotations
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Run Python script
run: python bin/annotation_workflow.py
67 changes: 67 additions & 0 deletions bin/annotation_workflow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import json
from pathlib import Path

def github_action_notice(file, url, line):
"""
Print GitHub action notice with file path, URL, and line number.

Parameters:
file (str): File path.
url (str): URL.
line (int): Line number.
"""
return f"::warning file={file},line={line}::Annotation: {url}"

def find_test_line_number(test_content, test_name):
"""
Find the line number of a test in the JSON content.

Parameters:
test_content (str): JSON content.
test_name (str): Test name.

Returns:
int: Line number of the test.
"""
lines = test_content.split("\n") # Split content into lines
for i, line in enumerate(lines, start=1): # Iterate over lines
if test_name in line: # Check if test name is found in the line
return i # Return the line number if found
return 1 # Return None if test name is not found

# Specify the path to the JSON file using pathlib.Path
json_file_path = Path("bin/specification_urls.json")

# Read specification URLs from JSON file using pathlib.Path
with json_file_path.open("r", encoding="utf-8") as f:
urls = json.load(f)

# Iterate through JSON files in tests folder and subdirectories

for file_path in Path("tests").rglob("*.json"):
# Read the file content using pathlib.Path
with file_path.open('r', encoding='utf-8') as f:
changed_file_content = f.read()

# Parse JSON content
try:
json_content = json.loads(changed_file_content)
for test in json_content:
if "specification" in test:
line_number = find_test_line_number(changed_file_content, test.get("description") )

for specification_object in test["specification"]:
for spec, section in specification_object.items():
draft = file_path.parent.name
if spec in ["quote"]:
continue
elif spec in ["core", "validation", "hyper-schema"]:
url = urls[draft][spec].format(spec=spec, section=section)
else:
url = urls[spec].format(spec=spec, section=section)
annotation = github_action_notice(file_path, url, line_number)
print(annotation)

except json.JSONDecodeError:
print(f"::error file={file_path}::Failed to parse JSON content")

34 changes: 34 additions & 0 deletions bin/specification_urls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"draft3": {
"core": "https://json-schema.org/draft-03/draft-zyp-json-schema-03.pdf"
},
"draft4": {
"core": "https://json-schema.org/draft-04/draft-zyp-json-schema-04#rfc.section.{section}",
"validation": "https://json-schema.org/draft-04/draft-fge-json-schema-validation-00#rfc.section.{section}",
"hyper-schema": "https://json-schema.org/draft-04/draft-luff-json-hyper-schema-00#rfc.section.{section}"
},
"draft6": {
"core": "https://json-schema.org/draft-06/draft-wright-json-schema-01#rfc.section.{section}",
"validation": "https://json-schema.org/draft-06/draft-wright-json-schema-validation-01#rfc.section.{section}",
"hyper-schema": "https://json-schema.org/draft-06/draft-wright-json-schema-hyperschema-01#rfc.section.{section}"
},
"draft7": {
"core": "https://json-schema.org/draft-07/draft-handrews-json-schema-01#rfc.section.{section}",
"validation": "https://json-schema.org/draft-07/draft-handrews-json-schema-validation-01#rfc.section.{section}",
"hyper-schema": "https://json-schema.org/draft-07/draft-handrews-json-schema-hyperschema-01#rfc.section.{section}"
},
"draft2019-09": {
"core": "https://json-schema.org/draft/2019-09/draft-handrews-json-schema-02#rfc.section.{section}",
"validation": "https://json-schema.org/draft/2019-09/draft-handrews-json-schema-validation-02#rfc.section.{section}",
"hyper-schema": "https://json-schema.org/draft/2019-09/draft-handrews-json-schema-hyperschema-02#rfc.section.{section}"
},
"draft2020-12": {
"core": "https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-{section}",
"validation": "https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-{section}",
"hyper-schema": "https://json-schema.org/draft/2019-09/draft-handrews-json-schema-hyperschema-02#rfc.section.{section}"
},
"ecma262": "https://262.ecma-international.org/{section}",
"perl5": "https://perldoc.perl.org/perlre#{section}",
"rfc": "https://www.rfc-editor.org/rfc/{spec}.txt#{section}",
"iso": "https://www.iso.org/obp/ui"
}
7 changes: 7 additions & 0 deletions tests/draft2020-12/allOf.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"description": "allOf",
"specification":[ { "core": "10.2" } ],
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
Expand Down Expand Up @@ -43,6 +44,7 @@
},
{
"description": "allOf with base schema",
"specification":[ { "core": "10.2", "validation": "1.2.3", "rfc1234": "2.3", "perl5": "Hello", "iso123": "Anysection" } ],
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {"bar": {"type": "integer"}},
Expand Down Expand Up @@ -92,6 +94,7 @@
},
{
"description": "allOf simple types",
"specification":[ { "core": "10.2", "validation": "1.2.3" } ],
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
Expand All @@ -114,6 +117,7 @@
},
{
"description": "allOf with boolean schemas, all true",
"specification":[ { "core": "10.2", "validation": "1.2.3" } ],
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [true, true]
Expand Down Expand Up @@ -211,6 +215,7 @@
},
{
"description": "allOf with the last empty schema",
"specification":[ { "core": "10.2", "validation": "1.2.3" } ],
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
Expand All @@ -233,6 +238,7 @@
},
{
"description": "nested allOf, to check validation semantics",
"specification":[ { "core": "10.2", "validation": "1.2.3" } ],
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
Expand Down Expand Up @@ -260,6 +266,7 @@
},
{
"description": "allOf combined with anyOf, oneOf",
"specification": [ { "core":"10.3.2.3", "quote": "The value of \"additionalProperties\" MUST be a valid JSON Schema." } ],
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [ { "multipleOf": 2 } ],
Expand Down
1 change: 1 addition & 0 deletions tests/draft2020-12/anchor.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
},
{
"description": "Location-independent identifier with base URI change in subschema",
"specification": [ { "core":"10.3.2.3", "quote": "The value of \"additionalProperties\" MUST be a valid JSON Schema." } ],
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "http://localhost:1234/draft2020-12/root",
Expand Down
Loading