diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 5954e15..f29bc8f 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -18,12 +18,9 @@ jobs: # Lint the Dockerfile for syntax correctness and conformance with # standards. - - name: Docker Lint - uses: luke142367/Docker-Lint-Action@v1.0.0 + - uses: hadolint/hadolint-action@v3.1.0 with: - target: Dockerfile - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + dockerfile: Dockerfile test: runs-on: ubuntu-latest diff --git a/Dockerfile b/Dockerfile index 47f0869..a3d7fdd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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" diff --git a/README.md b/README.md index 848b85b..4700949 100644 --- a/README.md +++ b/README.md @@ -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 | "" | diff --git a/action.yml b/action.yml index 1ace129..94419fd 100644 --- a/action.yml +++ b/action.yml @@ -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 @@ -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 }} diff --git a/entrypoint.py b/entrypoint.py index 463808d..6f6da62 100644 --- a/entrypoint.py +++ b/entrypoint.py @@ -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") @@ -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}") @@ -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}") @@ -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}")