Skip to content

Commit d216058

Browse files
shenxianpengclaude
andcommitted
fix(install): start each invocation from an empty work dir, wheels only; doc fixes
- action.yml removes $RUNNER_TEMP/commit-check-action before use, so a second invocation in one job cannot leave two commit_check wheels for the attestation glob; pip download takes --only-binary=:all: so a platform without wheels fails at download time with pip's message instead of at the offline install. - README comparison table: the Action's title and author checks are opt-in; the GitHub App reports one check run per commit and posts no comment. - Workflow A, docs and README write report.md with printf '%s' so the posted comment is byte-identical to the report output. - Workflow B tolerates a missing artifact (A's install failed) with a notice instead of a red run. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018xYa7m3qup5wyN5MaXFgf6
1 parent f1849d9 commit d216058

5 files changed

Lines changed: 22 additions & 8 deletions

File tree

‎README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ can see.
106106
| | GitHub Action (this repo) | [pre-commit hook](https://github.com/commit-check/commit-check#use-with-pre-commit) | [Commit Check GitHub App](https://github.com/marketplace/commit-check) |
107107
|---|---|---|---|
108108
| **Where it runs** | In your workflow, on the runner, after the push | On the contributor's machine, at `git commit` / `git push` | Hosted by commit-check; installed on the repository, no workflow file |
109-
| **What it checks** | Every PR commit, the PR title, branch and author; renders a job summary, annotations, a PR comment and the `result` / `report` outputs | Message (`commit-msg` stage), branch, author; tag, force-push and files (`pre-push`) — one commit at a time, before it exists | The pull request's commits, title and branch, reported on the pull request |
110-
| **When to pick it** | You want enforcement in CI that a contributor cannot skip, per-rule outputs for later steps, or you run on GitHub Enterprise Server / need `CCHK_*` overrides | You want the fastest feedback and to stop bad commits before they are pushed; pair it with the Action, since hooks are opt-in | You want zero YAML and no Actions minutes; fork PRs get comments without the [two-workflow pattern](docs/fork-pr-comments.md) |
109+
| **What it checks** | Every PR commit's message, plus the PR title, branch and author checks you enable; renders a job summary, annotations, a PR comment and the `result` / `report` outputs | Message (`commit-msg` stage), branch, author; tag, force-push and files (`pre-push`) — one commit at a time, before it exists | Every commit of a push or pull request: message, branch, author (the PR title only in squash mode); reported as one **Commit Check** check run per commit |
110+
| **When to pick it** | You want enforcement in CI that a contributor cannot skip, per-rule outputs for later steps, or you run on GitHub Enterprise Server / need `CCHK_*` overrides | You want the fastest feedback and to stop bad commits before they are pushed; pair it with the Action, since hooks are opt-in | You want zero YAML and no Actions minutes; fork PRs get a check run without the [two-workflow pattern](docs/fork-pr-comments.md) (no PR comment, though) |
111111

112112
Most teams pair the pre-commit hook (fast, local) with the Action (enforced):
113113
the hook catches a bad message before it is pushed, and the Action is why CI
@@ -330,7 +330,7 @@ action's own, that comment is later found and edited in place like any other.
330330
if: always() && steps.commit-check.outputs.report != ''
331331
env:
332332
REPORT: ${{ steps.commit-check.outputs.report }}
333-
run: printf '%s\n' "$REPORT" > report.md
333+
run: printf '%s' "$REPORT" > report.md
334334
```
335335

336336
Treat `report` as text to display, not data to parse; `result` is the contract

‎action.yml‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ runs:
7070
# caller's checkout: a later `git status`, linter or upload-artifact step
7171
# must not see our venv or wheels.
7272
WORK="$RUNNER_TEMP/commit-check-action"
73+
rm -rf "$WORK" # a second invocation in the same job starts clean, so the wheel glob below matches exactly one file
7374
mkdir -p "$WORK/wheels"
7475
$PYTHON_CMD -m venv "$WORK/venv"
7576
if [[ "$RUNNER_OS" == "Windows" ]]; then
@@ -78,8 +79,10 @@ runs:
7879
source "$WORK/venv/bin/activate"
7980
fi
8081
81-
# One download of the pinned closure, into the scratch dir.
82-
$PYTHON_CMD -m pip download -q -d "$WORK/wheels" -r "$GITHUB_ACTION_PATH/requirements.txt"
82+
# One download of the pinned closure, into the scratch dir. Wheels only:
83+
# the offline install below cannot build an sdist, so a platform without
84+
# binary wheels fails here, with pip's message, rather than later.
85+
$PYTHON_CMD -m pip download -q --only-binary=:all: -d "$WORK/wheels" -r "$GITHUB_ACTION_PATH/requirements.txt"
8386
8487
# Verify the commit-check wheel's build provenance (PyGithub and the
8588
# transitive wheels are pinned but not attested; see README "Runner requirements").

‎docs/fork-pr-comments.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
PR_NUMBER: ${{ github.event.number }}
9292
run: |
9393
mkdir -p commit-check-result
94-
printf '%s\n' "$REPORT" > commit-check-result/report.md
94+
printf '%s' "$REPORT" > commit-check-result/report.md
9595
printf '%s\n' "$RESULT" > commit-check-result/result.json
9696
printf '%s\n' "$PR_NUMBER" > commit-check-result/pr-number
9797
- uses: actions/upload-artifact@v4
@@ -125,11 +125,14 @@ jobs:
125125
# Download by run id: the PR number travels inside the artifact because
126126
# github.event.workflow_run.pull_requests is empty for fork PRs.
127127
- uses: actions/download-artifact@v4
128+
id: download
129+
continue-on-error: true # no artifact when A's install failed: nothing to post
128130
with:
129131
name: commit-check-result
130132
run-id: ${{ github.event.workflow_run.id }}
131133
github-token: ${{ github.token }}
132134
- name: Post or update the PR comment
135+
if: steps.download.outcome == 'success'
133136
uses: actions/github-script@v7
134137
with:
135138
script: |

‎examples/commit-check-workflow-a.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
PR_NUMBER: ${{ github.event.number }}
4545
run: |
4646
mkdir -p commit-check-result
47-
printf '%s\n' "$REPORT" > commit-check-result/report.md
47+
printf '%s' "$REPORT" > commit-check-result/report.md
4848
printf '%s\n' "$RESULT" > commit-check-result/result.json
4949
printf '%s\n' "$PR_NUMBER" > commit-check-result/pr-number
5050
- uses: actions/upload-artifact@v4

‎examples/commit-check-workflow-b.yml‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,22 @@ jobs:
2727
actions: read # needed to download another run's artifact
2828
steps:
2929
# Download by run id: the PR number travels inside the artifact because
30-
# github.event.workflow_run.pull_requests is empty for fork PRs.
30+
# github.event.workflow_run.pull_requests is empty for fork PRs. The
31+
# artifact is missing when Workflow A never got as far as running the
32+
# checks (its install step failed); that is A's failure to show, not B's.
3133
- uses: actions/download-artifact@v4
34+
id: download
35+
continue-on-error: true
3236
with:
3337
name: commit-check-result
3438
run-id: ${{ github.event.workflow_run.id }}
3539
github-token: ${{ github.token }}
3640

41+
- if: steps.download.outcome != 'success'
42+
run: echo "::notice::Workflow A (run ${{ github.event.workflow_run.id }}) uploaded no commit-check-result artifact; nothing to post."
43+
3744
- name: Post or update the PR comment
45+
if: steps.download.outcome == 'success'
3846
uses: actions/github-script@v7
3947
with:
4048
script: |

0 commit comments

Comments
 (0)