-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: jargon artifacts validation pipeline (#304)
- Loading branch information
1 parent
d9c62fa
commit e7a19ed
Showing
11 changed files
with
775 additions
and
0 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,4 @@ | ||
node_modules | ||
action.yml | ||
Dockerfile | ||
README.md |
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,9 @@ | ||
FROM node:21-alpine | ||
|
||
COPY package*.json / | ||
|
||
RUN npm ci | ||
|
||
COPY src /src | ||
|
||
CMD ["node", "/src/index.js"] |
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,79 @@ | ||
# Validate Jargon Artefacts GitHub Action | ||
|
||
This custom GitHub Action automates the validation of Jargon-generated UNTP artifacts, including JSON-LD contexts, schemas, and sample credentials. It ensures that the generated artifacts comply with the appropriate specifications before release. | ||
|
||
## Features | ||
- **Automated Validation**: Checks JSON-LD contexts, schemas, and sample credentials. | ||
- **Webhook Integration**: Triggers validation upon receiving Jargon snapshot events. | ||
- **Dockerized Execution**: Runs in an isolated container environment. | ||
- **GitHub Actions Support**: Easily integrates into GitHub workflows. | ||
- **Validation Reporting**: Outputs validation results for further processing. | ||
|
||
## Installation | ||
This GitHub Action is designed to be used within a workflow in the [`spec-untp`](https://github.com/uncefact/spec-untp) repository. | ||
|
||
## Usage | ||
To use this action in your GitHub workflow, add the following YAML configuration to your `.github/workflows/validate.yml` file: | ||
|
||
```yaml | ||
name: Validate Jargon Artefacts | ||
|
||
on: | ||
repository_dispatch: | ||
types: [jargon_onSnapshot] | ||
|
||
jobs: | ||
validate-jargon-artefacts: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Run Validate Jargon Artefacts | ||
id: validate | ||
uses: ./.github/actions/validate-jargon-artefacts | ||
with: | ||
jargon-webhook-payload: ${{ toJSON(github.event.client_payload) }} | ||
|
||
- name: Show Validation Result | ||
run: | | ||
echo "Jarogn Artefacts Validation Result: ${{ steps.validate.outputs.validation-result }}" | ||
``` | ||
## Inputs | ||
| Name | Description | Required | | ||
|------|-------------|----------| | ||
| `jargon-webhook-payload` | The JSON payload from the Jargon webhook | Yes | | ||
|
||
## Outputs | ||
| Name | Description | | ||
|------|-------------| | ||
| `validation-result` | The validation result of the artifacts | | ||
|
||
## Implementation Details | ||
- **Docker-based execution**: The action runs inside a Docker container using `node:21-alpine`. | ||
- **Validation Scripts**: | ||
- `schemaValidation.js`: Validates sample credentials against their schema and the context used in the sample credentials. | ||
- `contextValidation.js`: Validates JSON-LD context files. | ||
- **Error Handling**: If validation fails, the action sets the workflow as failed. | ||
|
||
## Development | ||
|
||
### Running Locally | ||
To test this action locally, clone the repository and run: | ||
|
||
```sh | ||
# Build the Docker image | ||
docker build -t validate-jargon-artefacts . | ||
# Run the Docker container | ||
docker run --rm -e INPUT_JARGON-WEBHOOK-PAYLOAD='{"artefacts": {...}}' validate-jargon-artefacts | ||
``` | ||
|
||
### Modifying the Action | ||
|
||
- Update `src/index.js` for core validation logic. | ||
- Update `src/contextValidation.js` and `src/schemaValidation.js` for context and schema validation. | ||
- Update `src/utils.js` for utility functions. | ||
- Update `Dockerfile` for Docker image changes. | ||
- Modify `action.yml` for input/output changes. |
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,13 @@ | ||
name: Validate Jargon Artefacts | ||
description: Validates the Jargon snapshot artefacts. | ||
|
||
inputs: | ||
jargon-webhook-payload: | ||
description: The JSON payload from the Jargon webhook. | ||
required: true | ||
outputs: | ||
validation-result: | ||
description: The validation result. | ||
runs: | ||
using: docker | ||
image: Dockerfile |
Oops, something went wrong.