Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,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-discussion
name: Validate GitHub discussion
description: 'Validate GitHub discussion against the schema provided by SchemaStore'
entry: check-jsonschema --builtin-schema vendor.github-discussion
language: python
files: >
(?x)^(
^\.github/DISCUSSION_TEMPLATE/.+\.ya?ml$
)$
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`
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Unreleased

- Update vendored schemas: buildkite, gitlab-ci, mergify, renovate, snapcraft
(2025-11-23)
- Add GitHub Discussion category forms schema and pre-commit hook. Thanks :user:`edgarrmondragon`! (:pr:`626`)

0.35.0
------
Expand Down
14 changes: 14 additions & 0 deletions docs/precommit_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,20 @@ Validate GitHub Actions against the schema provided by SchemaStore
- id: check-github-actions


``check-github-discussion``
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Validate GitHub discussion against the schema provided by SchemaStore

.. code-block:: yaml
:caption: example config

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.35.0
hooks:
- id: check-github-discussion


``check-github-issue-config``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
1 change: 1 addition & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ SchemaStore and other sources:
- ``vendor.dependabot``
- ``vendor.drone-ci``
- ``vendor.github-actions``
- ``vendor.github-discussion``
- ``vendor.github-issue-config``
- ``vendor.github-issue-forms``
- ``vendor.github-workflows``
Expand Down
63 changes: 63 additions & 0 deletions src/check_jsonschema/builtin_schemas/vendor/github-discussion.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://json.schemastore.org/github-discussion.json",
"$comment": "https://docs.github.com/en/discussions/managing-discussions-for-your-community/syntax-for-discussion-category-forms",
"additionalProperties": false,
"properties": {
"title": {
"description": "A default title that will be pre-populated in the discussion submission form.",
"type": "string"
},
"labels": {
"description": "Labels that will automatically be added to discussions created with this template.",
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
"body": {
"description": "Definition of the input types in the discussion form",
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["markdown", "textarea", "input", "dropdown", "checkboxes"]
},
"attributes": {
"type": "object",
"properties": {
"label": {
"type": "string"
},
"description": {
"type": "string"
},
"placeholder": {
"type": "string"
}
}
},
"validations": {
"type": "object",
"properties": {
"required": {
"type": "boolean"
}
}
}
}
}
}
},
"required": ["body"],
"type": "object"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14cf1562338184fa10109cfb4c7855e7070ea6339e5bc3bc83bdb6e1088aca4f
10 changes: 10 additions & 0 deletions src/check_jsonschema/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ def _githubusercontent_url(owner: str, repo: str, ref: str, path: str) -> str:
"types": "yaml",
},
},
"github-discussion": {
"url": "https://www.schemastore.org/github-discussion.json",
"hook_config": {
"name": "Validate GitHub discussion",
"files": [
r"^\.github/DISCUSSION_TEMPLATE/.+\.ya?ml$",
],
"types": "yaml",
},
},
"github-issue-config": {
"url": "https://www.schemastore.org/github-issue-config.json",
"hook_config": {
Expand Down
10 changes: 10 additions & 0 deletions tests/acceptance/test_hook_file_matches.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ def get_hook_config(hookid):
),
"bad": (".github/actions/foo/other.yaml",),
},
"check-github-discussion": {
"good": (
".github/DISCUSSION_TEMPLATE/announcements.yaml",
".github/DISCUSSION_TEMPLATE/office-hours.yml",
),
"bad": (
".github/discussion.yml",
".github/DISCUSSION_TEMPLATE/not-a-discussion.txt",
),
},
"check-github-issue-config": {
"good": (".github/ISSUE_TEMPLATE/config.yml",),
"bad": (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
title: "Office Hours"
not-a-valid-field: "This field is not allowed."
labels:
- "office-hours"
body:
- type: markdown
attributes:
value: "The agenda for this week's office hours is as follows: ..."
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: "Office Hours"
labels:
- "office-hours"
body:
- type: markdown
attributes:
value: "The agenda for this week's office hours is as follows: ..."
Loading