-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed 'JSON-Schema-Test-Suite/' changes from bf0360f4..9fc880bf
9fc880bf Merge pull request #740 from notEthan/format-pattern-control-char cbd48ea5 Simplify test of \a regex character to test directly against `pattern` schema d6f1010a Merge pull request #746 from json-schema-org/annotations 4aec22c1 Revert the changes to additionalProperties.json. 2dc10671 Move the workflow step title. d9ce71ac May as well also show quotes in the annotation. 1b719a84 Pick the line after the description when attaching spec annotations. 08105151 Markdown is apparently not (yet?) supported in annotations. 81645773 Tidy up the specification annotator a bit. 38628b79 Make the spec URLs structure a bit easier for internal use. 4ebbeaf4 Merge branch 'Era-cell/main' e4bd7554 dumbness2 corrected d8ade402 inside run 57c7c869 changed install location 11f8e511 Added installing command in workflow f2766616 template library, url loads changes c2badb12 Merge pull request #734 from OptimumCode/idn-hostname-arabic-indic-mixed dd9599a5 Merge branch 'main' of github.com:json-schema-org/JSON-Schema-Test-Suite 5b393436 add pr dependencies action 3a509007 Clear existin annotations on same PR 23674123 Cases for rfc and iso written separately 0b780b2c Corected yaml format 2b1ffb74 Best practices followed with optimized code e88a2da6 Works for all OS 7b40efe4 Base path for neighbouring file? 564e6957 Walking through all leaf files 7b84fb44 Merge branch 'main' of https://github.com/Era-cell/JSON-Schema-Test-Suite 891d0265 First workflow2 1c175195 regex correction 96f7683a Final correction2 - file names beautufied 5f050a07 Final correction1 77527b63 Stupidity corrected eb8fd760 Branch name specified 540a269b Log2 f29d090a Wrong location sepcification 582e12be logging logs check df3bdecc path corrected c6b937ca Reading all jsons and spec urls added cbdd1755 change day2 54f3784a Merge pull request #731 from MeastroZI/main 79dc92f1 TOKEN ce52852d Python file location changed 3558c2c6 Fake add to tests eecc7b7a Merge branch 'main' of https://github.com/Era-cell/JSON-Schema-Test-Suite 810d148a First workflow2 4eac02c7 First workflow ff29264c Merge pull request #741 from harrel56/chore/tabs-to-spaces 9f39cf73 use spaces instead of tabs 2f3b5f7a Corrected replaced unevaluated with additoinalProperties 40bcb8b3 Corrected replaced unevaluated with additoinalProperties fa9224d7 Merge pull request #732 from MeastroZI/main2 83bedd5c Changing descriptions 49f73429 fixing tests e6d6a081 adding more test cases 7e6c9be6 changing descriptions 959aca92 shifting test 605d7d78 Update propertyDependencies.json : test must be tests deb82824 test for dependentSchema and propertyDependencies with unevaluatedProperties and additionalProperties ea485124 Merge branch 'json-schema-org:main' into main 64a3e7b3 Merge pull request #721 from json-schema-org/gregsdennis/dynamicref-skips-resources b9f14e64 Fix $schema in new new test 3d5048e8 Merge pull request #733 from Era-cell/main 4ae14268 Add valid first character to avoid Bidi rule violation 2480edba Update additionalProperties.json formatting it 6aa79c0b Update additionalProperties.json formatting it 3e0139a5 Update tests/draft-next/additionalProperties.json 616240b0 Update tests/draft-next/additionalProperties.json c5f3e4ea Update tests/draft2020-12/propertyNames.json 964efb8e propertyNames doesn't affect additionalProperties, tests exist already for unevaluatedProps f08b884c Cases go under additional and unevaluated Properties 99864ff6 added tests for propertyNames with additionalProperties/unevaluatedProperties, also with specification property 3b5782b6 Update ref.json : changing $Ids 546b3561 test for $ref with $recursiveAnchor 57617f25 Merge pull request #726 from Era-cell/main 51fc69cd meta data and property names constraints added, additional Items: string 9b169bed specification takes array of objects having section and quote 1362a8cc Pattern for para corrected 340116ec Schema of specification in much structured 003ac021 Test-schema including sub-schema for scpecification 50a20280 adding specification enhancement for additionalProperties 604f5f99 Drop tests of `$id` and `$anchor` that just test values against meta-schema `pattern` for those properties 9cd64ec9 come on man, save all the files f494440e use unique $id in optional tests, too 468453b0 use unique $id 9ec6d17e fix copy/paste error b284f423 add tests for $dynamicRef skipping over resources git-subtree-dir: JSON-Schema-Test-Suite git-subtree-split: 9fc880bfb6d8ccd093bc82431f17d13681ffae8e
- Loading branch information
1 parent
f3f81e3
commit 7035056
Showing
36 changed files
with
869 additions
and
755 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Check PR Dependencies | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
check_dependencies: | ||
runs-on: ubuntu-latest | ||
name: Check Dependencies | ||
steps: | ||
- uses: gregsdennis/dependencies-action@main | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Generate Annotations | ||
run: pip install uritemplate && bin/annotate-specification-links |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
#!/usr/bin/env python3 | ||
""" | ||
Annotate pull requests to the GitHub repository with links to specifications. | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
from pathlib import Path | ||
from typing import Any | ||
import json | ||
import re | ||
import sys | ||
|
||
from uritemplate import URITemplate | ||
|
||
|
||
BIN_DIR = Path(__file__).parent | ||
TESTS = BIN_DIR.parent / "tests" | ||
URLS = json.loads(BIN_DIR.joinpath("specification_urls.json").read_text()) | ||
|
||
|
||
def urls(version: str) -> dict[str, URITemplate]: | ||
""" | ||
Retrieve the version-specific URLs for specifications. | ||
""" | ||
for_version = {**URLS["json-schema"][version], **URLS["external"]} | ||
return {k: URITemplate(v) for k, v in for_version.items()} | ||
|
||
|
||
def annotation( | ||
path: Path, | ||
message: str, | ||
line: int = 1, | ||
level: str = "notice", | ||
**kwargs: Any, | ||
) -> str: | ||
""" | ||
Format a GitHub annotation. | ||
See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions | ||
for full syntax. | ||
""" | ||
|
||
if kwargs: | ||
additional = "," + ",".join(f"{k}={v}" for k, v in kwargs.items()) | ||
else: | ||
additional = "" | ||
|
||
relative = path.relative_to(TESTS.parent) | ||
return f"::{level} file={relative},line={line}{additional}::{message}\n" | ||
|
||
|
||
def line_number_of(path: Path, case: dict[str, Any]) -> int: | ||
""" | ||
Crudely find the line number of a test case. | ||
""" | ||
with path.open() as file: | ||
description = case["description"] | ||
return next( | ||
(i + 1 for i, line in enumerate(file, 1) if description in line), | ||
1, | ||
) | ||
|
||
|
||
def main(): | ||
# Clear annotations which may have been emitted by a previous run. | ||
sys.stdout.write("::remove-matcher owner=me::\n") | ||
|
||
for version in TESTS.iterdir(): | ||
if version.name in {"draft-next", "latest"}: | ||
continue | ||
|
||
version_urls = urls(version.name) | ||
|
||
for path in version.rglob("*.json"): | ||
try: | ||
contents = json.loads(path.read_text()) | ||
except json.JSONDecodeError as error: | ||
error = annotation( | ||
level="error", | ||
path=path, | ||
line=error.lineno, | ||
col=error.pos + 1, | ||
title=str(error), | ||
) | ||
sys.stdout.write(error) | ||
|
||
for test_case in contents: | ||
specifications = test_case.get("specification") | ||
if specifications is not None: | ||
for each in specifications: | ||
quote = each.pop("quote", "") | ||
(kind, section), = each.items() | ||
|
||
number = re.search(r"\d+", kind) | ||
spec = "" if number is None else number.group(0) | ||
|
||
url = version_urls[kind].expand( | ||
spec=spec, | ||
section=section, | ||
) | ||
|
||
message = f"{url}\n\n{quote}" if quote else url | ||
sys.stdout.write( | ||
annotation( | ||
path=path, | ||
line=line_number_of(path, test_case), | ||
title="Specification Link", | ||
message=message, | ||
), | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"json-schema": { | ||
"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}" | ||
}, | ||
"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}" | ||
}, | ||
"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}" | ||
}, | ||
"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}" | ||
}, | ||
"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}" | ||
}, | ||
"draft3": { | ||
"core": "https://json-schema.org/draft-03/draft-zyp-json-schema-03.pdf" | ||
} | ||
}, | ||
|
||
"external": { | ||
"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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.