diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 47deb7621..d38a5315e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: # dogfood - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.31.3 + rev: 0.32.1 hooks: - id: check-dependabot - id: check-github-workflows @@ -28,7 +28,7 @@ repos: hooks: - id: black - repo: https://github.com/PyCQA/flake8 - rev: 7.1.2 + rev: 7.2.0 hooks: - id: flake8 additional_dependencies: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b1d0a1bc1..f499d43f4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,6 +10,15 @@ Unreleased .. vendor-insert-here +0.33.0 +------ + +- Update vendored schemas: bitbucket-pipelines, buildkite, circle-ci, compose-spec, + github-workflows, mergify, renovate, taskfile, woodpecker-ci (2025-04-11) +- A new option, ``--force-filetype``, is now supported and allows users to + explicitly specify which parser should be used for instance files. Thanks + :user:`mschoettle`! (:pr:`557`, :issue:`341`) + 0.32.1 ------ diff --git a/README.md b/README.md index eeda17ea5..b66e70d52 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ files. ```yaml - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-github-workflows args: ["--verbose"] diff --git a/docs/optional_parsers.rst b/docs/optional_parsers.rst index 8d433e297..11eb8a173 100644 --- a/docs/optional_parsers.rst +++ b/docs/optional_parsers.rst @@ -20,7 +20,7 @@ For example, .. code-block:: yaml - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-renovate additional_dependencies: ['pyjson5'] @@ -45,7 +45,7 @@ For example, .. code-block:: yaml - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-jsonschema name: 'Check GitHub Workflows' diff --git a/docs/precommit_usage.rst b/docs/precommit_usage.rst index 22f3e4b15..ee9da81d3 100644 --- a/docs/precommit_usage.rst +++ b/docs/precommit_usage.rst @@ -17,7 +17,7 @@ You must specify a schema using pre-commit ``args`` configuration. :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-jsonschema files: ^data/.*\.json$ @@ -34,7 +34,7 @@ Validate JSON Schema files against their matching metaschema, as specified in th :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-metaschema files: ^schemas/.*\.json$ @@ -52,7 +52,7 @@ Validate Azure Pipelines config against the schema provided by Microsoft :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-azure-pipelines @@ -66,7 +66,7 @@ Validate Bamboo Specs against the schema provided by SchemaStore :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-bamboo-spec @@ -80,7 +80,7 @@ Validate Bitbucket Pipelines against the schema provided by SchemaStore :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-bitbucket-pipelines @@ -94,7 +94,7 @@ Validate Buildkite Pipelines against the schema provided by Buildkite :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-buildkite @@ -108,7 +108,7 @@ Validate CircleCI config against the schema provided by SchemaStore :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-circle-ci @@ -122,7 +122,7 @@ Validate Google Cloud Build config against the schema provided by SchemaStore :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-cloudbuild @@ -136,7 +136,7 @@ Validate Docker Compose files against the schema provided by SchemaStore :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-compose-spec @@ -150,7 +150,7 @@ Validate Dependabot Config (v2) against the schema provided by SchemaStore :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-dependabot @@ -164,7 +164,7 @@ Validate Drone-CI Config against the schema provided by SchemaStore :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-drone-ci @@ -178,7 +178,7 @@ Validate GitHub Actions against the schema provided by SchemaStore :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-github-actions @@ -192,7 +192,7 @@ Validate GitHub Workflows against the schema provided by SchemaStore :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-github-workflows @@ -206,7 +206,7 @@ Validate GitLab CI config against the schema provided by SchemaStore :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-gitlab-ci @@ -220,7 +220,7 @@ Validate Meltano config against the schema provided by Meltano :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-meltano @@ -234,7 +234,7 @@ Validate Mergify config against the schema provided by SchemaStore :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-mergify @@ -248,7 +248,7 @@ Validate ReadTheDocs config against the schema provided by ReadTheDocs :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-readthedocs @@ -262,7 +262,7 @@ Validate Renovate config against the schema provided by Renovate (does not suppo :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-renovate @@ -276,7 +276,7 @@ Validate snapcraft files against the schema provided by Canonical :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-snapcraft @@ -290,7 +290,7 @@ Validate Taskfile config against the schema provided by Task :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-taskfile @@ -304,7 +304,7 @@ Validate Travis Config against the schema provided by SchemaStore :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-travis @@ -318,7 +318,7 @@ Validate Woodpecker Config against the schema provided by SchemaStore :caption: example config - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-woodpecker-ci @@ -344,7 +344,7 @@ manually, you could do this: .. code-block:: yaml - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-jsonschema name: "Check GitHub Workflows" @@ -363,7 +363,7 @@ To check with the builtin schema that a GitHub workflow sets .. code-block:: yaml - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-jsonschema name: "Check GitHub Workflows set timeout-minutes" diff --git a/docs/usage.rst b/docs/usage.rst index 29576eb78..f335dc37e 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -221,6 +221,14 @@ no extension should be treated as YAML. By default, this is not set and files without a detected type of JSON or YAML will fail. +``--force-filetype`` +~~~~~~~~~~~~~~~~~~~~~~ + +Set a filetype to use for instance files instead of detecting types. + +For example, ``--force-filetype json5`` will use the JSON5 parser, even on +files ending in ``.json``. + ``--data-transform`` ~~~~~~~~~~~~~~~~~~~~ diff --git a/pyproject.toml b/pyproject.toml index 85ba2a611..d012ca16f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "check-jsonschema" -version = "0.32.1" +version = "0.33.0" description = "A jsonschema CLI and pre-commit hook" authors = [ { name = "Stephen Rosen", email = "sirosen0@gmail.com" }, @@ -37,8 +37,9 @@ dev = [ "pytest<9", 'click-type-test==1.1.0;python_version>="3.10"', "coverage<8", + "identify>=2.6.9", "pytest-xdist<4", - "responses==0.25.6", + "responses==0.25.7", ] docs = [ "sphinx<9", @@ -72,3 +73,6 @@ filterwarnings = [ # dateutil has a Python 3.12 compatibility issue. 'ignore:datetime\.datetime\.utcfromtimestamp\(\) is deprecated:DeprecationWarning', ] +addopts = [ + "--color=yes", +] diff --git a/src/check_jsonschema/builtin_schemas/vendor/bitbucket-pipelines.json b/src/check_jsonschema/builtin_schemas/vendor/bitbucket-pipelines.json index 8be26b41f..58fdf1435 100644 --- a/src/check_jsonschema/builtin_schemas/vendor/bitbucket-pipelines.json +++ b/src/check_jsonschema/builtin_schemas/vendor/bitbucket-pipelines.json @@ -1,1000 +1 @@ -{ - "$id": "https://bitbucket.org/product/features/pipelines", - "$ref": "#/components/schemas/pipelines_configuration", - "$schema": "http://json-schema.org/draft-07/schema#", - "components": { - "schemas": { - "artifacts": { - "oneOf": [ - { - "$ref": "#/components/schemas/artifacts_paths" - }, - { - "$ref": "#/components/schemas/artifacts_expanded" - } - ] - }, - "artifacts_expanded": { - "properties": { - "download": { - "default": true, - "description": "Enables downloading of all available artifacts at the start of a step.", - "type": "boolean" - }, - "paths": { - "$ref": "#/components/schemas/artifacts_paths" - } - }, - "type": "object" - }, - "artifacts_paths": { - "items": { - "description": "Glob pattern for the path to the artifacts.", - "title": "Artifact Path Pattern", - "type": "string" - }, - "minItems": 1, - "type": "array" - }, - "cache": { - "oneOf": [ - { - "$ref": "#/components/schemas/cache_path" - }, - { - "$ref": "#/components/schemas/cache_expanded" - } - ] - }, - "cache_expanded": { - "properties": { - "key": { - "properties": { - "files": { - "description": "Checksum of these file paths will be used to generate the cache key.", - "items": { - "description": "Path to a file or glob pattern of files in the repository which form the cache key.", - "type": "string" - }, - "minItems": 1, - "type": "array" - } - }, - "required": [ - "files" - ], - "title": "Cache Key", - "type": "object" - }, - "path": { - "$ref": "#/components/schemas/cache_path" - } - }, - "required": [ - "path" - ], - "title": "Cache", - "type": "object" - }, - "cache_path": { - "description": "Path to the directory to be cached, can be absolute or relative to the clone directory.", - "title": "Cache Path", - "type": "string" - }, - "clone": { - "description": "Settings for cloning a repository into a container.", - "properties": { - "depth": { - "default": 50, - "description": "The depth argument of Git clone operation. It can be either number or \"full\" value", - "example": "full", - "oneOf": [ - { - "minimum": 1, - "type": "integer" - }, - { - "enum": [ - "full" - ], - "type": "string" - } - ], - "title": "Git Clone Depth" - }, - "enabled": { - "default": true, - "description": "Enables cloning of the repository.", - "type": "boolean" - }, - "filter": { - "description": "The partial clone filter argument of Git fetch operation. It can be either \"blob:none\" or \"tree:\" value", - "type": "string" - }, - "lfs": { - "default": false, - "description": "Enables the download of files from LFS storage when cloning.", - "type": "boolean" - }, - "skip-ssl-verify": { - "default": false, - "description": "Disables SSL verification during Git clone operation, allowing the use of self-signed certificates.", - "type": "boolean" - }, - "sparse-checkout": { - "description": "When this is provided, the repository will be cloned using sparse checkout using the provided settings.", - "properties": { - "cone-mode": { - "default": true, - "description": "Controls whether to use cone-mode or non-cone-mode.", - "type": "boolean" - }, - "enabled": { - "default": true, - "description": "Enables sparse checkout.", - "type": "boolean" - }, - "patterns": { - "description": "List of patterns to include in sparse checkout. The patterns should be directories or gitignore-style patterns based on the cone-mode settings.", - "items": { - "description": "A directory for cone-mode, or a gitignore-style pattern for no-cone-mode.", - "type": "string" - }, - "type": "array" - } - }, - "title": "Sparse Checkout Settings", - "type": "object" - }, - "strategy": { - "default": "fetch", - "description": "Set the Git clone strategy to use. \"fetch\" is the new default strategy, \"clone\" is the legacy strategy.", - "enum": [ - "clone", - "fetch" - ], - "type": "string" - }, - "tags": { - "default": false, - "description": "Enables fetching tags when cloning.", - "type": "boolean" - } - }, - "title": "Clone Repository Settings", - "type": "object" - }, - "cloud": { - "description": "Custom cloud step runtime", - "properties": { - "atlassian-ip-ranges": { - "default": false, - "description": "Whether it uses Atlassian ip ranges.", - "type": "boolean" - }, - "version": { - "description": "Cloud Runtime version.", - "type": "string" - } - }, - "title": "Cloud step runtime", - "type": "object" - }, - "condition": { - "properties": { - "changesets": { - "description": "Condition on the changesets involved in the pipeline.", - "properties": { - "includePaths": { - "description": "Condition which holds only if any of the modified files match any of the specified patterns.", - "items": { - "description": "Glob pattern to match the file path.", - "title": "File Path Pattern", - "type": "string" - }, - "minItems": 1, - "title": "Include Paths", - "type": "array" - } - }, - "required": [ - "includePaths" - ], - "title": "Changeset Condition", - "type": "object" - } - }, - "required": [ - "changesets" - ], - "type": "object" - }, - "custom_pipeline": { - "oneOf": [ - { - "$ref": "#/components/schemas/items_with_variables" - }, - { - "$ref": "#/components/schemas/import_pipeline" - } - ] - }, - "fail_fast": { - "default": false, - "title": "Fail Fast", - "type": "boolean" - }, - "image": { - "oneOf": [ - { - "$ref": "#/components/schemas/image_no_auth" - }, - { - "$ref": "#/components/schemas/image_basic_auth" - }, - { - "$ref": "#/components/schemas/image_aws_auth" - }, - { - "$ref": "#/components/schemas/image_name" - } - ] - }, - "image_aws_auth": { - "allOf": [ - { - "$ref": "#/components/schemas/image_base" - }, - { - "properties": { - "aws": { - "oneOf": [ - { - "properties": { - "access-key": { - "description": "The access key for Amazon Elastic Container Registry (AWS ECR).", - "title": "AWS Access Key", - "type": "string" - }, - "secret-key": { - "description": "The secret key for Amazon Elastic Container Registry (AWS ECR).", - "title": "AWS Secret Key", - "type": "string" - } - }, - "required": [ - "access-key", - "secret-key" - ], - "type": "object" - }, - { - "properties": { - "oidc-role": { - "description": "OIDC role with access to private Docker images hosted in Amazon Elastic Container Registry (AWS ECR).", - "title": "OpenID Connect Role", - "type": "string" - } - }, - "required": [ - "oidc-role" - ], - "type": "object" - } - ] - } - }, - "required": [ - "aws" - ], - "type": "object" - } - ] - }, - "image_base": { - "description": "The parameters of the Docker image to use when running a step.", - "properties": { - "name": { - "$ref": "#/components/schemas/image_name" - }, - "run-as-user": { - "default": 0, - "description": "The UID of a user in the docker image to run as. Overrides image's default user, specified user UID must be an existing user in the image with a valid home directory.", - "title": "User ID", - "type": "integer" - } - }, - "required": [ - "name" - ], - "title": "Docker Image Configuration", - "type": "object" - }, - "image_basic_auth": { - "allOf": [ - { - "$ref": "#/components/schemas/image_base" - }, - { - "properties": { - "password": { - "description": "The password to use when fetching the Docker image.", - "title": "Docker Registry Password", - "type": "string" - }, - "username": { - "description": "The username to use when fetching the Docker image.", - "title": "Docker Registry Username", - "type": "string" - } - }, - "required": [ - "username", - "password" - ], - "type": "object" - } - ] - }, - "image_name": { - "default": "atlassian/default-image:latest", - "description": "The name of the Docker image which may or may not include registry URL, tag, and digest value.", - "title": "Docker Image Name", - "type": "string" - }, - "image_no_auth": { - "allOf": [ - { - "$ref": "#/components/schemas/image_base" - }, - { - "properties": { - "aws": { - "not": {} - }, - "password": { - "not": {} - }, - "username": { - "not": {} - } - }, - "type": "object" - } - ] - }, - "import_pipeline": { - "additionalProperties": false, - "properties": { - "import": { - "description": "The import needs to match the following format: {repo-slug|repo-uuid}:{tag-name|branch-name}:{pipeline-name}.", - "pattern": "^[^:]+:[^:]+:[^:]+$", - "title": "Identifier of the pipeline configuration to import", - "type": "string" - } - }, - "required": [ - "import" - ], - "type": "object" - }, - "items": { - "description": "List of steps, stages and parallel groups of the pipeline.", - "items": { - "oneOf": [ - { - "$ref": "#/components/schemas/step_item" - }, - { - "$ref": "#/components/schemas/parallel_item" - }, - { - "$ref": "#/components/schemas/stage_item" - } - ] - }, - "minItems": 1, - "title": "Pipeline Items", - "type": "array" - }, - "items_with_variables": { - "description": "List of variables, steps, stages and parallel groups of the custom pipeline.", - "items": { - "oneOf": [ - { - "$ref": "#/components/schemas/variables_item" - }, - { - "$ref": "#/components/schemas/step_item" - }, - { - "$ref": "#/components/schemas/parallel_item" - }, - { - "$ref": "#/components/schemas/stage_item" - } - ] - }, - "minItems": 1, - "title": "Custom Pipeline Items", - "type": "array" - }, - "max_time": { - "default": 120, - "description": "The maximum time a step can execute for in minutes.", - "example": 60, - "exclusiveMinimum": 0, - "type": "integer" - }, - "parallel": { - "oneOf": [ - { - "$ref": "#/components/schemas/parallel_steps" - }, - { - "$ref": "#/components/schemas/parallel_expanded" - } - ] - }, - "parallel_expanded": { - "properties": { - "fail-fast": { - "$ref": "#/components/schemas/fail_fast", - "description": "Stop the whole parallel group in case one of its steps fails." - }, - "steps": { - "$ref": "#/components/schemas/parallel_steps" - } - }, - "required": [ - "steps" - ], - "type": "object" - }, - "parallel_item": { - "additionalProperties": false, - "properties": { - "parallel": { - "$ref": "#/components/schemas/parallel" - } - }, - "type": "object" - }, - "parallel_steps": { - "description": "List of steps in the parallel group to run concurrently.", - "items": { - "$ref": "#/components/schemas/step_item" - }, - "minItems": 1, - "title": "Parallel Group Steps", - "type": "array" - }, - "pipe": { - "description": "The pipe to execute.", - "example": { - "pipe": "atlassian/test-pipe:2.2.0", - "variables": { - "BAZ": [ - "QUX", - "QUZ" - ], - "FOO": "BAR" - } - }, - "properties": { - "pipe": { - "description": "The full pipe identifier.", - "title": "Pipe Identifier", - "type": "string" - }, - "variables": { - "additionalProperties": { - "description": "Environment variable value", - "oneOf": [ - { - "type": "string" - }, - { - "items": { - "type": "string" - }, - "type": "array" - } - ] - }, - "description": "Environment variables passed to the pipe container.", - "title": "Pipe Variables", - "type": "object" - } - }, - "required": [ - "pipe" - ], - "title": "Pipe", - "type": "object" - }, - "pipeline": { - "oneOf": [ - { - "$ref": "#/components/schemas/items" - }, - { - "$ref": "#/components/schemas/import_pipeline" - } - ] - }, - "pipelines_configuration": { - "properties": { - "clone": { - "$ref": "#/components/schemas/clone" - }, - "definitions": { - "description": "The definitions of caches and services used in the declared pipelines.", - "properties": { - "caches": { - "additionalProperties": { - "$ref": "#/components/schemas/cache" - }, - "title": "Custom cache definitions", - "type": "object" - }, - "pipelines": { - "additionalProperties": { - "$ref": "#/components/schemas/custom_pipeline" - }, - "description": "Definitions of the pipelines which can be used in other repositories of the same Bitbucket workspace.", - "title": "Shared pipeline definitions", - "type": "object" - }, - "services": { - "additionalProperties": { - "$ref": "#/components/schemas/service" - }, - "title": "Service definitions", - "type": "object" - } - }, - "title": "Global Definitions", - "type": "object" - }, - "export": { - "default": false, - "description": "Allows other Bitbucket repositories to import pipeline definitions from this file. A shared pipeline definition can't contain another `import` property.", - "title": "Enables shared pipelines definitions.", - "type": "boolean" - }, - "image": { - "$ref": "#/components/schemas/image" - }, - "labels": { - "description": "Additional key value data supplied in the configuration YAML.", - "example": { - "buildTool": "maven", - "jvm": "jdk17" - }, - "title": "Pipeline Labels", - "type": "object" - }, - "options": { - "description": "Global options allow to override the default values applied to all steps in all declared pipelines.", - "properties": { - "docker": { - "default": false, - "description": "Enables Docker service for every step.", - "type": "boolean" - }, - "max-time": { - "$ref": "#/components/schemas/max_time" - }, - "runtime": { - "$ref": "#/components/schemas/runtime" - }, - "size": { - "$ref": "#/components/schemas/size" - } - }, - "title": "Global Options", - "type": "object" - }, - "pipelines": { - "properties": { - "branches": { - "additionalProperties": { - "$ref": "#/components/schemas/pipeline" - }, - "description": "Branch-specific build pipelines.", - "title": "Branch Pipelines", - "type": "object" - }, - "custom": { - "additionalProperties": { - "$ref": "#/components/schemas/custom_pipeline" - }, - "description": "Pipelines that can only be triggered manually or be scheduled.", - "title": "Custom Pipelines", - "type": "object" - }, - "default": { - "$ref": "#/components/schemas/pipeline", - "description": "Default pipeline runs on every push except for tags unless a branch-specific pipeline is defined.", - "title": "Default Pipeline" - }, - "pull-requests": { - "additionalProperties": { - "$ref": "#/components/schemas/pull_requests_pipeline" - }, - "description": "Pull-request-specific build pipelines.", - "title": "Pull Request Pipelines", - "type": "object" - }, - "tags": { - "additionalProperties": { - "$ref": "#/components/schemas/pipeline" - }, - "description": "Tag-specific build pipelines.", - "title": "Tag Pipelines", - "type": "object" - } - }, - "title": "Pipelines", - "type": "object" - } - }, - "type": "object" - }, - "pull_requests_pipeline": { - "oneOf": [ - { - "$ref": "#/components/schemas/items" - }, - { - "properties": { - "destinations": { - "additionalProperties": { - "$ref": "#/components/schemas/pipeline" - }, - "type": "object" - } - }, - "type": "object" - } - ] - }, - "runs_on": { - "oneOf": [ - { - "$ref": "#/components/schemas/runs_on_item" - }, - { - "$ref": "#/components/schemas/runs_on_expanded" - } - ] - }, - "runs_on_expanded": { - "description": "Required labels of a runner to run the step.", - "example": [ - "self.hosted", - "linux" - ], - "items": { - "$ref": "#/components/schemas/runs_on_item" - }, - "maxItems": 10, - "minItems": 1, - "title": "Step Runner Labels", - "type": "array" - }, - "runs_on_item": { - "description": "Label of a runner.", - "maxLength": 50, - "title": "Step Runner Label", - "type": "string" - }, - "runtime": { - "description": "Custom step runtime", - "properties": { - "cloud": { - "$ref": "#/components/schemas/cloud" - } - }, - "title": "Step Runtime", - "type": "object" - }, - "script": { - "items": { - "oneOf": [ - { - "description": "The command to execute.", - "example": "echo \"hello world\"", - "title": "Script Command", - "type": "string" - }, - { - "$ref": "#/components/schemas/pipe" - } - ] - }, - "minItems": 1, - "type": "array" - }, - "service": { - "description": "Custom service properties", - "properties": { - "image": { - "$ref": "#/components/schemas/image" - }, - "memory": { - "default": 1024, - "description": "Memory limit for the service container, in megabytes.", - "minimum": 128, - "title": "Service Memory", - "type": "integer" - }, - "type": { - "description": "Specifies Docker service container (to run Docker-in-Docker).", - "enum": [ - "docker" - ], - "type": "string" - }, - "variables": { - "additionalProperties": { - "description": "Environment variable value", - "title": "Service Variable", - "type": "string" - }, - "description": "Environment variables passed to the service container.", - "minProperties": 1, - "title": "Service Variables", - "type": "object" - } - }, - "title": "Service definition", - "type": "object" - }, - "size": { - "default": "1x", - "description": "The size of the step, sets the amount of resources allocated.", - "enum": [ - "1x", - "2x", - "4x", - "8x", - "16x", - "32x" - ], - "title": "Step Size", - "type": "string" - }, - "stage": { - "properties": { - "condition": { - "$ref": "#/components/schemas/condition", - "description": "The condition to execute the stage.", - "title": "Stage Condition" - }, - "deployment": { - "description": "The deployment environment for the stage.", - "title": "Stage Deployment Environment", - "type": "string" - }, - "name": { - "description": "The name of the stage.", - "title": "Stage Name", - "type": "string" - }, - "steps": { - "description": "List of steps in the stage.", - "items": { - "properties": { - "step": { - "allOf": [ - { - "$ref": "#/components/schemas/step_base" - }, - { - "properties": { - "condition": { - "not": {} - } - }, - "type": "object" - } - ] - } - }, - "type": "object" - }, - "minItems": 1, - "title": "Stage Steps", - "type": "array" - }, - "trigger": { - "$ref": "#/components/schemas/trigger", - "description": "The trigger used for the pipeline stage.", - "title": "Stage Trigger" - } - }, - "required": [ - "steps" - ], - "type": "object" - }, - "stage_item": { - "additionalProperties": false, - "properties": { - "stage": { - "$ref": "#/components/schemas/stage" - } - }, - "type": "object" - }, - "step": { - "allOf": [ - { - "$ref": "#/components/schemas/step_base" - }, - { - "properties": { - "condition": { - "$ref": "#/components/schemas/condition", - "description": "The condition to execute the step.", - "title": "Step Condition" - } - }, - "type": "object" - } - ] - }, - "step_base": { - "properties": { - "after-script": { - "$ref": "#/components/schemas/script", - "description": "List of commands to execute after the step succeeds or fails.", - "title": "Step Post Script" - }, - "artifacts": { - "$ref": "#/components/schemas/artifacts" - }, - "caches": { - "description": "Caches enabled for the step.", - "items": { - "description": "Reference to a cache defined under global definitions.", - "title": "Cache Name", - "type": "string" - }, - "minItems": 1, - "title": "Step Caches", - "type": "array" - }, - "clone": { - "$ref": "#/components/schemas/clone" - }, - "deployment": { - "description": "The deployment environment for the step.", - "title": "Step Deployment Environment", - "type": "string" - }, - "fail-fast": { - "$ref": "#/components/schemas/fail_fast", - "description": "Stop the parent parallel group in case this step fails." - }, - "image": { - "$ref": "#/components/schemas/image" - }, - "max-time": { - "$ref": "#/components/schemas/max_time", - "title": "Step Maximum Time" - }, - "name": { - "description": "The name of the step.", - "example": "Build and test", - "title": "Step Name", - "type": "string" - }, - "oidc": { - "description": "Enables the use of OpenID Connect to connect a pipeline step to a resource server.", - "type": "boolean" - }, - "runs-on": { - "$ref": "#/components/schemas/runs_on" - }, - "runtime": { - "$ref": "#/components/schemas/runtime" - }, - "script": { - "$ref": "#/components/schemas/script", - "description": "List of commands that are executed in sequence.", - "title": "Step Script" - }, - "services": { - "description": "Services enabled for the step.", - "items": { - "description": "Reference to a service defined under global definitions.", - "title": "Service Name", - "type": "string" - }, - "maxItems": 5, - "minItems": 1, - "title": "Step Services", - "type": "array" - }, - "size": { - "$ref": "#/components/schemas/size" - }, - "trigger": { - "$ref": "#/components/schemas/trigger", - "description": "The trigger used for the pipeline step.", - "title": "Step Trigger" - } - }, - "required": [ - "script" - ], - "title": "Pipeline Step", - "type": "object" - }, - "step_item": { - "additionalProperties": false, - "properties": { - "step": { - "$ref": "#/components/schemas/step" - } - }, - "type": "object" - }, - "trigger": { - "default": "automatic", - "enum": [ - "automatic", - "manual" - ], - "type": "string" - }, - "variables_item": { - "additionalProperties": false, - "properties": { - "variables": { - "description": "List of variables for the custom pipeline.", - "items": { - "description": "Settings for the custom variable.", - "properties": { - "allowed-values": { - "description": "A list of values that are allowed for the variable.", - "items": { - "title": "Allowed Variable Value", - "type": "string" - }, - "minItems": 1, - "title": "Allowed Variable Values", - "type": "array" - }, - "default": { - "title": "Default Variable Value", - "type": "string" - }, - "description": { - "title": "Variable Description", - "type": "string" - }, - "name": { - "title": "Variable Name", - "type": "string" - } - }, - "required": [ - "name" - ], - "title": "Custom Pipeline Variable", - "type": "object" - }, - "minItems": 1, - "title": "Custom Pipeline Variables", - "type": "array" - } - }, - "type": "object" - } - } - } -} +{"$id": "https://bitbucket.org/product/features/pipelines", "$ref": "#/components/schemas/pipelines_configuration", "$schema": "http://json-schema.org/draft-07/schema#", "components": {"schemas": {"artifacts": {"oneOf": [{"$ref": "#/components/schemas/artifacts_paths"}, {"$ref": "#/components/schemas/artifacts_expanded"}]}, "artifacts_expanded": {"properties": {"download": {"oneOf": [{"default": true, "description": "Enables downloading of all available artifacts at the end of a step.", "type": "boolean"}, {"description": "Define the list of filtered artifacts to be downloaded by the step.", "items": {"type": "string"}, "minItems": 1, "type": "array"}]}, "paths": {"$ref": "#/components/schemas/artifacts_paths"}, "upload": {"items": {"$ref": "#/components/schemas/artifacts_upload"}, "minItems": 1, "type": "array"}}, "type": "object"}, "artifacts_paths": {"items": {"description": "Glob pattern for the path to the artifacts.", "title": "Artifact Path Pattern", "type": "string"}, "minItems": 1, "type": "array"}, "artifacts_upload": {"description": "The artifact to be uploaded.", "properties": {"depth": {"description": "The depth to search for the artifact files.", "minimum": 1, "title": "Artifact Depth", "type": "integer"}, "name": {"description": "The name of the artifact.", "title": "Artifact Name", "type": "string"}, "paths": {"$ref": "#/components/schemas/artifacts_paths"}, "type": {"default": "shared", "description": "The type of the artifact.", "enum": ["shared"], "title": "Artifact Type", "type": "string"}}, "required": ["name", "paths"], "title": "Artifact Upload object", "type": "object"}, "cache": {"oneOf": [{"$ref": "#/components/schemas/cache_path"}, {"$ref": "#/components/schemas/cache_expanded"}]}, "cache_expanded": {"properties": {"key": {"properties": {"files": {"description": "Checksum of these file paths will be used to generate the cache key.", "items": {"description": "Path to a file or glob pattern of files in the repository which form the cache key.", "type": "string"}, "minItems": 1, "type": "array"}}, "required": ["files"], "title": "Cache Key", "type": "object"}, "path": {"$ref": "#/components/schemas/cache_path"}}, "required": ["path"], "title": "Cache", "type": "object"}, "cache_path": {"description": "Path to the directory to be cached, can be absolute or relative to the clone directory.", "title": "Cache Path", "type": "string"}, "clone": {"description": "Settings for cloning a repository into a container.", "properties": {"depth": {"default": 50, "description": "The depth argument of Git clone operation. It can be either number or \"full\" value", "example": "full", "oneOf": [{"minimum": 1, "type": "integer"}, {"enum": ["full"], "type": "string"}], "title": "Git Clone Depth"}, "enabled": {"default": true, "description": "Enables cloning of the repository.", "type": "boolean"}, "lfs": {"default": false, "description": "Enables the download of files from LFS storage when cloning.", "type": "boolean"}, "skip-ssl-verify": {"default": false, "description": "Disables SSL verification during Git clone operation, allowing the use of self-signed certificates.", "type": "boolean"}}, "title": "Clone Repository Settings", "type": "object"}, "cloud": {"description": "Custom cloud step runtime", "properties": {"arch": {"default": "x86", "description": "Architecture type used to run the step.", "enum": ["x86", "arm"], "type": "string"}, "atlassian-ip-ranges": {"default": false, "description": "Whether it uses Atlassian ip ranges.", "type": "boolean"}, "version": {"description": "Cloud Runtime version.", "type": "string"}}, "title": "Cloud step runtime", "type": "object"}, "condition": {"properties": {"changesets": {"additionalProperties": false, "description": "Condition on the changesets involved in the pipeline.", "maxProperties": 1, "properties": {"excludePaths": {"description": "Condition which holds only if all of the modified files match any of the specified patterns.", "items": {"description": "Glob pattern to match the file path.", "title": "File Path Pattern", "type": "string"}, "minItems": 1, "title": "Exclude Paths", "type": "array"}, "includePaths": {"description": "Condition which holds only if any of the modified files match any of the specified patterns.", "items": {"description": "Glob pattern to match the file path.", "title": "File Path Pattern", "type": "string"}, "minItems": 1, "title": "Include Paths", "type": "array"}}, "title": "Changeset Condition", "type": "object"}}, "required": ["changesets"], "type": "object"}, "custom_pipeline": {"oneOf": [{"$ref": "#/components/schemas/items_with_variables"}, {"$ref": "#/components/schemas/import_pipeline"}]}, "fail_fast": {"default": false, "title": "Fail Fast", "type": "boolean"}, "image": {"oneOf": [{"$ref": "#/components/schemas/image_no_auth"}, {"$ref": "#/components/schemas/image_basic_auth"}, {"$ref": "#/components/schemas/image_aws_auth"}, {"$ref": "#/components/schemas/image_name"}]}, "image_aws_auth": {"allOf": [{"$ref": "#/components/schemas/image_base"}, {"properties": {"aws": {"oneOf": [{"properties": {"access-key": {"description": "The access key for Amazon Elastic Container Registry (AWS ECR).", "title": "AWS Access Key", "type": "string"}, "secret-key": {"description": "The secret key for Amazon Elastic Container Registry (AWS ECR).", "title": "AWS Secret Key", "type": "string"}}, "required": ["access-key", "secret-key"], "type": "object"}, {"properties": {"oidc-role": {"description": "OIDC role with access to private Docker images hosted in Amazon Elastic Container Registry (AWS ECR).", "title": "OpenID Connect Role", "type": "string"}}, "required": ["oidc-role"], "type": "object"}]}}, "required": ["aws"], "type": "object"}]}, "image_base": {"description": "The parameters of the Docker image to use when running a step.", "properties": {"name": {"$ref": "#/components/schemas/image_name"}, "run-as-user": {"default": 0, "description": "The UID of a user in the docker image to run as. Overrides image's default user, specified user UID must be an existing user in the image with a valid home directory.", "title": "User ID", "type": "integer"}}, "required": ["name"], "title": "Docker Image Configuration", "type": "object"}, "image_basic_auth": {"allOf": [{"$ref": "#/components/schemas/image_base"}, {"properties": {"password": {"description": "The password to use when fetching the Docker image.", "title": "Docker Registry Password", "type": "string"}, "username": {"description": "The username to use when fetching the Docker image.", "title": "Docker Registry Username", "type": "string"}}, "required": ["username", "password"], "type": "object"}]}, "image_name": {"default": "atlassian/default-image:latest", "description": "The name of the Docker image which may or may not include registry URL, tag, and digest value.", "title": "Docker Image Name", "type": "string"}, "image_no_auth": {"allOf": [{"$ref": "#/components/schemas/image_base"}, {"properties": {"aws": {"not": {}}, "password": {"not": {}}, "username": {"not": {}}}, "type": "object"}]}, "import_pipeline": {"additionalProperties": false, "properties": {"import": {"description": "The import needs to match the following format: {repo-slug|repo-uuid}:{tag-name|branch-name}:{pipeline-name}.", "pattern": "^[^:]+:[^:]+:[^:]+$", "title": "Identifier of the pipeline configuration to import", "type": "string"}}, "required": ["import"], "type": "object"}, "items": {"description": "List of steps, stages and parallel groups of the pipeline.", "items": {"oneOf": [{"$ref": "#/components/schemas/step_item"}, {"$ref": "#/components/schemas/parallel_item"}, {"$ref": "#/components/schemas/stage_item"}]}, "minItems": 1, "title": "Pipeline Items", "type": "array"}, "items_with_variables": {"description": "List of variables, steps, stages and parallel groups of the custom pipeline.", "items": {"oneOf": [{"$ref": "#/components/schemas/variables_item"}, {"$ref": "#/components/schemas/step_item"}, {"$ref": "#/components/schemas/parallel_item"}, {"$ref": "#/components/schemas/stage_item"}]}, "minItems": 1, "title": "Custom Pipeline Items", "type": "array"}, "max_time": {"default": 120, "description": "The maximum time a step can execute for in minutes.", "example": 60, "exclusiveMinimum": 0, "type": "integer"}, "parallel": {"oneOf": [{"$ref": "#/components/schemas/parallel_steps"}, {"$ref": "#/components/schemas/parallel_expanded"}]}, "parallel_expanded": {"properties": {"fail-fast": {"$ref": "#/components/schemas/fail_fast", "description": "Stop the whole parallel group in case one of its steps fails."}, "steps": {"$ref": "#/components/schemas/parallel_steps"}}, "required": ["steps"], "type": "object"}, "parallel_item": {"additionalProperties": false, "properties": {"parallel": {"$ref": "#/components/schemas/parallel"}}, "type": "object"}, "parallel_steps": {"description": "List of steps in the parallel group to run concurrently.", "items": {"$ref": "#/components/schemas/step_item"}, "minItems": 1, "title": "Parallel Group Steps", "type": "array"}, "pipe": {"description": "The pipe to execute.", "example": {"pipe": "atlassian/test-pipe:2.2.0", "variables": {"BAZ": ["QUX", "QUZ"], "FOO": "BAR"}}, "properties": {"pipe": {"description": "The full pipe identifier.", "title": "Pipe Identifier", "type": "string"}, "variables": {"additionalProperties": {"description": "Environment variable value", "oneOf": [{"type": "string"}, {"items": {"type": "string"}, "type": "array"}]}, "description": "Environment variables passed to the pipe container.", "title": "Pipe Variables", "type": "object"}}, "required": ["pipe"], "title": "Pipe", "type": "object"}, "pipeline": {"oneOf": [{"$ref": "#/components/schemas/items"}, {"$ref": "#/components/schemas/import_pipeline"}]}, "pipelines_configuration": {"properties": {"clone": {"$ref": "#/components/schemas/clone"}, "definitions": {"description": "The definitions of caches and services used in the declared pipelines.", "properties": {"caches": {"additionalProperties": {"$ref": "#/components/schemas/cache"}, "title": "Custom cache definitions", "type": "object"}, "pipelines": {"additionalProperties": {"$ref": "#/components/schemas/custom_pipeline"}, "description": "Definitions of the pipelines which can be used in other repositories of the same Bitbucket workspace.", "title": "Shared pipeline definitions", "type": "object"}, "services": {"additionalProperties": {"$ref": "#/components/schemas/service"}, "title": "Service definitions", "type": "object"}}, "title": "Global Definitions", "type": "object"}, "export": {"default": false, "description": "Allows other Bitbucket repositories to import pipeline definitions from this file. A shared pipeline definition can't contain another `import` property.", "title": "Enables shared pipelines definitions.", "type": "boolean"}, "image": {"$ref": "#/components/schemas/image"}, "labels": {"description": "Additional key value data supplied in the configuration YAML.", "example": {"buildTool": "maven", "jvm": "jdk17"}, "title": "Pipeline Labels", "type": "object"}, "options": {"description": "Global options allow to override the default values applied to all steps in all declared pipelines.", "properties": {"docker": {"default": false, "description": "Enables Docker service for every step.", "type": "boolean"}, "max-time": {"$ref": "#/components/schemas/max_time"}, "runtime": {"$ref": "#/components/schemas/runtime"}, "size": {"$ref": "#/components/schemas/size"}}, "title": "Global Options", "type": "object"}, "pipelines": {"properties": {"branches": {"additionalProperties": {"$ref": "#/components/schemas/pipeline"}, "description": "Branch-specific build pipelines.", "title": "Branch Pipelines", "type": "object"}, "custom": {"additionalProperties": {"$ref": "#/components/schemas/custom_pipeline"}, "description": "Pipelines that can only be triggered manually or be scheduled.", "title": "Custom Pipelines", "type": "object"}, "default": {"$ref": "#/components/schemas/pipeline", "description": "Default pipeline runs on every push except for tags unless a branch-specific pipeline is defined.", "title": "Default Pipeline"}, "pull-requests": {"additionalProperties": {"$ref": "#/components/schemas/pull_requests_pipeline"}, "description": "Pull-request-specific build pipelines.", "title": "Pull Request Pipelines", "type": "object"}, "tags": {"additionalProperties": {"$ref": "#/components/schemas/pipeline"}, "description": "Tag-specific build pipelines.", "title": "Tag Pipelines", "type": "object"}}, "title": "Pipelines", "type": "object"}}, "type": "object"}, "pull_requests_pipeline": {"oneOf": [{"$ref": "#/components/schemas/items"}, {"properties": {"destinations": {"additionalProperties": {"$ref": "#/components/schemas/pipeline"}, "type": "object"}}, "type": "object"}]}, "runs_on": {"oneOf": [{"$ref": "#/components/schemas/runs_on_item"}, {"$ref": "#/components/schemas/runs_on_expanded"}]}, "runs_on_expanded": {"description": "Required labels of a runner to run the step.", "example": ["self.hosted", "linux"], "items": {"$ref": "#/components/schemas/runs_on_item"}, "maxItems": 10, "minItems": 1, "title": "Step Runner Labels", "type": "array"}, "runs_on_item": {"description": "Label of a runner.", "maxLength": 50, "title": "Step Runner Label", "type": "string"}, "runtime": {"description": "Custom step runtime", "properties": {"cloud": {"$ref": "#/components/schemas/cloud"}}, "title": "Step Runtime", "type": "object"}, "script": {"items": {"oneOf": [{"description": "The command to execute.", "example": "echo \"hello world\"", "title": "Script Command", "type": "string"}, {"$ref": "#/components/schemas/pipe"}]}, "minItems": 1, "type": "array"}, "service": {"description": "Custom service properties", "properties": {"image": {"$ref": "#/components/schemas/image"}, "memory": {"default": 1024, "description": "Memory limit for the service container, in megabytes.", "minimum": 128, "title": "Service Memory", "type": "integer"}, "type": {"description": "Specifies Docker service container (to run Docker-in-Docker).", "enum": ["docker"], "type": "string"}, "variables": {"additionalProperties": {"description": "Environment variable value", "title": "Service Variable", "type": "string"}, "description": "Environment variables passed to the service container.", "minProperties": 1, "title": "Service Variables", "type": "object"}}, "title": "Service definition", "type": "object"}, "size": {"default": "1x", "description": "The size of the step, sets the amount of resources allocated.", "enum": ["1x", "2x", "4x", "8x", "16x", "32x"], "title": "Step Size", "type": "string"}, "stage": {"properties": {"condition": {"$ref": "#/components/schemas/condition", "description": "The condition to execute the stage.", "title": "Stage Condition"}, "deployment": {"description": "The deployment environment for the stage.", "title": "Stage Deployment Environment", "type": "string"}, "name": {"description": "The name of the stage.", "title": "Stage Name", "type": "string"}, "steps": {"description": "List of steps in the stage.", "items": {"properties": {"step": {"allOf": [{"$ref": "#/components/schemas/step_base"}, {"properties": {"condition": {"not": {}}}, "type": "object"}]}}, "type": "object"}, "minItems": 1, "title": "Stage Steps", "type": "array"}, "trigger": {"$ref": "#/components/schemas/trigger", "description": "The trigger used for the pipeline stage.", "title": "Stage Trigger"}}, "required": ["steps"], "type": "object"}, "stage_item": {"additionalProperties": false, "properties": {"stage": {"$ref": "#/components/schemas/stage"}}, "type": "object"}, "step": {"allOf": [{"$ref": "#/components/schemas/step_base"}, {"properties": {"condition": {"$ref": "#/components/schemas/condition", "description": "The condition to execute the step.", "title": "Step Condition"}}, "type": "object"}]}, "step_base": {"properties": {"after-script": {"$ref": "#/components/schemas/script", "description": "List of commands to execute after the step succeeds or fails.", "title": "Step Post Script"}, "artifacts": {"$ref": "#/components/schemas/artifacts"}, "caches": {"description": "Caches enabled for the step.", "items": {"description": "Reference to a cache defined under global definitions.", "title": "Cache Name", "type": "string"}, "minItems": 1, "title": "Step Caches", "type": "array"}, "clone": {"$ref": "#/components/schemas/clone"}, "deployment": {"description": "The deployment environment for the step.", "title": "Step Deployment Environment", "type": "string"}, "fail-fast": {"$ref": "#/components/schemas/fail_fast", "description": "Stop the parent parallel group in case this step fails."}, "image": {"$ref": "#/components/schemas/image"}, "max-time": {"$ref": "#/components/schemas/max_time", "title": "Step Maximum Time"}, "name": {"description": "The name of the step.", "example": "Build and test", "title": "Step Name", "type": "string"}, "oidc": {"description": "Enables the use of OpenID Connect to connect a pipeline step to a resource server.", "type": "boolean"}, "runs-on": {"$ref": "#/components/schemas/runs_on"}, "runtime": {"$ref": "#/components/schemas/runtime"}, "script": {"$ref": "#/components/schemas/script", "description": "List of commands that are executed in sequence.", "title": "Step Script"}, "services": {"description": "Services enabled for the step.", "items": {"description": "Reference to a service defined under global definitions.", "title": "Service Name", "type": "string"}, "maxItems": 5, "minItems": 1, "title": "Step Services", "type": "array"}, "size": {"$ref": "#/components/schemas/size"}, "trigger": {"$ref": "#/components/schemas/trigger", "description": "The trigger used for the pipeline step.", "title": "Step Trigger"}}, "required": ["script"], "title": "Pipeline Step", "type": "object"}, "step_item": {"additionalProperties": false, "properties": {"step": {"$ref": "#/components/schemas/step"}}, "type": "object"}, "trigger": {"default": "automatic", "enum": ["automatic", "manual"], "type": "string"}, "variables_item": {"additionalProperties": false, "properties": {"variables": {"description": "List of variables for the custom pipeline.", "items": {"description": "Settings for the custom variable.", "properties": {"allowed-values": {"description": "A list of values that are allowed for the variable.", "items": {"title": "Allowed Variable Value", "type": "string"}, "minItems": 1, "title": "Allowed Variable Values", "type": "array"}, "default": {"title": "Default Variable Value", "type": "string"}, "description": {"title": "Variable Description", "type": "string"}, "name": {"title": "Variable Name", "type": "string"}}, "required": ["name"], "title": "Custom Pipeline Variable", "type": "object"}, "minItems": 1, "title": "Custom Pipeline Variables", "type": "array"}}, "type": "object"}}}} \ No newline at end of file diff --git a/src/check_jsonschema/builtin_schemas/vendor/buildkite.json b/src/check_jsonschema/builtin_schemas/vendor/buildkite.json index 7b0563cd8..df9a6a214 100644 --- a/src/check_jsonschema/builtin_schemas/vendor/buildkite.json +++ b/src/check_jsonschema/builtin_schemas/vendor/buildkite.json @@ -72,7 +72,7 @@ "limit": { "type": "integer", "description": "The number of times this job can be retried", - "minimum": 1, + "minimum": 0, "maximum": 10 }, "signal": { diff --git a/src/check_jsonschema/builtin_schemas/vendor/circle-ci.json b/src/check_jsonschema/builtin_schemas/vendor/circle-ci.json index 7c2f1bfa5..2013bfaad 100644 --- a/src/check_jsonschema/builtin_schemas/vendor/circle-ci.json +++ b/src/check_jsonschema/builtin_schemas/vendor/circle-ci.json @@ -1166,6 +1166,10 @@ "type": "string" } } + }, + "override-with": { + "description": "This allows overriding the job to run with a different job definition. The provided job override must be an orb job.", + "type": "string" } } }, diff --git a/src/check_jsonschema/builtin_schemas/vendor/compose-spec.json b/src/check_jsonschema/builtin_schemas/vendor/compose-spec.json index 4b6df9a8a..ee1137fba 100644 --- a/src/check_jsonschema/builtin_schemas/vendor/compose-spec.json +++ b/src/check_jsonschema/builtin_schemas/vendor/compose-spec.json @@ -259,6 +259,20 @@ } ] }, + "provider": { + "type": "object", + "properties": { + "type": {"type": "string"}, + "options": { + "type": "object", + "patternProperties": { + "^.+$": {"type": ["string", "number", "null"]} + } + } + }, + "additionalProperties": false, + "patternProperties": {"^x-": {}} + }, "external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true}, "extra_hosts": {"$ref": "#/definitions/extra_hosts"}, "gpus": {"$ref": "#/definitions/gpus"}, @@ -279,7 +293,6 @@ "links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true}, "logging": { "type": "object", - "properties": { "driver": {"type": "string"}, "options": { @@ -405,7 +418,9 @@ "type": "object", "required": ["type"], "properties": { - "type": {"type": "string"}, + "type": {"type": "string", + "enum": ["bind", "volume", "tmpfs", "cluster", "image"] + }, "source": {"type": "string"}, "target": {"type": "string"}, "read_only": {"type": ["boolean", "string"]}, @@ -424,6 +439,7 @@ "volume": { "type": "object", "properties": { + "labels": {"$ref": "#/definitions/list_or_dict"}, "nocopy": {"type": ["boolean", "string"]}, "subpath": {"type": "string"} }, @@ -443,6 +459,14 @@ }, "additionalProperties": false, "patternProperties": {"^x-": {}} + }, + "image": { + "type": "object", + "properties": { + "subpath": {"type": "string"} + }, + "additionalProperties": false, + "patternProperties": {"^x-": {}} } }, "additionalProperties": false, diff --git a/src/check_jsonschema/builtin_schemas/vendor/github-workflows.json b/src/check_jsonschema/builtin_schemas/vendor/github-workflows.json index e1c0b890f..7df318b6c 100644 --- a/src/check_jsonschema/builtin_schemas/vendor/github-workflows.json +++ b/src/check_jsonschema/builtin_schemas/vendor/github-workflows.json @@ -491,8 +491,15 @@ "types": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#onevent_nametypes", "description": "Selects the types of activity that will trigger a workflow run. Most GitHub events are triggered by more than one type of activity. For example, the event for the release resource is triggered when a release is published, unpublished, created, edited, deleted, or prereleased. The types keyword enables you to narrow down activity that causes the workflow to run. When only one activity type triggers a webhook event, the types keyword is unnecessary.\nYou can use an array of event types. For more information about each event and their activity types, see https://help.github.com/en/articles/events-that-trigger-workflows#webhook-events.", - "type": "array", - "minItems": 1 + "oneOf": [ + { + "type": "array", + "minItems": 1 + }, + { + "type": "string" + } + ] }, "working-directory": { "$comment": "https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsrun", @@ -1574,7 +1581,6 @@ "type": "boolean" } }, - "required": ["required"], "additionalProperties": false } }, diff --git a/src/check_jsonschema/builtin_schemas/vendor/mergify.json b/src/check_jsonschema/builtin_schemas/vendor/mergify.json index fb873601e..d11b98d61 100644 --- a/src/check_jsonschema/builtin_schemas/vendor/mergify.json +++ b/src/check_jsonschema/builtin_schemas/vendor/mergify.json @@ -1311,6 +1311,16 @@ "minimum": 1, "title": "Max Parallel Checks", "type": "integer" + }, + "reset_on_external_merge": { + "default": "always", + "description": "Defines the behavior of the merge queue when something is merged outside of the queue.\n\"always\": The queue is reset when an external merge is detected. All queued pull requests are re-evaluated to ensure correctness based on the new base branch state.\n\"never\": The queue remains unchanged. It does not reset or re-evaluate based on the external merge.\n", + "enum": [ + "never", + "always" + ], + "title": "Reset On External Merge", + "type": "string" } }, "title": "MergeQueueModel", @@ -1684,6 +1694,7 @@ { "enum": [ "PR_DEQUEUED", + "PR_DEQUEUED_FROM_PARTITION", "PR_AHEAD_DEQUEUED", "PR_AHEAD_FAILED_TO_MERGE", "PR_WITH_HIGHER_PRIORITY_QUEUED", @@ -1706,7 +1717,8 @@ "MERGE_QUEUE_RESET", "INCOMPATIBILITY_WITH_BRANCH_PROTECTIONS", "PR_MANUALLY_MERGED", - "DRAFT_PULL_REQUEST_CREATION_FAILED" + "DRAFT_PULL_REQUEST_CREATION_FAILED", + "CONFIGURATION_CHANGED" ], "type": "string" }, @@ -1869,6 +1881,22 @@ "title": "Commits unverified", "type": "array" }, + "deployment-success": { + "description": "The list of deployments that successfully passed for the pull request.", + "items": { + "type": "string" + }, + "title": "Deployment success", + "type": "array" + }, + "deployment-failure": { + "description": "The list of deployments that failed for the pull request.", + "items": { + "type": "string" + }, + "title": "Deployment failure", + "type": "array" + }, "review-threads-resolved": { "description": "The list of bodies associated to review threads that are marked as resolved by GitHub.", "items": { @@ -2133,6 +2161,8 @@ "check", "check-stale", "commits-unverified", + "deployment-success", + "deployment-failure", "review-threads-resolved", "review-threads-unresolved", "files", diff --git a/src/check_jsonschema/builtin_schemas/vendor/renovate.json b/src/check_jsonschema/builtin_schemas/vendor/renovate.json index 08ee46d44..57ff96ca4 100644 --- a/src/check_jsonschema/builtin_schemas/vendor/renovate.json +++ b/src/check_jsonschema/builtin_schemas/vendor/renovate.json @@ -1091,7 +1091,7 @@ "dockerSidecarImage": { "description": "Change this value to override the default Renovate sidecar image.", "type": "string", - "default": "ghcr.io/containerbase/sidecar:13.8.8" + "default": "ghcr.io/containerbase/sidecar:13.8.13" }, "dockerUser": { "description": "Set the `UID` and `GID` for Docker-based binaries if you use `binarySource=docker`.", @@ -2651,6 +2651,10 @@ "description": "The version of the new dependency that replaces the old deprecated dependency.", "type": "string" }, + "replacementVersionTemplate": { + "description": "Template field for the version of the new dependency that replaces the old deprecated dependency.", + "type": "string" + }, "sourceDirectory": { "description": "The source directory in which the package is present at its source.", "type": "string" @@ -2841,6 +2845,7 @@ "gomodSkipVendor", "gomodVendor", "helmUpdateSubChartArchives", + "kustomizeInflateHelmCharts", "npmDedupe", "pnpmDedupe", "yarnDedupeFewer", diff --git a/src/check_jsonschema/builtin_schemas/vendor/sha256/bitbucket-pipelines.sha256 b/src/check_jsonschema/builtin_schemas/vendor/sha256/bitbucket-pipelines.sha256 index ccae2cf5a..aad5dcef8 100644 --- a/src/check_jsonschema/builtin_schemas/vendor/sha256/bitbucket-pipelines.sha256 +++ b/src/check_jsonschema/builtin_schemas/vendor/sha256/bitbucket-pipelines.sha256 @@ -1 +1 @@ -c02d76572f2fdf6ace59245802f5fb10d758572f31c929a55cffe76b1b64d776 \ No newline at end of file +22aa0ca154ac4a264f97702428bb771e372237993db32537980d25f12120715a \ No newline at end of file diff --git a/src/check_jsonschema/builtin_schemas/vendor/sha256/buildkite.sha256 b/src/check_jsonschema/builtin_schemas/vendor/sha256/buildkite.sha256 index d6ed613fb..31e4a9814 100644 --- a/src/check_jsonschema/builtin_schemas/vendor/sha256/buildkite.sha256 +++ b/src/check_jsonschema/builtin_schemas/vendor/sha256/buildkite.sha256 @@ -1 +1 @@ -128a96e0088b34eb6c1bd591df82a32e1e6743a4bd7c38fc0f5819b2e1ef831a \ No newline at end of file +ff30bd5f6d22b965472c1c289bc90e92e837ce136c83a4a7f6ad6cc54132fa99 \ No newline at end of file diff --git a/src/check_jsonschema/builtin_schemas/vendor/sha256/circle-ci.sha256 b/src/check_jsonschema/builtin_schemas/vendor/sha256/circle-ci.sha256 index 17444d1c7..437fb58a5 100644 --- a/src/check_jsonschema/builtin_schemas/vendor/sha256/circle-ci.sha256 +++ b/src/check_jsonschema/builtin_schemas/vendor/sha256/circle-ci.sha256 @@ -1 +1 @@ -21743cc33a819684da3c501c2d22c94ff02b520f055b1610356c86e9acd06847 \ No newline at end of file +4d5d0bb592542dc4600680f7805ea640186627043c4816bd6839c33e388692d9 \ No newline at end of file diff --git a/src/check_jsonschema/builtin_schemas/vendor/sha256/compose-spec.sha256 b/src/check_jsonschema/builtin_schemas/vendor/sha256/compose-spec.sha256 index d4980ac08..a59ea0990 100644 --- a/src/check_jsonschema/builtin_schemas/vendor/sha256/compose-spec.sha256 +++ b/src/check_jsonschema/builtin_schemas/vendor/sha256/compose-spec.sha256 @@ -1 +1 @@ -ea8f3bd1e32cb93be231122144b119746b68b18d79ed118704c6fa3aa105a49e \ No newline at end of file +1bf44a391eb97a0426d09792a325b63805cb8731e1cd81ed144161b3e473aa59 \ No newline at end of file diff --git a/src/check_jsonschema/builtin_schemas/vendor/sha256/github-workflows.sha256 b/src/check_jsonschema/builtin_schemas/vendor/sha256/github-workflows.sha256 index 7c5776874..07e6912cd 100644 --- a/src/check_jsonschema/builtin_schemas/vendor/sha256/github-workflows.sha256 +++ b/src/check_jsonschema/builtin_schemas/vendor/sha256/github-workflows.sha256 @@ -1 +1 @@ -e2fe2167fb07a4121a234523058195afd42792fdf3d06ca3c731d91ff55a8a8c \ No newline at end of file +78456fc783a9166a52731197fb303f28961457e7a87acc9a78e4783a0ae284c9 \ No newline at end of file diff --git a/src/check_jsonschema/builtin_schemas/vendor/sha256/mergify.sha256 b/src/check_jsonschema/builtin_schemas/vendor/sha256/mergify.sha256 index b451e7747..e2756efea 100644 --- a/src/check_jsonschema/builtin_schemas/vendor/sha256/mergify.sha256 +++ b/src/check_jsonschema/builtin_schemas/vendor/sha256/mergify.sha256 @@ -1 +1 @@ -0c2f20fa607c47b0c3c8e0f9162fc7177bcc70b4e720d061e53e492da8d411b8 \ No newline at end of file +e2d985102db50b5ab5c36d67ae60ba8dcd0f6a0fecf2e6bcd10bf3eb36d468ed \ No newline at end of file diff --git a/src/check_jsonschema/builtin_schemas/vendor/sha256/renovate.sha256 b/src/check_jsonschema/builtin_schemas/vendor/sha256/renovate.sha256 index 384f25b3c..7e14e9ed5 100644 --- a/src/check_jsonschema/builtin_schemas/vendor/sha256/renovate.sha256 +++ b/src/check_jsonschema/builtin_schemas/vendor/sha256/renovate.sha256 @@ -1 +1 @@ -30ab380b17083e659ff9e7e5ff8d770e89b2d5889fdb526407a9a4a807dedefc \ No newline at end of file +2dc6e675330d40bd9b1446e7a038eeee1ed656defeb35b44f11431ef97573ebd \ No newline at end of file diff --git a/src/check_jsonschema/builtin_schemas/vendor/sha256/taskfile.sha256 b/src/check_jsonschema/builtin_schemas/vendor/sha256/taskfile.sha256 index 5b823abbd..680a8bc64 100644 --- a/src/check_jsonschema/builtin_schemas/vendor/sha256/taskfile.sha256 +++ b/src/check_jsonschema/builtin_schemas/vendor/sha256/taskfile.sha256 @@ -1 +1 @@ -b40df180ca88093a8be667dd996b43221de2ad6d85c48f78e5f43784d29dc9a9 \ No newline at end of file +0cd16e7df47d129c51fbea320f34361eb177e6447ccce10df769dcd672cccdad \ No newline at end of file diff --git a/src/check_jsonschema/builtin_schemas/vendor/sha256/woodpecker-ci.sha256 b/src/check_jsonschema/builtin_schemas/vendor/sha256/woodpecker-ci.sha256 index 236d69bfa..ded967da0 100644 --- a/src/check_jsonschema/builtin_schemas/vendor/sha256/woodpecker-ci.sha256 +++ b/src/check_jsonschema/builtin_schemas/vendor/sha256/woodpecker-ci.sha256 @@ -1 +1 @@ -cbdc42a5f4ff756568f95391688075622327e790cdcb669719cec3e192923878 \ No newline at end of file +927fec729aca41a30c4c6d73aae3ef7a0a8572d3fdcf6faf569a4869c71d59f0 \ No newline at end of file diff --git a/src/check_jsonschema/builtin_schemas/vendor/taskfile.json b/src/check_jsonschema/builtin_schemas/vendor/taskfile.json index 49af497b4..0a942697d 100644 --- a/src/check_jsonschema/builtin_schemas/vendor/taskfile.json +++ b/src/check_jsonschema/builtin_schemas/vendor/taskfile.json @@ -276,7 +276,7 @@ "^.*$": { "anyOf": [ { - "type": ["boolean", "integer", "null", "number", "string", "object", "array"] + "type": ["boolean", "integer", "null", "number", "string", "array"] }, { "$ref": "#/definitions/var_subkey" @@ -475,7 +475,7 @@ "for_attribute": { "description": "The task attribute to iterate over", "type": "string", - "enum": ["sources"] + "enum": ["sources", "generates"] }, "for_var": { "description": "Which variables to iterate over. The variable will be split using any whitespace character by default. This can be changed by using the `split` attribute.", diff --git a/src/check_jsonschema/builtin_schemas/vendor/woodpecker-ci.json b/src/check_jsonschema/builtin_schemas/vendor/woodpecker-ci.json index 8cde9d42c..2c992e6dc 100644 --- a/src/check_jsonschema/builtin_schemas/vendor/woodpecker-ci.json +++ b/src/check_jsonschema/builtin_schemas/vendor/woodpecker-ci.json @@ -650,7 +650,7 @@ "$ref": "#/definitions/step_backend_kubernetes_security_context" }, "runtimeClassName": { - "description": "Read more: https://woodpecker-ci.org/docs/administration/backends/kubernetes#runtimeclassname", + "description": "Read more: https://woodpecker-ci.org/docs/administration/configuration/backends/kubernetes#runtimeclassname", "type": "string" }, "secrets": { @@ -664,7 +664,7 @@ } }, "step_backend_kubernetes_resources": { - "description": "Resources for the kubernetes backend. Read more: https://woodpecker-ci.org/docs/administration/backends/kubernetes#job-specific-configuration", + "description": "Resources for the kubernetes backend. Read more: https://woodpecker-ci.org/docs/administration/configuration/backends/kubernetes#step-specific-configuration", "type": "object", "properties": { "requests": { @@ -676,7 +676,7 @@ } }, "step_backend_kubernetes_security_context": { - "description": "Pods / containers security context. Read more: https://woodpecker-ci.org/docs/administration/backends/kubernetes#securitycontext", + "description": "Pods / containers security context. Read more: https://woodpecker-ci.org/docs/administration/configuration/backends/kubernetes#security-context", "type": "object", "properties": { "privileged": { @@ -703,7 +703,7 @@ } }, "step_backend_kubernetes_secprofile": { - "description": "Pods / containers security profile. Read more: https://woodpecker-ci.org/docs/administration/backends/kubernetes#job-specific-configuration", + "description": "Pods / containers security profile. Read more: https://woodpecker-ci.org/docs/administration/configuration/backends/kubernetes#step-specific-configuration", "type": "object", "properties": { "type": { @@ -722,7 +722,7 @@ } }, "step_backend_kubernetes_service_account": { - "description": "serviceAccountName to be use by job. Read more: https://woodpecker-ci.org/docs/administration/backends/kubernetes#serviceaccountname", + "description": "serviceAccountName to be use by job. Read more: https://woodpecker-ci.org/docs/administration/configuration/backends/kubernetes#service-account", "type": "object", "properties": { "requests": { diff --git a/src/check_jsonschema/catalog.py b/src/check_jsonschema/catalog.py index cc7f1587e..f98ceb6b2 100644 --- a/src/check_jsonschema/catalog.py +++ b/src/check_jsonschema/catalog.py @@ -4,7 +4,7 @@ def _bitbucket_pipelines_url() -> str: - return "https://bitbucket.org/atlassianlabs/intellij-bitbucket-references-plugin/raw/master/src/main/resources/schemas/bitbucket-pipelines.schema.json" # noqa: E501 + return "https://api.bitbucket.org/schemas/pipelines-configuration" def _githubusercontent_url(owner: str, repo: str, ref: str, path: str) -> str: diff --git a/src/check_jsonschema/cli/main_command.py b/src/check_jsonschema/cli/main_command.py index 9e93ff1ff..62d79bb35 100644 --- a/src/check_jsonschema/cli/main_command.py +++ b/src/check_jsonschema/cli/main_command.py @@ -161,6 +161,11 @@ def pretty_helptext_list(values: list[str] | tuple[str, ...]) -> str: show_default=True, type=click.Choice(SUPPORTED_FILE_FORMATS, case_sensitive=True), ) +@click.option( + "--force-filetype", + help="Force a file type to use when parsing instance files", + type=click.Choice(SUPPORTED_FILE_FORMATS, case_sensitive=True), +) @click.option( "--traceback-mode", help=( @@ -242,6 +247,7 @@ def main( format_regex: t.Literal["python", "nonunicode", "default"] | None, regex_variant: t.Literal["python", "nonunicode", "default"] | None, default_filetype: t.Literal["json", "yaml", "toml", "json5"], + force_filetype: t.Literal["json", "yaml", "toml", "json5"] | None, traceback_mode: t.Literal["full", "short"], data_transform: t.Literal["azure-pipelines", "gitlab-ci"] | None, fill_defaults: bool, @@ -271,6 +277,7 @@ def main( args.disable_cache = no_cache args.default_filetype = default_filetype + args.force_filetype = force_filetype args.fill_defaults = fill_defaults if data_transform is not None: args.data_transform = TRANSFORM_LIBRARY[data_transform] @@ -311,6 +318,7 @@ def build_instance_loader(args: ParseResult) -> InstanceLoader: return InstanceLoader( args.instancefiles, default_filetype=args.default_filetype, + force_filetype=args.force_filetype, data_transform=args.data_transform, ) diff --git a/src/check_jsonschema/cli/parse_result.py b/src/check_jsonschema/cli/parse_result.py index bfd9065b1..fd925118c 100644 --- a/src/check_jsonschema/cli/parse_result.py +++ b/src/check_jsonschema/cli/parse_result.py @@ -29,6 +29,7 @@ def __init__(self) -> None: self.cache_filename: str | None = None # filetype detection (JSON, YAML, TOML, etc) self.default_filetype: str = "json" + self.force_filetype: str | None = None # data-transform (for Azure Pipelines and potentially future transforms) self.data_transform: Transform | None = None # validation behavioral controls diff --git a/src/check_jsonschema/instance_loader.py b/src/check_jsonschema/instance_loader.py index 2d0651c4f..5d76bbfe7 100644 --- a/src/check_jsonschema/instance_loader.py +++ b/src/check_jsonschema/instance_loader.py @@ -14,10 +14,12 @@ def __init__( self, files: t.Sequence[t.IO[bytes] | CustomLazyFile], default_filetype: str = "json", + force_filetype: str | None = None, data_transform: Transform | None = None, ) -> None: self._files = files self._default_filetype = default_filetype + self._force_filetype = force_filetype self._data_transform = ( data_transform if data_transform is not None else Transform() ) @@ -46,7 +48,7 @@ def iter_files(self) -> t.Iterator[tuple[str, ParseError | t.Any]]: try: data: t.Any = self._parsers.parse_data_with_path( - stream, name, self._default_filetype + stream, name, self._default_filetype, self._force_filetype ) except ParseError as err: data = err diff --git a/src/check_jsonschema/parsers/__init__.py b/src/check_jsonschema/parsers/__init__.py index 6db5e95bf..5938ce5d7 100644 --- a/src/check_jsonschema/parsers/__init__.py +++ b/src/check_jsonschema/parsers/__init__.py @@ -65,9 +65,15 @@ def __init__( } def get( - self, path: pathlib.Path | str, default_filetype: str + self, + path: pathlib.Path | str, + default_filetype: str, + force_filetype: str | None = None, ) -> t.Callable[[t.IO[bytes]], t.Any]: - filetype = path_to_type(path, default_type=default_filetype) + if force_filetype: + filetype = force_filetype + else: + filetype = path_to_type(path, default_type=default_filetype) if filetype in self._by_tag: return self._by_tag[filetype] @@ -83,9 +89,13 @@ def get( ) def parse_data_with_path( - self, data: t.IO[bytes] | bytes, path: pathlib.Path | str, default_filetype: str + self, + data: t.IO[bytes] | bytes, + path: pathlib.Path | str, + default_filetype: str, + force_filetype: str | None = None, ) -> t.Any: - loadfunc = self.get(path, default_filetype) + loadfunc = self.get(path, default_filetype, force_filetype) try: if isinstance(data, bytes): data = io.BytesIO(data) @@ -93,6 +103,11 @@ def parse_data_with_path( except LOADING_FAILURE_ERROR_TYPES as e: raise FailedFileLoadError(f"Failed to parse {path}") from e - def parse_file(self, path: pathlib.Path | str, default_filetype: str) -> t.Any: + def parse_file( + self, + path: pathlib.Path | str, + default_filetype: str, + force_filetype: str | None = None, + ) -> t.Any: with open(path, "rb") as fp: - return self.parse_data_with_path(fp, path, default_filetype) + return self.parse_data_with_path(fp, path, default_filetype, force_filetype) diff --git a/tests/acceptance/test_hook_file_matches.py b/tests/acceptance/test_hook_file_matches.py index b48f6dfca..918ed315b 100644 --- a/tests/acceptance/test_hook_file_matches.py +++ b/tests/acceptance/test_hook_file_matches.py @@ -5,6 +5,7 @@ import pytest import ruamel.yaml +from identify.identify import tags_from_filename yaml = ruamel.yaml.YAML(typ="safe") @@ -29,6 +30,22 @@ def check_pattern_match( pytest.fail(f"'{pattern}' matched '{value}' (expected no match)") +def check_types_match( + types: list[str], + types_or: list[str], + path: str, +) -> None: + __tracebackhide__ = True + + tags = tags_from_filename(path) + + if types and not tags.issuperset(types): + pytest.fail(f"types={types} did not match '{path}' (expected match)") + + if types_or and not tags.intersection(types_or): + pytest.fail(f"types_or={types_or} did not match '{path}' (expected match)") + + def get_hook_config(hookid): config_file = HERE.parent.parent / ".pre-commit-hooks.yaml" with open(config_file) as fp: @@ -182,6 +199,7 @@ def get_hook_config(hookid): def test_hook_matches_known_good_paths(hookid, filepath): config = get_hook_config(hookid) check_pattern_match(config["files"], filepath) + check_types_match(config.get("types", []), config.get("types_or", []), filepath) @pytest.mark.parametrize( diff --git a/tests/acceptance/test_nonjson_instance_files.py b/tests/acceptance/test_nonjson_instance_files.py new file mode 100644 index 000000000..5a15907a7 --- /dev/null +++ b/tests/acceptance/test_nonjson_instance_files.py @@ -0,0 +1,60 @@ +import json + +import pytest + +from check_jsonschema.parsers.json5 import ENABLED as JSON5_ENABLED + +SIMPLE_SCHEMA = { + "$schema": "http://json-schema.org/draft-07/schema", + "properties": { + "title": {"type": "string"}, + }, + "additionalProperties": False, +} +PASSING_DOCUMENT = """ +// a comment +{"title": "doc one"} +""" +FAILING_DOCUMENT = """ +// a comment +{"title": 2} +""" + + +@pytest.mark.skipif(not JSON5_ENABLED, reason="test requires json5") +@pytest.mark.parametrize("passing_data", [True, False]) +def test_json5_filetype_forced_on_json_suffixed_instance( + run_line, tmp_path, passing_data +): + schemafile = tmp_path / "schema.json" + schemafile.write_text(json.dumps(SIMPLE_SCHEMA)) + + doc = tmp_path / "doc.json" + if passing_data: + doc.write_text(PASSING_DOCUMENT) + else: + doc.write_text(FAILING_DOCUMENT) + + result = run_line( + [ + "check-jsonschema", + "--force-filetype", + "json5", + "--schemafile", + str(schemafile), + str(doc), + ] + ) + assert result.exit_code == (0 if passing_data else 1) + + # but even in the passing case, a rerun without the force flag will fail + if passing_data: + result_without_filetype = run_line( + [ + "check-jsonschema", + "--schemafile", + str(schemafile), + str(doc), + ] + ) + assert result_without_filetype.exit_code == 1 diff --git a/tests/unit/cli/test_annotations.py b/tests/unit/cli/test_annotations.py index 1ab41aa51..24cab0152 100644 --- a/tests/unit/cli/test_annotations.py +++ b/tests/unit/cli/test_annotations.py @@ -18,5 +18,6 @@ def test_annotations_match_click_params(): # force default_filetype to be a Literal including `json5`, which is only # included in the choices if a parser is installed "default_filetype": t.Literal["json", "yaml", "toml", "json5"], + "force_filetype": t.Literal["json", "yaml", "toml", "json5"] | None, }, ) diff --git a/tests/unit/test_instance_loader.py b/tests/unit/test_instance_loader.py index fa9c3e91c..b7dc25667 100644 --- a/tests/unit/test_instance_loader.py +++ b/tests/unit/test_instance_loader.py @@ -79,13 +79,49 @@ def test_instanceloader_yaml_data(tmp_path, filename, default_filetype, open_wid ], ) def test_instanceloader_toml_data(tmp_path, filename, default_filetype, open_wide): - f = tmp_path / "foo.toml" + f = tmp_path / filename f.write_text('[foo]\nbar = "baz"\n') loader = InstanceLoader(open_wide(f), default_filetype=default_filetype) data = list(loader.iter_files()) assert data == [(str(f), {"foo": {"bar": "baz"}})] +@pytest.mark.parametrize( + "filename, force_filetype", + [ + ("foo.test", "toml"), + ("foo", "toml"), + ], +) +def test_instanceloader_force_filetype_toml( + tmp_path, filename, force_filetype, open_wide +): + f = tmp_path / filename + f.write_text('[foo]\nbar = "baz"\n') + loader = InstanceLoader(open_wide(f), force_filetype=force_filetype) + data = list(loader.iter_files()) + assert data == [(str(f), {"foo": {"bar": "baz"}})] + + +@pytest.mark.skipif(not JSON5_ENABLED, reason="test requires json5") +@pytest.mark.parametrize( + "filename, force_filetype", + [ + ("foo.test", "json5"), + ("foo.json", "json5"), + ], +) +def test_instanceloader_force_filetype_json( + tmp_path, filename, force_filetype, open_wide +): + f = tmp_path / filename + f.write_text("// a comment\n{}") + loader = InstanceLoader(open_wide(f), force_filetype=force_filetype) + data = list(loader.iter_files()) + print(data) + assert data == [(str(f), {})] + + def test_instanceloader_unknown_type_nonjson_content(tmp_path, open_wide): f = tmp_path / "foo" # no extension here f.write_text("a:b") # non-json data (cannot be detected as JSON)