Skip to content

Commit 7eea56d

Browse files
committed
feat(pre-commit): add GitHub issue config schema and pre-commit hook
1 parent dba36bf commit 7eea56d

File tree

9 files changed

+101
-0
lines changed

9 files changed

+101
-0
lines changed

.pre-commit-hooks.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,20 @@
141141
)$
142142
types: [yaml]
143143

144+
# this hook is autogenerated from a script
145+
# to modify this hook, update `src/check_jsonschema/catalog.py`
146+
# and run `make generate-hooks` or `tox run -e generate-hooks-config`
147+
- id: check-github-issue-config
148+
name: Validate GitHub issue config
149+
description: 'Validate GitHub issue config against the schema provided by SchemaStore'
150+
entry: check-jsonschema --builtin-schema vendor.github-issue-config
151+
language: python
152+
files: >
153+
(?x)^(
154+
^\.github/ISSUE_TEMPLATE/config\.yml$
155+
)$
156+
types: [yaml]
157+
144158
# this hook is autogenerated from a script
145159
# to modify this hook, update `src/check_jsonschema/catalog.py`
146160
# and run `make generate-hooks` or `tox run -e generate-hooks-config`

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Unreleased
1010

1111
.. vendor-insert-here
1212
13+
- Add GitHub issue config schema and pre-commit hook (:issue:`589`).
1314
- Add GitHub issue form schema and pre-commit hook (:issue:`588`).
1415

1516
0.33.3

docs/precommit_usage.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,20 @@ Validate GitHub Actions against the schema provided by SchemaStore
183183
- id: check-github-actions
184184
185185
186+
``check-github-issue-config``
187+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
188+
189+
Validate GitHub issue config against the schema provided by SchemaStore
190+
191+
.. code-block:: yaml
192+
:caption: example config
193+
194+
- repo: https://github.com/python-jsonschema/check-jsonschema
195+
rev: 0.33.3
196+
hooks:
197+
- id: check-github-issue-config
198+
199+
186200
``check-github-issue-forms``
187201
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
188202

docs/usage.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ SchemaStore and other sources:
9696
- ``vendor.dependabot``
9797
- ``vendor.drone-ci``
9898
- ``vendor.github-actions``
99+
- ``vendor.github-issue-config``
99100
- ``vendor.github-issue-forms``
100101
- ``vendor.github-workflows``
101102
- ``vendor.gitlab-ci``
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://json.schemastore.org/github-issue-config.json",
4+
"$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",
5+
"properties": {
6+
"blank_issues_enabled": {
7+
"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",
8+
"type": "boolean"
9+
},
10+
"contact_links": {
11+
"title": "contact links",
12+
"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",
13+
"type": "array",
14+
"minItems": 1,
15+
"items": {
16+
"type": "object",
17+
"required": ["name", "url", "about"],
18+
"properties": {
19+
"name": {
20+
"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",
21+
"type": "string",
22+
"minLength": 1,
23+
"examples": ["Sample name"]
24+
},
25+
"url": {
26+
"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",
27+
"type": "string",
28+
"pattern": "^https?://",
29+
"examples": ["https://sample/url"]
30+
},
31+
"about": {
32+
"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",
33+
"type": "string",
34+
"minLength": 1,
35+
"examples": ["Sample description"]
36+
}
37+
},
38+
"additionalProperties": false
39+
}
40+
}
41+
},
42+
"additionalProperties": false,
43+
"title": "GitHub issue template chooser config file schema",
44+
"type": "object"
45+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
899e718f4b8c965413b07ec63d8f089792a10c42409270db560b9a7ec0224a5a

src/check_jsonschema/catalog.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ def _githubusercontent_url(owner: str, repo: str, ref: str, path: str) -> str:
141141
"types": "yaml",
142142
},
143143
},
144+
"github-issue-config": {
145+
"url": "https://www.schemastore.org/github-issue-config.json",
146+
"hook_config": {
147+
"name": "Validate GitHub issue config",
148+
"files": [
149+
r"^\.github/ISSUE_TEMPLATE/config\.yml$",
150+
],
151+
"types": "yaml",
152+
},
153+
},
144154
"github-issue-forms": {
145155
"url": "https://www.schemastore.org/github-issue-forms.json",
146156
"hook_config": {

tests/acceptance/test_hook_file_matches.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ def get_hook_config(hookid):
123123
),
124124
"bad": (".github/actions/foo/other.yaml",),
125125
},
126+
"check-github-issue-config": {
127+
"good": (".github/ISSUE_TEMPLATE/config.yml",),
128+
"bad": (
129+
".github/ISSUE_TEMPLATE/config.yaml",
130+
".github/ISSUE_TEMPLATE/bug.yml",
131+
),
132+
},
126133
"check-github-issue-forms": {
127134
"good": (
128135
".github/ISSUE_TEMPLATE/feature.yaml",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Questions & Discussions
4+
url: https://github.com/Flexget/Flexget/discussions
5+
about: Use GitHub discussions for message-board style questions and discussions
6+
- name: Report an issue with Web UI
7+
url: https://github.com/Flexget/webui/issues/new/choose
8+
about: Please report issues for our Web UI in the Flexget/webui repository

0 commit comments

Comments
 (0)