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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ runners need a few tools — see [Good to know](#good-to-know).
| `author-name` | `false` | Check each commit's author name |
| `author-email` | `false` | Check each commit's author email |
| `pr-title` | `false` | Check the pull request title against Conventional Commits — the one that matters for squash merges. Pull request events only |
| `pr-body` | `false` | Check the pull request description against the AI rules of `cchk.toml` (`ai_attribution`) only. Pull request events only |
| `pr-body-ai-attribution` | `false` | Check the pull request description against the AI rules of `cchk.toml` (`ai_attribution`) only. Pull request events only |
| `ai-label` | `false` | Label the pull request when an AI tool wrote any of it (a commit, the description, or an agent's app that opened it): `true` for `ai-assisted`, or the label's name. Labels are only added, never removed. Needs `pull-requests: write`; skipped on fork pull requests under `pull_request` |
| `pr-comments` | `false` | Post the report as a pull request comment, edited in place on later runs. Needs `pull-requests: write`; skipped on fork pull requests |
| `job-summary` | `true` | Write the report to the job summary |
| `dry-run` | `false` | Report failures as warnings and always exit 0 |

> [!TIP]
> `pull_request` does not fire when a title or description is edited. With
> `pr-title` or `pr-body`, add `types: [opened, synchronize, reopened, edited]`
> `pr-title` or `pr-body-ai-attribution`, add `types: [opened, synchronize, reopened, edited]`
> to re-check an edited pull request.

## Configuration
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ inputs:
description: check pull request title following conventional commits
required: false
default: false
pr-body:
pr-body-ai-attribution:
Comment thread
shenxianpeng marked this conversation as resolved.
Resolved
description: check the pull request description against the AI attribution rules (ai_attribution in cchk.toml)
required: false
default: false
Expand Down Expand Up @@ -118,6 +118,6 @@ runs:
JOB_SUMMARY: ${{ inputs.job-summary }}
PR_COMMENTS: ${{ inputs.pr-comments }}
PR_TITLE: ${{ inputs.pr-title }}
PR_BODY: ${{ inputs.pr-body }}
PR_BODY_AI_ATTRIBUTION: ${{ inputs.pr-body-ai-attribution }}
AI_LABEL: ${{ inputs.ai-label }}
GITHUB_TOKEN: ${{ github.token }}
12 changes: 6 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _reconfigure_io() -> None:
JOB_SUMMARY_ENABLED = env_flag("JOB_SUMMARY")
PR_COMMENTS_ENABLED = env_flag("PR_COMMENTS")
PR_TITLE_ENABLED = env_flag("PR_TITLE")
PR_BODY_ENABLED = env_flag("PR_BODY")
PR_BODY_AI_ATTRIBUTION_ENABLED = env_flag("PR_BODY_AI_ATTRIBUTION")

#: The label ``ai-label: true`` puts on a pull request that an AI tool wrote.
DEFAULT_AI_LABEL = "ai-assisted"
Expand Down Expand Up @@ -254,7 +254,7 @@ def log_env_vars():
"JOB_SUMMARY",
"PR_COMMENTS",
"PR_TITLE",
"PR_BODY",
"PR_BODY_AI_ATTRIBUTION",
"AI_LABEL",
):
value = os.getenv(name, "false")
Expand Down Expand Up @@ -464,7 +464,7 @@ def get_pr_opener_tool() -> str | None:


#: The AI tools found in the pull request description when it was read for
#: the label only (``ai-label`` without ``pr-body``), so it is no scope.
#: the label only (``ai-label`` without ``pr-body-ai-attribution``), so it is no scope.
PR_BODY_AI_TOOLS: list[str] = []


Expand Down Expand Up @@ -789,7 +789,7 @@ def run_commit_check() -> tuple[int, list[ScopeResult]]:

Checks are evaluated in order:
1. PR title (when ``pr-title: true`` and in a PR event)
2. PR description, AI rules only (when ``pr-body: true`` and in a PR
2. PR description, AI rules only (when ``pr-body-ai-attribution: true`` and in a PR
event; with only ``ai-label`` set it is read for the label, and no
scope is reported)
3. Individual PR commit messages (when ``message: true`` and in a PR event)
Expand All @@ -807,13 +807,13 @@ def run_commit_check() -> tuple[int, list[ScopeResult]]:
results.append(check_scope("PR title", ["--message"], input_text=pr_title))

# ---- 2. PR description ------------------------------------------------
if (PR_BODY_ENABLED or ai_label_name()) and is_pr_event():
if (PR_BODY_AI_ATTRIBUTION_ENABLED or ai_label_name()) and is_pr_event():
pr_body = get_pr_body()
if pr_body:
scope = check_scope(
"PR description", ["--ai-attribution-only"], input_text=pr_body
)
if PR_BODY_ENABLED:
if PR_BODY_AI_ATTRIBUTION_ENABLED:
results.append(scope)
else:
PR_BODY_AI_TOOLS[:] = scope.ai_tools
Expand Down
4 changes: 2 additions & 2 deletions main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def test_every_input_is_logged_as_a_debug_command(self):
"::debug::JOB_SUMMARY=false",
"::debug::PR_COMMENTS=false",
"::debug::PR_TITLE=false",
"::debug::PR_BODY=false",
"::debug::PR_BODY_AI_ATTRIBUTION=false",
"::debug::AI_LABEL=false",
],
)
Expand Down Expand Up @@ -3699,7 +3699,7 @@ def _run(self, pr_body_enabled, ai_label, body="Adds a parser."):
)
with (
patch("main.PR_TITLE_ENABLED", False),
patch("main.PR_BODY_ENABLED", pr_body_enabled),
patch("main.PR_BODY_AI_ATTRIBUTION_ENABLED", pr_body_enabled),
patch.dict(os.environ, {"AI_LABEL": ai_label}),
patch("main.MESSAGE_ENABLED", False),
patch("main.BRANCH_ENABLED", False),
Expand Down
Loading