diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0c31cdb99ff..bf9d67755da 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,3 +3,10 @@ repos: rev: "v2.7.1" hooks: - id: prettier + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.21.0 + hooks: + - id: check-jsonschema + # match meta.ymls in one of the subdirectories of modules/nf-core + files: ^modules/nf-core/.*/meta\.yml$ + args: ["--schemafile", "yaml-schema.json"] diff --git a/yaml-schema.json b/yaml-schema.json new file mode 100644 index 00000000000..350ad1bcb4f --- /dev/null +++ b/yaml-schema.json @@ -0,0 +1,146 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "title": "Meta yaml", + "description": "Validate the meta yaml file for an nf-core module", + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Name of the module" + }, + "description": { + "type": "string", + "description": "Description of the module" + }, + "keywords": { + "type": "array", + "description": "Keywords for the module", + "items": { + "type": "string" + }, + "minItems": 3 + }, + "authors": { + "type": "array", + "description": "Authors of the module", + "items": { + "type": "string" + } + }, + "input": { + "type": "array", + "description": "Input channels for the module", + + "items": { + "type": "object", + "patternProperties": { + ".*": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "Type of the input channel", + "enum": ["map", "file", "directory", "string", "integer", "float"] + }, + "description": { + "type": "string", + "description": "Description of the input channel" + }, + "pattern": { + "type": "string", + "description": "Pattern of the input channel, given in Java glob syntax" + }, + "default": { + "type": ["string", "number", "boolean", "array", "object"], + "description": "Default value for the input channel" + } + }, + "required": ["type", "description"] + } + } + } + }, + "output": { + "type": "array", + "description": "Output channels for the module", + "items": { + "type": "object", + "patternProperties": { + ".*": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "Type of the output channel", + "enum": ["map", "file", "directory", "string", "integer", "float"] + }, + "description": { + "type": "string", + "description": "Description of the output channel" + }, + "pattern": { + "type": "string", + "description": "Pattern of the input channel, given in Java glob syntax" + } + }, + "required": ["type", "description"] + } + } + } + }, + "tools": { + "type": "array", + "description": "Tools used by the module", + "items": { + "type": "object", + "patternProperties": { + ".*": { + "type": "object", + "properties": { + "description": { + "type": "string", + "description": "Description of the output channel" + }, + "homepage": { + "type": "string", + "description": "Homepage of the tool", + "pattern": "^(http|https)://.*$" + }, + "documentation": { + "type": "string", + "description": "Documentation of the tool", + "pattern": "^(http|https)://.*$" + }, + "tool_dev_url": { + "type": "string", + "description": "URL of the development version of the tool's documentation", + "pattern": "^(http|https)://.*$" + }, + "doi": { + "type": "string", + "description": "DOI of the tool", + "pattern": "^10.\\d{4,9}\\/[^,]+$" + }, + "licence": { + "type": ["array", "string"], + "description": "Licence of the tool", + "items": { + "type": "string" + }, + "uniqueItems": true + } + }, + "required": ["description"], + "anyOf": [ + { "required": ["homepage"] }, + { "required": ["documentation"] }, + { "required": ["tool_dev_url"] }, + { "required": ["doi"] } + ] + } + } + } + } + }, + "required": ["name", "description", "keywords", "authors", "output", "tools"] +}