Skip to content

Commit

Permalink
Add allow-unrecognized flag
Browse files Browse the repository at this point in the history
  • Loading branch information
kchason committed Oct 3, 2023
1 parent 3127bae commit b4ccc6c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ENV CASE_PATH "/opt/json/"
ENV CASE_VERSION "case-1.2.0"
ENV CASE_EXTENSION_FILTER ""
ENV CASE_VALIDATE_ABORT "false"
ENV CASE_ALLOW_UNRECOGNIZED "false"

# Required for annotating the GitHub pull request; optional otherwise
ENV REPORT_IN_PR "false"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ at [https://gitlab.com/keith.chason/case-validation-example](https://gitlab.com/
| case-version | CASE_VERSION | The version of the ontology against which the graph should be validatated. | "none", "case-0.5.0", "case-0.6.0" , "case-0.7.0", "case-0.7.1", "case-1.0.0", "case-1.1.0", "case-1.2.0" | "case-1.2.0" |
| extension-filter | CASE_EXTENSION_FILTER | The extension of only the files against which the validator should be run. Eg. `"json"`, `"jsonld"`, `"case"`. Defaults to `""` to run against all files defined in `case-path`. | Any | "" |
| abort | CASE_VALIDATE_ABORT | Whether to abort the validator on the first failure | "true", "false" | "false" |
| allow-unrecognized | CASE_ALLOW_UNRECOGNIZED | Whether to allow unrecognized CDO concepts in the graph. | "true", "false" | "false" |
| report-in-pr | REPORT_IN_PR | Whether or not to report the validation results in the pull request. Only reports if the action is triggered by a pull request. | "true", "false" | "false" |
| github-token | GITHUB_TOKEN | The GitHub token used to report the validation results in the pull request. | Any | "" |
| repository | GITHUB_REPOSITORY | The GitHub repository used to report the validation results in the pull request. | Any | "" |
Expand Down
7 changes: 6 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ inputs:
description: 'Whether to abort the validator on the first failure'
required: false
default: 'false'
allow-unrecognized:
description: 'Whether to allow unrecognized CDO concepts in the graph'
required: false
default: 'false'
report-in-pr:
description: 'Whether or not to report the validation results in the pull request. Only reports if the action is triggered by a pull request.'
required: false
Expand All @@ -39,12 +43,13 @@ inputs:
default: ''
runs:
using: 'docker'
image: 'docker://kchason/case-validator:1.4.0'
image: 'docker://kchason/case-validator:1.5.0'
env:
CASE_PATH: ${{ inputs.case-path }}
CASE_VERSION: ${{ inputs.case-version }}
CASE_EXTENSION_FILTER: ${{ inputs.extension-filter }}
CASE_VALIDATE_ABORT: ${{ inputs.abort }}
CASE_ALLOW_UNRECOGNIZED: ${{ inputs.allow-unrecognized }}
REPORT_IN_PR: ${{ inputs.report-in-pr }}
GITHUB_TOKEN: ${{ inputs.github-token }}
GITHUB_REPOSITORY: ${{ inputs.repository }}
Expand Down
14 changes: 12 additions & 2 deletions entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
)
case_path: str = os.environ.get("CASE_PATH", "/opt/json/")
extension_filter: str = os.environ.get("CASE_EXTENSION_FILTER", "")
allow_unrecognized: bool = (
os.environ.get("CASE_ALLOW_UNRECOGNIZED", "false").lower() == "true"
)
report_in_pr = os.getenv("REPORT_IN_PR", "false").lower() == "true"
github_repo = os.getenv("GITHUB_REPOSITORY")
github_token = os.getenv("GITHUB_TOKEN")
Expand All @@ -23,6 +26,7 @@
# Print the variables with their keys for debugging
print(f"CASE_VERSION: {case_version}")
print(f"CASE_VALIDATE_ABORT: {abort_on_failure}")
print(f"CASE_ALLOW_UNRECOGNIZED: {allow_unrecognized}")
print(f"CASE_PATH: {case_path}")
print(f"CASE_EXTENSION_FILTER: {extension_filter}")
print(f"REPORT_IN_PR: {report_in_pr}")
Expand Down Expand Up @@ -115,7 +119,10 @@ def annotate_pr(message: str) -> None:
has_failure: bool = False
for f in files:
result: ValidationResult = validate(
f, case_version=case_version, abort_on_first=abort_on_failure
f,
case_version=case_version,
abort_on_first=abort_on_failure,
allow_warnings=allow_unrecognized,
)

print(f"Validating file at: {f}")
Expand All @@ -136,7 +143,10 @@ def annotate_pr(message: str) -> None:
# If the path is a file, then it is assumed it should be validated
# and ignore the filter
result: ValidationResult = validate(
case_path, case_version=case_version, abort_on_first=abort_on_failure
case_path,
case_version=case_version,
abort_on_first=abort_on_failure,
allow_warnings=allow_unrecognized,
)

print(f"Validating file at: {case_path}")
Expand Down

0 comments on commit b4ccc6c

Please sign in to comment.