Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/annotate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: ./
with:
case-path: "./tests/data/"
case-version: "case-1.3.0"
case-version: "case-1.4.0"
report-in-pr: "true"
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,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
Expand All @@ -38,17 +36,17 @@ jobs:
uses: ./
with:
case-path: "./tests/data/simple-case.jsonld"
case-version: "case-1.3.0"
case-version: "case-1.4.0"

- name: Run Action - Directory Filter
uses: ./
with:
case-path: "./tests/data/"
case-version: "case-1.3.0"
case-version: "case-1.4.0"
extension-filter: "jsonld"

- name: Run Action - Directory No Filter
uses: ./
with:
case-path: "./tests/data/"
case-version: "case-1.3.0"
case-version: "case-1.4.0"
18 changes: 9 additions & 9 deletions 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.16.0 PyGithub
RUN python -m pip install --no-cache-dir case-utils==0.17.0 PyGithub==2.6.1

# Delete source files now that package has been installed
WORKDIR /opt/workspace
Expand All @@ -13,16 +13,16 @@ WORKDIR /opt/workspace
COPY entrypoint.py /opt/workspace/entrypoint.py

# Define the base path for the validation path
ENV CASE_PATH "/opt/json/"
ENV CASE_VERSION "case-1.3.0"
ENV CASE_EXTENSION_FILTER ""
ENV CASE_VALIDATE_ABORT "false"
ENV CASE_PATH="/opt/json/"
ENV CASE_VERSION="case-1.4.0"
ENV CASE_EXTENSION_FILTER=""
ENV CASE_VALIDATE_ABORT="false"

# Required for annotating the GitHub pull request; optional otherwise
ENV REPORT_IN_PR "false"
ENV GITHUB_TOKEN ""
ENV GITHUB_REPOSITORY ""
ENV GITHUB_PULL_REQUEST ""
ENV REPORT_IN_PR="false"
ENV GITHUB_TOKEN=""
ENV GITHUB_REPOSITORY=""
ENV GITHUB_PULL_REQUEST=""

# Define the command to run the entrypoint.py script that will detect the type
# of the path that was provided, apply the filter extension (if appropriate) and
Expand Down
62 changes: 44 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ _This is an unofficial GitHub Action and not endorsed by the CASE Community or t
guarantees are made to its accuracy or functionality._

