From 453b6e79b10b52e55ebcc06af08ff29acc71623a Mon Sep 17 00:00:00 2001 From: Andrea Frittoli Date: Tue, 21 Mar 2023 14:35:09 +0000 Subject: [PATCH] Add example files for all events Add example files for all events. Add a CI job that checks all examples against the schemas. Signed-off-by: Andrea Frittoli --- .github/workflows/main.yml | 20 +++++- README.md | 5 +- examples/artifact_packaged.json | 20 ++++++ examples/artifact_published.json | 15 +++++ examples/branch_created.json | 20 ++++++ examples/branch_deleted.json | 20 ++++++ examples/build_finished.json | 17 +++++ examples/build_queued.json | 15 +++++ examples/build_started.json | 15 +++++ examples/change_abandoned.json | 20 ++++++ examples/change_created.json | 20 ++++++ examples/change_merged.json | 20 ++++++ examples/change_reviewed.json | 20 ++++++ examples/change_updated.json | 20 ++++++ examples/environment_created.json | 18 ++++++ examples/environment_deleted.json | 17 +++++ examples/environment_modified.json | 18 ++++++ ...ntdetected.json => incident_detected.json} | 0 ...ntreported.json => incident_reported.json} | 0 ...ntresolved.json => incident_resolved.json} | 0 examples/pipelinerun_finished.json | 20 ++++++ examples/pipelinerun_queued.json | 18 ++++++ examples/pipelinerun_started.json | 18 ++++++ examples/repository_created.json | 20 ++++++ examples/repository_deleted.json | 20 ++++++ examples/repository_modified.json | 20 ++++++ examples/service_deployed.json | 20 ++++++ examples/service_published.json | 19 ++++++ examples/service_removed.json | 19 ++++++ examples/service_rolledback.json | 20 ++++++ examples/service_upgraded.json | 20 ++++++ examples/taskrun_finished.json | 23 +++++++ examples/taskrun_started.json | 21 +++++++ examples/testcase_finished.json | 15 +++++ examples/testcase_queued.json | 15 +++++ examples/testcase_started.json | 15 +++++ examples/testsuite_finished.json | 15 +++++ examples/testsuite_started.json | 15 +++++ tools/verify-examples.sh | 63 +++++++++++++++++++ 39 files changed, 693 insertions(+), 3 deletions(-) create mode 100644 examples/artifact_packaged.json create mode 100644 examples/artifact_published.json create mode 100644 examples/branch_created.json create mode 100644 examples/branch_deleted.json create mode 100644 examples/build_finished.json create mode 100644 examples/build_queued.json create mode 100644 examples/build_started.json create mode 100644 examples/change_abandoned.json create mode 100644 examples/change_created.json create mode 100644 examples/change_merged.json create mode 100644 examples/change_reviewed.json create mode 100644 examples/change_updated.json create mode 100644 examples/environment_created.json create mode 100644 examples/environment_deleted.json create mode 100644 examples/environment_modified.json rename examples/{incidentdetected.json => incident_detected.json} (100%) rename examples/{incidentreported.json => incident_reported.json} (100%) rename examples/{incidentresolved.json => incident_resolved.json} (100%) create mode 100644 examples/pipelinerun_finished.json create mode 100644 examples/pipelinerun_queued.json create mode 100644 examples/pipelinerun_started.json create mode 100644 examples/repository_created.json create mode 100644 examples/repository_deleted.json create mode 100644 examples/repository_modified.json create mode 100644 examples/service_deployed.json create mode 100644 examples/service_published.json create mode 100644 examples/service_removed.json create mode 100644 examples/service_rolledback.json create mode 100644 examples/service_upgraded.json create mode 100644 examples/taskrun_finished.json create mode 100644 examples/taskrun_started.json create mode 100644 examples/testcase_finished.json create mode 100644 examples/testcase_queued.json create mode 100644 examples/testcase_started.json create mode 100644 examples/testsuite_finished.json create mode 100644 examples/testsuite_started.json create mode 100755 tools/verify-examples.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0892b231..3949613b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,13 +10,13 @@ on: # Set the Job # ############### jobs: - build: + lint: name: Lint Code Base runs-on: ubuntu-latest steps: - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Full git history is needed to get a proper list of changed files within `super-linter` fetch-depth: 0 @@ -31,3 +31,19 @@ jobs: DEFAULT_BRANCH: main GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VALIDATE_MARKDOWN: true + + jsonschema: + name: Validate examples + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + + - name: Validate Examples + run: ./tools/verify-examples.sh diff --git a/README.md b/README.md index 853c960c..0e044521 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,10 @@ Handling Events associated with the health of the services deployed and running Defining how CDEvents are mapped to CloudEvents for transportation and delivery +### [Schemas](./schemas/) and [Examples](./examples/) + +The [schemas](./schemas/) folder contains `jsonschemas` for all events in the spec. The [examples](./examples/) contains simple `JSON` examples for all events. + ## CDEvents SDKs CDEvents is developing as set of SDKs: @@ -94,7 +98,6 @@ CDEvents is developing as set of SDKs: * [Python](https://github.com/cdevents/sdk-python) * [Java](https://github.com/cdevents/sdk-java) - ## Community ### How to get involved diff --git a/examples/artifact_packaged.json b/examples/artifact_packaged.json new file mode 100644 index 00000000..94c548af --- /dev/null +++ b/examples/artifact_packaged.json @@ -0,0 +1,20 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.artifact.packaged.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "pkg:golang/mygit.com/myorg/myapp@234fd47e07d1004f0aed9c", + "source": "/event/source/123", + "type": "artifact", + "content": { + "change": { + "id": "myChange123", + "source": "my-git.example/an-org/a-repo" + } + } + } +} diff --git a/examples/artifact_published.json b/examples/artifact_published.json new file mode 100644 index 00000000..3bee559a --- /dev/null +++ b/examples/artifact_published.json @@ -0,0 +1,15 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.artifact.published.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "pkg:golang/mygit.com/myorg/myapp@234fd47e07d1004f0aed9c", + "source": "/event/source/123", + "type": "artifact", + "content": {} + } +} diff --git a/examples/branch_created.json b/examples/branch_created.json new file mode 100644 index 00000000..bfc2c892 --- /dev/null +++ b/examples/branch_created.json @@ -0,0 +1,20 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.branch.created.0.1.2", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "branch", + "content": { + "repository": { + "id": "TestRepo/TestOrg", + "source": "https://example.org" + } + } + } +} \ No newline at end of file diff --git a/examples/branch_deleted.json b/examples/branch_deleted.json new file mode 100644 index 00000000..ae817230 --- /dev/null +++ b/examples/branch_deleted.json @@ -0,0 +1,20 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.branch.deleted.0.1.2", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "branch", + "content": { + "repository": { + "id": "TestRepo/TestOrg", + "source": "https://example.org" + } + } + } +} \ No newline at end of file diff --git a/examples/build_finished.json b/examples/build_finished.json new file mode 100644 index 00000000..71a038fa --- /dev/null +++ b/examples/build_finished.json @@ -0,0 +1,17 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.build.finished.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "build", + "content": { + "artifactId": "pkg:oci/myapp@sha256%3A0b31b1c02ff458ad9b7b81cbdf8f028bd54699fa151f221d1e8de6817db93427" + } + } +} diff --git a/examples/build_queued.json b/examples/build_queued.json new file mode 100644 index 00000000..62c49035 --- /dev/null +++ b/examples/build_queued.json @@ -0,0 +1,15 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.build.queued.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "build", + "content": {} + } +} diff --git a/examples/build_started.json b/examples/build_started.json new file mode 100644 index 00000000..aa3b9323 --- /dev/null +++ b/examples/build_started.json @@ -0,0 +1,15 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.build.started.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "build", + "content": {} + } +} diff --git a/examples/change_abandoned.json b/examples/change_abandoned.json new file mode 100644 index 00000000..8a7f63d2 --- /dev/null +++ b/examples/change_abandoned.json @@ -0,0 +1,20 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.change.abandoned.0.1.2", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "change", + "content": { + "repository": { + "id": "TestRepo/TestOrg", + "source": "https://example.org" + } + } + } +} \ No newline at end of file diff --git a/examples/change_created.json b/examples/change_created.json new file mode 100644 index 00000000..c89731f0 --- /dev/null +++ b/examples/change_created.json @@ -0,0 +1,20 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.change.created.0.1.2", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "change", + "content": { + "repository": { + "id": "TestRepo/TestOrg", + "source": "https://example.org" + } + } + } +} \ No newline at end of file diff --git a/examples/change_merged.json b/examples/change_merged.json new file mode 100644 index 00000000..4a788095 --- /dev/null +++ b/examples/change_merged.json @@ -0,0 +1,20 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.change.merged.0.1.2", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "change", + "content": { + "repository": { + "id": "TestRepo/TestOrg", + "source": "https://example.org" + } + } + } +} \ No newline at end of file diff --git a/examples/change_reviewed.json b/examples/change_reviewed.json new file mode 100644 index 00000000..25bd4724 --- /dev/null +++ b/examples/change_reviewed.json @@ -0,0 +1,20 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.change.reviewed.0.1.2", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "change", + "content": { + "repository": { + "id": "TestRepo/TestOrg", + "source": "https://example.org" + } + } + } +} \ No newline at end of file diff --git a/examples/change_updated.json b/examples/change_updated.json new file mode 100644 index 00000000..5995c888 --- /dev/null +++ b/examples/change_updated.json @@ -0,0 +1,20 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.change.updated.0.1.2", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "change", + "content": { + "repository": { + "id": "TestRepo/TestOrg", + "source": "https://example.org" + } + } + } +} \ No newline at end of file diff --git a/examples/environment_created.json b/examples/environment_created.json new file mode 100644 index 00000000..fba767ff --- /dev/null +++ b/examples/environment_created.json @@ -0,0 +1,18 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.environment.created.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "environment", + "content": { + "name": "testEnv", + "url": "https://example.org/testEnv" + } + } +} diff --git a/examples/environment_deleted.json b/examples/environment_deleted.json new file mode 100644 index 00000000..220117a1 --- /dev/null +++ b/examples/environment_deleted.json @@ -0,0 +1,17 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.environment.deleted.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "environment", + "content": { + "name": "testEnv" + } + } +} diff --git a/examples/environment_modified.json b/examples/environment_modified.json new file mode 100644 index 00000000..5107bb83 --- /dev/null +++ b/examples/environment_modified.json @@ -0,0 +1,18 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.environment.modified.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "environment", + "content": { + "name": "testEnv", + "url": "https://example.org/testEnv" + } + } +} diff --git a/examples/incidentdetected.json b/examples/incident_detected.json similarity index 100% rename from examples/incidentdetected.json rename to examples/incident_detected.json diff --git a/examples/incidentreported.json b/examples/incident_reported.json similarity index 100% rename from examples/incidentreported.json rename to examples/incident_reported.json diff --git a/examples/incidentresolved.json b/examples/incident_resolved.json similarity index 100% rename from examples/incidentresolved.json rename to examples/incident_resolved.json diff --git a/examples/pipelinerun_finished.json b/examples/pipelinerun_finished.json new file mode 100644 index 00000000..0f56115b --- /dev/null +++ b/examples/pipelinerun_finished.json @@ -0,0 +1,20 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.pipelinerun.finished.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "pipelineRun", + "content": { + "pipelineName": "myPipeline", + "url": "https://www.example.com/mySubject123", + "outcome": "failure", + "errors": "Something went wrong\nWith some more details" + } + } +} diff --git a/examples/pipelinerun_queued.json b/examples/pipelinerun_queued.json new file mode 100644 index 00000000..7cfd79bc --- /dev/null +++ b/examples/pipelinerun_queued.json @@ -0,0 +1,18 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.pipelinerun.queued.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "pipelineRun", + "content": { + "pipelineName": "myPipeline", + "url": "https://www.example.com/mySubject123" + } + } +} diff --git a/examples/pipelinerun_started.json b/examples/pipelinerun_started.json new file mode 100644 index 00000000..9d903497 --- /dev/null +++ b/examples/pipelinerun_started.json @@ -0,0 +1,18 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.pipelinerun.started.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "pipelineRun", + "content": { + "pipelineName": "myPipeline", + "url": "https://www.example.com/mySubject123" + } + } +} diff --git a/examples/repository_created.json b/examples/repository_created.json new file mode 100644 index 00000000..a3e698f7 --- /dev/null +++ b/examples/repository_created.json @@ -0,0 +1,20 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.repository.created.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "repository", + "content": { + "name": "TestRepo", + "owner": "TestOrg", + "url": "https://example.org/TestOrg/TestRepo", + "viewUrl": "https://example.org/view/TestOrg/TestRepo" + } + } +} diff --git a/examples/repository_deleted.json b/examples/repository_deleted.json new file mode 100644 index 00000000..49bac54b --- /dev/null +++ b/examples/repository_deleted.json @@ -0,0 +1,20 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.repository.deleted.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "repository", + "content": { + "name": "TestRepo", + "owner": "TestOrg", + "url": "https://example.org/TestOrg/TestRepo", + "viewUrl": "https://example.org/view/TestOrg/TestRepo" + } + } +} diff --git a/examples/repository_modified.json b/examples/repository_modified.json new file mode 100644 index 00000000..2213372f --- /dev/null +++ b/examples/repository_modified.json @@ -0,0 +1,20 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.repository.modified.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "repository", + "content": { + "name": "TestRepo", + "owner": "TestOrg", + "url": "https://example.org/TestOrg/TestRepo", + "viewUrl": "https://example.org/view/TestOrg/TestRepo" + } + } +} diff --git a/examples/service_deployed.json b/examples/service_deployed.json new file mode 100644 index 00000000..d5a179c1 --- /dev/null +++ b/examples/service_deployed.json @@ -0,0 +1,20 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.service.deployed.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "service", + "content": { + "environment": { + "id": "test123" + }, + "artifactId": "pkg:oci/myapp@sha256%3A0b31b1c02ff458ad9b7b81cbdf8f028bd54699fa151f221d1e8de6817db93427" + } + } +} diff --git a/examples/service_published.json b/examples/service_published.json new file mode 100644 index 00000000..4a49233c --- /dev/null +++ b/examples/service_published.json @@ -0,0 +1,19 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.service.published.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "service", + "content": { + "environment": { + "id": "test123" + } + } + } +} diff --git a/examples/service_removed.json b/examples/service_removed.json new file mode 100644 index 00000000..5c66a0f6 --- /dev/null +++ b/examples/service_removed.json @@ -0,0 +1,19 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.service.removed.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "service", + "content": { + "environment": { + "id": "test123" + } + } + } +} diff --git a/examples/service_rolledback.json b/examples/service_rolledback.json new file mode 100644 index 00000000..8f1880a5 --- /dev/null +++ b/examples/service_rolledback.json @@ -0,0 +1,20 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.service.rolledback.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "service", + "content": { + "environment": { + "id": "test123" + }, + "artifactId": "pkg:oci/myapp@sha256%3A0b31b1c02ff458ad9b7b81cbdf8f028bd54699fa151f221d1e8de6817db93427" + } + } +} diff --git a/examples/service_upgraded.json b/examples/service_upgraded.json new file mode 100644 index 00000000..f8389743 --- /dev/null +++ b/examples/service_upgraded.json @@ -0,0 +1,20 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.service.upgraded.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "service", + "content": { + "environment": { + "id": "test123" + }, + "artifactId": "pkg:oci/myapp@sha256%3A0b31b1c02ff458ad9b7b81cbdf8f028bd54699fa151f221d1e8de6817db93427" + } + } +} diff --git a/examples/taskrun_finished.json b/examples/taskrun_finished.json new file mode 100644 index 00000000..8f553b40 --- /dev/null +++ b/examples/taskrun_finished.json @@ -0,0 +1,23 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.taskrun.finished.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "taskRun", + "content": { + "taskName": "myTask", + "url": "https://www.example.com/mySubject123", + "pipelineRun": { + "id": "mySubject123" + }, + "outcome": "failure", + "errors": "Something went wrong\nWith some more details" + } + } +} diff --git a/examples/taskrun_started.json b/examples/taskrun_started.json new file mode 100644 index 00000000..61842e08 --- /dev/null +++ b/examples/taskrun_started.json @@ -0,0 +1,21 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.taskrun.started.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "taskRun", + "content": { + "taskName": "myTask", + "url": "https://www.example.com/mySubject123", + "pipelineRun": { + "id": "mySubject123" + } + } + } +} diff --git a/examples/testcase_finished.json b/examples/testcase_finished.json new file mode 100644 index 00000000..373b4694 --- /dev/null +++ b/examples/testcase_finished.json @@ -0,0 +1,15 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.testcase.finished.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "testCase", + "content": {} + } +} diff --git a/examples/testcase_queued.json b/examples/testcase_queued.json new file mode 100644 index 00000000..b4bca40f --- /dev/null +++ b/examples/testcase_queued.json @@ -0,0 +1,15 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.testcase.queued.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "testCase", + "content": {} + } +} diff --git a/examples/testcase_started.json b/examples/testcase_started.json new file mode 100644 index 00000000..2ffa1dc4 --- /dev/null +++ b/examples/testcase_started.json @@ -0,0 +1,15 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.testcase.started.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "testCase", + "content": {} + } +} diff --git a/examples/testsuite_finished.json b/examples/testsuite_finished.json new file mode 100644 index 00000000..ac74f6a2 --- /dev/null +++ b/examples/testsuite_finished.json @@ -0,0 +1,15 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.testsuite.finished.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "testSuite", + "content": {} + } +} diff --git a/examples/testsuite_started.json b/examples/testsuite_started.json new file mode 100644 index 00000000..8cd8b920 --- /dev/null +++ b/examples/testsuite_started.json @@ -0,0 +1,15 @@ +{ + "context": { + "version": "0.2.0", + "id": "271069a8-fc18-44f1-b38f-9d70a1695819", + "source": "/event/source/123", + "type": "dev.cdevents.testsuite.started.0.1.1", + "timestamp": "2023-03-20T14:27:05.315384Z" + }, + "subject": { + "id": "mySubject123", + "source": "/event/source/123", + "type": "testSuite", + "content": {} + } +} diff --git a/tools/verify-examples.sh b/tools/verify-examples.sh new file mode 100755 index 00000000..d7735363 --- /dev/null +++ b/tools/verify-examples.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +# Copyright 2023 The CDEvents Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +function usage() { + cat < $SUBJECT $PREDICATE" + yajsv -s "$SCHEMA_FILE" "$EXAMPLE_FILE" || num_failed=$(( num_failed + 1 )) + echo +done + +if [ $num_failed -gt 0 ]; then + echo "${num_failed} out of ${num_examples} examples failed validation" +fi +exit $num_failed \ No newline at end of file