Validate (lint) GitHub issues.
Project description
gh-issue-validator
gh-issue-validator is a customizable "linter" for issues in a GitHub repository.
It ensures issues conform to a specified format.
Installation
You typically wouldn't install this package on your local machine. It expects to be used in GitHub Actions.
Usage
Write your validation script
To get started, you'll need to write a validation script.
We suggest creating it at .github/issue_validator.py.
At the top of the script, include PEP723 metadata to enable automated installation of
dependencies.
At minimum, we'll need to add this project, gh-issue-validator, as a dependency.
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "gh-issue-validator",
# ]
# ///
import typing
from gh_issue_validator import ValidationCheck, ValidationIssue, ValidationReport, validate
from gh_issue_validator.checks.headings import CheckMissingHeadings, HeadingRequirement
from gh_issue_validator.types import SegmentsMap
# Optional: Create your own validator based on the ValidationCheck ABC.
class ProblemStatementQualityCheck(ValidationCheck):
"""Reject problem statements that are just a URL."""
@typing.override
def check(self, *, segments: SegmentsMap, report: ValidationReport) -> None:
heading_to_check = "Problem statement"
content = segments.get(heading_to_check, [])
if not content:
return # Empty content is handled by first-party CheckWordCount check.
text = str(content).strip()
if text.startswith("http") and " " not in text:
# Our custom "issue" to report:
report.add_issue(ValidationIssue(
code="problem-statement-is-url",
message="Problem statement should be a description, not just a URL.",
heading=heading_to_check,
))
HEADING_REQUIREMENTS =[
{"heading": "Problem statement", "min_words": 10},
{"heading": "Proposed solution", "min_words": 5, "max_words": 100},
]
validate(checks=[
CheckMissingHeadings(requirements=HEADING_REQUIREMENTS),
CheckWordCount(requirements=HEADING_REQUIREMENTS)
ProblemStatementQualityCheck(),
])
Call it from GitHub Actions
on:
issues:
types:
- "opened"
- "edited"
- "labeled"
- "unlabeled"
jobs:
validate:
# Filter for only issues labeled as "initiative"
if: "contains(github.event.issue.labels.*.name, 'initiative')"
runs-on: "ubuntu-latest"
permissions:
issues: "write"
steps:
- uses: "actions/checkout@v4"
- uses: "astral-sh/setup-uv@v5"
- run: "uv run .github/issue_validator.py"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_ISSUE_NUMBER: "${{ github.event.issue.number }}"
Acknowledgement
This validator is inspired by the https://github.com/2i2c-org/initiatives project.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gh_issue_validator-0.0.1.tar.gz.
File metadata
- Download URL: gh_issue_validator-0.0.1.tar.gz
- Upload date:
- Size: 68.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47a0c49000857b70ef35f3ad5dfe6328f50a7238b7533b375ae78965aa63f3bb
|
|
| MD5 |
f8b149a1ee1c692e5da9120bca9397ef
|
|
| BLAKE2b-256 |
9b7db8c755abf90d6b5d8ea2ed8a610ef011d85faa369460d6cb5e8e9914b721
|
Provenance
The following attestation bundles were made for gh_issue_validator-0.0.1.tar.gz:
Publisher:
publish.yml on mfisher87/gh-issue-validator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gh_issue_validator-0.0.1.tar.gz -
Subject digest:
47a0c49000857b70ef35f3ad5dfe6328f50a7238b7533b375ae78965aa63f3bb - Sigstore transparency entry: 1280527932
- Sigstore integration time:
-
Permalink:
mfisher87/gh-issue-validator@eacbacb26ae5b4f6ddbc254de8f63197fe1ed28e -
Branch / Tag:
refs/tags/0.0.1 - Owner: https://github.com/mfisher87
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@eacbacb26ae5b4f6ddbc254de8f63197fe1ed28e -
Trigger Event:
release
-
Statement type:
File details
Details for the file gh_issue_validator-0.0.1-py3-none-any.whl.
File metadata
- Download URL: gh_issue_validator-0.0.1-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba5487f77d9665355d9e20622cebf590eded90f15c9d24a48b2fe0591dbe12cc
|
|
| MD5 |
8dc12d54f78e0e49adf6237ae8f532bb
|
|
| BLAKE2b-256 |
6f85afcffee8ab7e3877b59a3d96b456e1d3310370bfbc93adac3e4e11f2f2f6
|
Provenance
The following attestation bundles were made for gh_issue_validator-0.0.1-py3-none-any.whl:
Publisher:
publish.yml on mfisher87/gh-issue-validator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gh_issue_validator-0.0.1-py3-none-any.whl -
Subject digest:
ba5487f77d9665355d9e20622cebf590eded90f15c9d24a48b2fe0591dbe12cc - Sigstore transparency entry: 1280527936
- Sigstore integration time:
-
Permalink:
mfisher87/gh-issue-validator@eacbacb26ae5b4f6ddbc254de8f63197fe1ed28e -
Branch / Tag:
refs/tags/0.0.1 - Owner: https://github.com/mfisher87
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@eacbacb26ae5b4f6ddbc254de8f63197fe1ed28e -
Trigger Event:
release
-
Statement type: