From f6676c435556af006254521be1f3a79b2da40f82 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Sun, 4 Jul 2021 18:09:41 +0900 Subject: [PATCH] spec: Add JSON Schemas for foundry IPC messages To make foundry more flexible and scalable, the next release will implement a messaging-based IPC approach using JSON objects. This commit adds JSON schemas for all message types that will be used by foundry. --- spec/build.json | 73 ++++++++++++++++++++++++++++++++++++++++++ spec/buildrequest.json | 36 +++++++++++++++++++++ spec/commit.json | 36 +++++++++++++++++++++ spec/dist.json | 51 +++++++++++++++++++++++++++++ spec/distrequest.json | 45 ++++++++++++++++++++++++++ spec/merge.json | 47 +++++++++++++++++++++++++++ spec/mergerequest.json | 35 ++++++++++++++++++++ spec/sign.json | 51 +++++++++++++++++++++++++++++ spec/signrequest.json | 50 +++++++++++++++++++++++++++++ spec/test.json | 51 +++++++++++++++++++++++++++++ spec/testrequest.json | 36 +++++++++++++++++++++ 11 files changed, 511 insertions(+) create mode 100644 spec/build.json create mode 100644 spec/buildrequest.json create mode 100644 spec/commit.json create mode 100644 spec/dist.json create mode 100644 spec/distrequest.json create mode 100644 spec/merge.json create mode 100644 spec/mergerequest.json create mode 100644 spec/sign.json create mode 100644 spec/signrequest.json create mode 100644 spec/test.json create mode 100644 spec/testrequest.json diff --git a/spec/build.json b/spec/build.json new file mode 100644 index 0000000..bcbb1c7 --- /dev/null +++ b/spec/build.json @@ -0,0 +1,73 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://m10k.eu/foundry/build.json", + "title": "Foundry Build Notification", + "type": "object", + + "properties": { + "tid": { + "description": "Unique identifier of this transaction", + "type": "string" + }, + + "repository": { + "description": "The repository that sources were taken from", + "type": "string", + "pattern": "^(https|file)://.*$" + }, + + "branch": { + "description": "The branch that the sources were taken from", + "type": "string" + }, + + "commit": { + "description": "The commit that uniquely identifies the built sources", + "type": "string", + "pattern": "^[0-9a-fA-F]+$" + }, + + "artifacts": { + "description": "The files resulting from the build", + "type": "array", + "items": { + "type": "#/$defs/artifact" + }, + "minItems": 1 + }, + + "logs": { + "description": "Logfiles from the build", + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1 + } + }, + + "required": [ + "repository", + "branch", + "commit", + "artifacts", + "logs" + ], + + "$defs": { + "artifact": { + "type": "object", + "properties": { + "uri": { + "description": "URI of the artifact", + "type": "string" + }, + "checksum": { + "description": "Hex-encoded sha512 checksum of the artifact", + "type": "string", + "pattern": "^[0-9a-fA-F]{128}$" + } + } + } + } +} diff --git a/spec/buildrequest.json b/spec/buildrequest.json new file mode 100644 index 0000000..b0b2c01 --- /dev/null +++ b/spec/buildrequest.json @@ -0,0 +1,36 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://m10k.eu/foundry/msg.buildrequest.json", + "title": "Foundry BuildRequest Message", + "type": "object", + + "properties": { + "tid": { + "description": "Unique identifier of this transaction", + "type": "string" + }, + + "repository": { + "description": "URL of the repository where the code to be built is located", + "type": "string" + }, + + "branch": { + "description": "Name of the branch that contains the commit to be built", + "type": "string" + }, + + "commit": { + "description": "Commit that is to be built", + "type": "string", + "pattern": "^[0-9a-fA-F]+$" + } + }, + + "required": [ + "tid", + "repository", + "branch", + "commit" + ] +} diff --git a/spec/commit.json b/spec/commit.json new file mode 100644 index 0000000..19acebb --- /dev/null +++ b/spec/commit.json @@ -0,0 +1,36 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://m10k.eu/foundry/commit.json", + "title": "Foundry Commit Notification", + "type": "object", + + "properties": { + "repository": { + "description": "The URL of the repository the commit was detected at", + "type": "string", + "pattern": "^(https|file)://.*$" + }, + + "branch": { + "description": "The name of the branch the commit was detected on", + "type": "string" + }, + + "commit": { + "description": "The hash of the detected commit", + "type": "string", + "pattern": "^[0-9a-fA-F]+$" + }, + + "timestamp": { + "description": "The unix timestamp of the time the change was detected", + "type": "integer" + } + }, + + "required": [ + "repository", + "commit", + "branch" + ] +} diff --git a/spec/dist.json b/spec/dist.json new file mode 100644 index 0000000..fd53957 --- /dev/null +++ b/spec/dist.json @@ -0,0 +1,51 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://m10k.eu/foundry/msg.dist.json", + "title": "Foundry Dist Notification", + "type": "object", + + "properties": { + "tid": { + "description": "Unique identifier of this transaction", + "type": "string" + }, + + "artifacts": { + "description": "Artifacts that were published", + "type": "array", + "items": { + "type": "#/$defs/artifact" + } + "minItems": 1 + }, + + "repository": { + "description": "The repository where the artifacts were published", + "type": "string" + } + }, + + "required": [ + "tid", + "artifacts", + "repository" + ], + + "$defs": { + "artifact": { + "type": "object", + "properties": { + "uri": { + "description": "URI of the artifact", + "type": "string" + }, + + "checksum": { + "description": "hex-encoded sha512 hash of the artifact", + "type": "string", + "pattern": "^[0-9a-fA-F]{128}$" + } + } + } + } +} diff --git a/spec/distrequest.json b/spec/distrequest.json new file mode 100644 index 0000000..7013a0e --- /dev/null +++ b/spec/distrequest.json @@ -0,0 +1,45 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://m10k.eu/foundry/msg.distrequest.json", + "title": "Foundry DistRequest Message", + "type": "object", + + "properties": { + "tid": { + "description": "Unique identifier of this transaction", + "type": "string" + }, + + "repository": { + "description": "URL of the source tree the artifacts were built from", + "type": "string" + }, + + "branch": { + "description": "Name of the branch the artifacts were built from", + "type": "string" + }, + + "commit": { + "description": "Commit the artifacts were built from", + "type": "string" + }, + + "artifacts": { + "description": "List of artifacts built from the source tree", + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1 + } + }, + + "required": [ + "tid", + "repository", + "branch", + "commit", + "artifacts" + ] +} diff --git a/spec/merge.json b/spec/merge.json new file mode 100644 index 0000000..5f9b67e --- /dev/null +++ b/spec/merge.json @@ -0,0 +1,47 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://m10k.eu/foundry/msg.merge.json", + "title": "Foundry Merge Notification", + "type": "object", + + "properties": { + "tid": { + "description": "Unique identifier of this transaction", + "type": "string" + }, + + "repository": { + "description": "URL of the repository where the merge was done", + "type": "string" + }, + + "source-branch": { + "description": "Name of the branch that was merged", + "type": "string" + }, + + "destination-branch": { + "description": "Name of the branch that was merged into", + "type": "string" + }, + + "status": { + "description": "Indicates merge success (zero) or failure (non-zero)", + "type": "integer" + }, + + "log": { + "description": "URI of the merge log", + "type": "string" + } + }, + + "required": [ + "tid", + "repository", + "source-branch", + "destination-branch", + "status", + "log" + ] +} diff --git a/spec/mergerequest.json b/spec/mergerequest.json new file mode 100644 index 0000000..378e070 --- /dev/null +++ b/spec/mergerequest.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://m10k.eu/foundry/msg.mergerequest.json", + "title": "Foundry MergeRequst Message", + "type": "object", + + "properties": { + "tid": { + "description": "Unique identifier of this transaction", + "type": "string" + }, + + "repository": { + "description": "URL of the repository containing the code to be tested", + "type": "string" + }, + + "source-branch": { + "description": "Name of the source for the merge operation", + "type": "string" + }, + + "destination-branch": { + "description": "Name of the destination for the merge operation", + "type": "string" + } + }, + + "required": [ + "tid", + "repository", + "source-branch", + "destination-branch" + ] +} diff --git a/spec/sign.json b/spec/sign.json new file mode 100644 index 0000000..b141280 --- /dev/null +++ b/spec/sign.json @@ -0,0 +1,51 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://m10k.eu/foundry/msg.sign.json", + "title": "Foundry Sign Notification", + "type": "object", + + "properties": { + "tid": { + "description": "Unique identifier of this transaction", + "type": "string" + }, + + "artifacts": { + "description": "The files that have been signed", + "type": "array", + "items": { + "type": "#/$defs/artifact" + }, + "minItems": 1 + }, + + "key": { + "description": "The key that was used for signing", + "type": "string" + } + }, + + "required": [ + "tid", + "artifacts", + "key" + ], + + "$defs": { + "artifact": { + "type": "object", + "properties": { + "uri": { + "description": "URI of the artifact", + "type": "string" + }, + + "checksum": { + "description": "hex-encoded sha512 hash of the artifact", + "type": "string", + "pattern": "^[0-9a-fA-F]{128}$" + } + } + } + } +} diff --git a/spec/signrequest.json b/spec/signrequest.json new file mode 100644 index 0000000..440218a --- /dev/null +++ b/spec/signrequest.json @@ -0,0 +1,50 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://m10k.eu/foundry/msg.signrequest.json", + "title": "Foundry SignRequest Message", + "type": "object", + + "properties": { + "tid": { + "description": "Unique identifier of this transaction", + "type": "string" + }, + + "artifacts": { + "description": "The artifacts to be signed", + "type": "array", + "items": { + "type": "#/$defs/artifact" + }, + "minItems": 1 + } + }, + + "required": [ + "tid", + "artifacts" + ], + + "$defs": { + "artifact": { + "type": "object", + + "properties": { + "uri": { + "description": "URI of the artifact", + "type": "string" + }, + "checksum": { + "description": "hex-encoded sha512 checksum of the artifact", + "type": "string", + "pattern": "^[0-9a-fA-F]{128}$" + } + }, + + "required": [ + "uri", + "checksum" + } + } + } +} diff --git a/spec/test.json b/spec/test.json new file mode 100644 index 0000000..d6ad14e --- /dev/null +++ b/spec/test.json @@ -0,0 +1,51 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://m10k.eu/foundry/msg.test.json", + "title": "Foundry Test Notification", + "type": "object", + + "properties": { + "tid": { + "description": "Unique identifier of this transaction", + "type": "string" + }, + + "repository": { + "description": "URL of the source tree that was tested", + "type": "string" + }, + + "branch": { + "description": "Name of the branch that was tested", + "type": "string" + }, + + "commit": { + "description": "The commit that was tested", + "type": "string" + }, + + "result": { + "description": "Result of the test (zero = success, non-zero = failure)", + "type": "integer" + }, + + "logs": { + "description": "Log files generated during the test", + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1 + } + }, + + "required": [ + "tid", + "repository", + "branch", + "commit", + "result", + "logs" + ] +} diff --git a/spec/testrequest.json b/spec/testrequest.json new file mode 100644 index 0000000..88a2a3a --- /dev/null +++ b/spec/testrequest.json @@ -0,0 +1,36 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://m10k.eu/foundry/msg.testrequest.json", + "title": "Foundry TestRequest Message", + "type": "object", + + "properties": { + "tid": { + "description": "Unique identifier of this transaction", + "type": "string" + }, + + "repository": { + "description": "URL of the repository containing the code to be tested", + "type": "string" + }, + + "branch": { + "description": "Name of the branch containing the commit to be tested", + "type": "string" + }, + + "commit": { + "description": "Commit that is to be tested", + "type": "string", + "pattern": "^[0-9a-fA-F]+$" + } + }, + + "required": [ + "tid", + "repository", + "branch", + "commit" + ] +} -- 2.47.3