Skip to content
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

Add allow-unrecognized Flag #17

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 2 additions & 5 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ jobs:

# Lint the Dockerfile for syntax correctness and conformance with
# standards.
- name: Docker Lint
uses: luke142367/[email protected]
- uses: hadolint/[email protected]
with:
target: Dockerfile
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
dockerfile: Dockerfile

test:
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM python:3.11-slim-bullseye
WORKDIR /opt/workspace

# Install dependencies
RUN python -m pip install case-utils==0.13.0 PyGithub
RUN python -m pip install --no-cache-dir case-utils==0.13.0 PyGithub==2.1.1

# Delete source files now that package has been installed
WORKDIR /opt/workspace
Expand All @@ -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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line shows the current granularity potential of this configuration parameter.

case_validate.validate does not have a specific option for ignoring warnings generated by the IRI typo-checker function. It only has an option for ignoring all warnings, which also includes SHACL validation warnings.

)

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