diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 9b5ad6f98..07c5986e5 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -141,6 +141,20 @@ )$ types: [yaml] +# this hook is autogenerated from a script +# to modify this hook, update `src/check_jsonschema/catalog.py` +# and run `make generate-hooks` or `tox run -e generate-hooks-config` +- id: check-github-issue-config + name: Validate GitHub issue config + description: 'Validate GitHub issue config against the schema provided by SchemaStore' + entry: check-jsonschema --builtin-schema vendor.github-issue-config + language: python + files: > + (?x)^( + ^\.github/ISSUE_TEMPLATE/config\.yml$ + )$ + types: [yaml] + # this hook is autogenerated from a script # to modify this hook, update `src/check_jsonschema/catalog.py` # and run `make generate-hooks` or `tox run -e generate-hooks-config` diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8c9b797d9..9e587915a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,6 +10,7 @@ Unreleased .. vendor-insert-here +- Add GitHub issue config schema and pre-commit hook (:issue:`589`). - Add GitHub issue form schema and pre-commit hook (:issue:`588`). 0.33.3 diff --git a/docs/precommit_usage.rst b/docs/precommit_usage.rst index a96ef3676..e22475ed5 100644 --- a/docs/precommit_usage.rst +++ b/docs/precommit_usage.rst @@ -183,6 +183,20 @@ Validate GitHub Actions against the schema provided by SchemaStore - id: check-github-actions +``check-github-issue-config`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Validate GitHub issue config against the schema provided by SchemaStore + +.. code-block:: yaml + :caption: example config + + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.33.3 + hooks: + - id: check-github-issue-config + + ``check-github-issue-forms`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/usage.rst b/docs/usage.rst index b6445c8e5..8d8baf5c3 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -96,6 +96,7 @@ SchemaStore and other sources: - ``vendor.dependabot`` - ``vendor.drone-ci`` - ``vendor.github-actions`` +- ``vendor.github-issue-config`` - ``vendor.github-issue-forms`` - ``vendor.github-workflows`` - ``vendor.gitlab-ci`` diff --git a/src/check_jsonschema/builtin_schemas/vendor/github-issue-config.json b/src/check_jsonschema/builtin_schemas/vendor/github-issue-config.json new file mode 100644 index 000000000..b46556bb0 --- /dev/null +++ b/src/check_jsonschema/builtin_schemas/vendor/github-issue-config.json @@ -0,0 +1,45 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://json.schemastore.org/github-issue-config.json", + "$comment": "https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository#configuring-the-template-chooser", + "properties": { + "blank_issues_enabled": { + "description": "Specify whether allow blank issue creation\nhttps://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository#configuring-the-template-chooser", + "type": "boolean" + }, + "contact_links": { + "title": "contact links", + "description": "Contact links\nhttps://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository#configuring-the-template-chooser", + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "required": ["name", "url", "about"], + "properties": { + "name": { + "description": "A link title\nhttps://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository#configuring-the-template-chooser", + "type": "string", + "minLength": 1, + "examples": ["Sample name"] + }, + "url": { + "description": "A link URL\nhttps://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository#configuring-the-template-chooser", + "type": "string", + "pattern": "^https?://", + "examples": ["https://sample/url"] + }, + "about": { + "description": "A link description\nhttps://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository#configuring-the-template-chooser", + "type": "string", + "minLength": 1, + "examples": ["Sample description"] + } + }, + "additionalProperties": false + } + } + }, + "additionalProperties": false, + "title": "GitHub issue template chooser config file schema", + "type": "object" +} diff --git a/src/check_jsonschema/builtin_schemas/vendor/sha256/github-issue-config.sha256 b/src/check_jsonschema/builtin_schemas/vendor/sha256/github-issue-config.sha256 new file mode 100644 index 000000000..97c518fc5 --- /dev/null +++ b/src/check_jsonschema/builtin_schemas/vendor/sha256/github-issue-config.sha256 @@ -0,0 +1 @@ +899e718f4b8c965413b07ec63d8f089792a10c42409270db560b9a7ec0224a5a \ No newline at end of file diff --git a/src/check_jsonschema/catalog.py b/src/check_jsonschema/catalog.py index faedf25f7..57a2f1a87 100644 --- a/src/check_jsonschema/catalog.py +++ b/src/check_jsonschema/catalog.py @@ -141,6 +141,16 @@ def _githubusercontent_url(owner: str, repo: str, ref: str, path: str) -> str: "types": "yaml", }, }, + "github-issue-config": { + "url": "https://www.schemastore.org/github-issue-config.json", + "hook_config": { + "name": "Validate GitHub issue config", + "files": [ + r"^\.github/ISSUE_TEMPLATE/config\.yml$", + ], + "types": "yaml", + }, + }, "github-issue-forms": { "url": "https://www.schemastore.org/github-issue-forms.json", "hook_config": { diff --git a/tests/acceptance/test_hook_file_matches.py b/tests/acceptance/test_hook_file_matches.py index c96211933..d142e5f61 100644 --- a/tests/acceptance/test_hook_file_matches.py +++ b/tests/acceptance/test_hook_file_matches.py @@ -123,6 +123,13 @@ def get_hook_config(hookid): ), "bad": (".github/actions/foo/other.yaml",), }, + "check-github-issue-config": { + "good": (".github/ISSUE_TEMPLATE/config.yml",), + "bad": ( + ".github/ISSUE_TEMPLATE/config.yaml", + ".github/ISSUE_TEMPLATE/bug.yml", + ), + }, "check-github-issue-forms": { "good": ( ".github/ISSUE_TEMPLATE/feature.yaml", diff --git a/tests/example-files/hooks/positive/github-issue-config/config.yml b/tests/example-files/hooks/positive/github-issue-config/config.yml new file mode 100644 index 000000000..f06cf71a1 --- /dev/null +++ b/tests/example-files/hooks/positive/github-issue-config/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: Questions & Discussions + url: https://github.com/Flexget/Flexget/discussions + about: Use GitHub discussions for message-board style questions and discussions + - name: Report an issue with Web UI + url: https://github.com/Flexget/webui/issues/new/choose + about: Please report issues for our Web UI in the Flexget/webui repository