[![Repository Checks](https://github.com/kchason/case-validation-action/actions/workflows/validate.yml/badge.svg)](https://github.com/kchason/case-validation-action/actions/workflows/validate.yml)
![CASE Version](https://img.shields.io/badge/CASE%20Version-1.2.0-brightgreen.svg)
![CASE Version](https://img.shields.io/badge/CASE%20Version-1.4.0-brightgreen.svg)
[![Latest Tag](https://img.shields.io/github/v/tag/kchason/case-validation-action?label=action%20version)](https://github.com/kchason/case-validation-action/tags)
[![Docker Build Status](https://img.shields.io/docker/cloud/build/kchason/case-validator)](https://hub.docker.com/repository/docker/kchason/case-validator)
[![Docker Pulls](https://img.shields.io/docker/pulls/kchason/case-validator)](https://hub.docker.com/repository/docker/kchason/case-validator)
Expand All @@ -27,10 +27,10 @@ Include the validation action in your GitHub action workflow and specify the fil
```yaml
# Run the CASE validation job to confirm the output is valid
- name: CASE Export Validation
uses: kchason/case-validation-action@v2.9.0
uses: kchason/case-validation-action@v2.10.0
with:
case-path: ./output/
case-version: "case-1.3.0"
case-version: "case-1.4.0"
extension-filter: "jsonld"
report-in-pr: "true"
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -51,7 +51,7 @@ modified to fit custom use cases.
# To run the latest image and remove the container after execution.
docker run --rm \
-e CASE_PATH="/opt/case/" \
-e CASE_VERSION="case-1.3.0" \
-e CASE_VERSION="case-1.4.0" \
-e CASE_EXTENSION_FILTER="jsonld" \
-v "/path/to/local:/opt/case" \
kchason/case-validator:latest
Expand All @@ -70,7 +70,7 @@ at [https://gitlab.com/keith.chason/case-validation-example](https://gitlab.com/
| Action Variable | Environment Variable | Description | Options | Default |
|------------------|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|--------------|
| case-path | CASE_PATH | The path to the file or directory to be validated. | Any | /opt/json |
| 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.3.0" | "case-1.3.0" |
| 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.3.0", "case-1.4.0" | "case-1.4.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" |
| 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" |
Expand All @@ -92,23 +92,49 @@ Conforms: True

### Non-Conforming

Supposing a file with these contents:

```json
{
"@context": {
"kb": "http://example.org/kb/",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"uco-types": "https://ontology.unifiedcyberontology.org/uco/types/",
"xsd": "http://www.w3.org/2001/XMLSchema#"
},
"@graph": [
{
"@id": "kb:hash-25940dc2-4db9-4c01-9053-bc31f953fc4a",
"@type": "uco-types:Hash",
"rdfs:comment": "This node will pass validation.",
"uco-types:hashMethod": "SHA3-256",
"uco-types:hashValue": {
"@type": "xsd:hexBinary",
"@value": "c901cf247f1112334f51bdb5385db3b56d935f9fbc844c1b4a161b10c1c86d83"
}
},
{
"@id": "kb:hash-b896ba81-f07c-4035-9277-a101eb6782c3",
"@type": "uco-types:Hash",
"rdfs:comment": "This node will trigger a validation error due to leaving hashValue's value as an untyped string.",
"uco-types:hashMethod": "SHA3-256",
"uco-types:hashValue": "4c6e44aab46ce9023dc82a006f18a06be8f3c64a6b12739be51e706b5adffeb5"
}
]
}
```

```
Validating file at ./output/case.json
Validation Report
Conforms: False
Results (2):
Constraint Violation in MinCountConstraintComponent (http://www.w3.org/ns/shacl#MinCountConstraintComponent):
Severity: sh:Violation
Source Shape: [ sh:class core:UcoObject ; sh:minCount Literal("1", datatype=xsd:integer) ; sh:nodeKind sh:BlankNodeOrIRI ; sh:path core:object ]
Focus Node: kb:provenance-record-58e7566a-a934-4513-93b2-98fd43978a1c
Result Path: core:object
Message: Less than 1 values on kb:provenance-record-58e7566a-a934-4513-93b2-98fd43978a1c->core:object
Constraint Violation in MinCountConstraintComponent (http://www.w3.org/ns/shacl#MinCountConstraintComponent):
Results (1):
Constraint Violation in DatatypeConstraintComponent (http://www.w3.org/ns/shacl#DatatypeConstraintComponent):
Severity: sh:Violation
Source Shape: [ sh:class core:UcoObject ; sh:minCount Literal("1", datatype=xsd:integer) ; sh:nodeKind sh:BlankNodeOrIRI ; sh:path core:object ]
Focus Node: kb:provenance-record-a22fc197-6e53-4bc0-9832-d0b9f2b733d3
Result Path: core:object
Message: Less than 1 values on kb:provenance-record-a22fc197-6e53-4bc0-9832-d0b9f2b733d3->core:object
Source Shape: [ sh:datatype xsd:hexBinary ; sh:maxCount Literal("1", datatype=xsd:integer) ; sh:minCount Literal("1", datatype=xsd:integer) ; sh:nodeKind sh:Literal ; sh:path types:hashValue ]
Focus Node: kb:hash-b896ba81-f07c-4035-9277-a101eb6782c3
Value Node: Literal("4c6e44aab46ce9023dc82a006f18a06be8f3c64a6b12739be51e706b5adffeb5")
Result Path: types:hashValue
Message: Value is not Literal with datatype xsd:hexBinary
```

## GitHub Pull Request Decoration
Expand Down
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ inputs:
required: false
default: '/opt/json/'
case-version:
description: 'The version of the ontology against which the graph should be validated. Options: "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.3.0"'
description: 'The version of the ontology against which the graph should be validated. Options: "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.3.0", "case-1.4.0"'
required: false
default: 'case-1.3.0'
default: 'case-1.4.0'
extension-filter:
description: '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`.'
required: false
Expand All @@ -39,7 +39,7 @@ inputs:
default: ''
runs:
using: 'docker'
image: 'docker://kchason/case-validator:1.5.0'
image: 'docker://kchason/case-validator:1.6.0'
env:
CASE_PATH: ${{ inputs.case-path }}
CASE_VERSION: ${{ inputs.case-version }}
Expand Down