Skip to content

feat: read the commits with the token of the workflow AND fix: fail when the commits cannot be retrieved AND fix: read every page of the commits of a pull request - #7

Merged
javier-godoy merged 5 commits into
masterfrom
fix/read-all-commits
Sep 11, 2026
Merged

feat: read the commits with the token of the workflow AND fix: fail when the commits cannot be retrieved AND fix: read every page of the commits of a pull request#7
javier-godoy merged 5 commits into
masterfrom
fix/read-all-commits

Conversation

@javier-godoy

@javier-godoy javier-godoy commented Sep 10, 2026

Copy link
Copy Markdown
Member

Three defects in how the commits of a pull request are read, all of which fail open or fail
intermittently, extracted from #3 so that they can be merged on their own.

Changes

fix: fail when the commits cannot be retrieved A failure to fetch the commits was turned into an empty list, indistinguishable from a pull request whose commits are all valid, so a rate limited or failing request was reported as a success. The failure is now propagated and fails the action. Close #4
feat: read the commits with the token of the workflow The request was unauthenticated, which GitHub limits to 60 requests per hour per IP address, shared with unrelated jobs on the same runner. A new input defaults to ${{ github.token }}, so no caller changes; an empty value keeps the anonymous request and warns. Close #8
fix: read every page of the commits of a pull request The request asked for no page size, received the default of 30 commits and read that page alone, so a longer pull request was checked only in part. It now asks for 100 at a time and follows the Link header. Close #5
build: add typescript devDependency required by ncc npm run build fails on a clean install without it, because ncc 0.36.1 resolves the TypeScript compiler from the project.
build: rebuild the dist bundle Rebuilt from the current sources, in its own commit.

Verification

npm test passes (3/3).

javier-godoy/test-repo#23 checks this branch directly, since the reusable workflow in
FlowingCode/GithubActions points at another branch of the action. It has 107 commits with an
invalid message at chronological position 104, and the run reports:

ℹ️ Read 107 commit(s).
##[error]🚫 According to the Flowing Code Commit Message Guidelines, some of the commit messages are not valid.

Position 104 is out of reach both of the default 30-commit page and of a single page of 100, so
only following the pages finds it. Before this branch that pull request was green.

The rest was exercised against the bundle directly:

  • the token, by reading a real pull request with and without one — the response reports a limit
    of 5000 with the token and 60 without, and the anonymous read warns;
  • the retrieval failure, against a refused endpoint: the action fails with
    🚫 The commit messages could not be checked: … and sets SEMVER_LEVEL=0 rather than
    leaving it unwritten.

Relationship to #3

#3 carries these same three fixes in a branch that also adds the results output and the
reporting inputs, and it fixes #5 differently: through the API client's own paginate, which
is available there because the token is. This branch follows the Link header instead, which
needs nothing but the request that reads the first page.

So whichever merges first, the other needs reconciling: if this one goes in, #3 should be
rebased onto master, where the shared commits drop out as already applied and its own
pagination commit becomes redundant.

🤖 Generated with Claude Code

ncc 0.36.1 resolves the TypeScript compiler from the project, and its
built-in fallback is not available, so `npm run build` fails on a clean
install with "Could not load TypeScript compiler".
A failure to fetch the list of commits was turned into an empty list, which
is indistinguishable from a pull request whose commit messages are all
valid, so a rate limited or failing request was reported as a success.

The failure is now propagated and fails the action, because not being able
to analyse anything is a failure of the action itself rather than a finding
about the commits. SEMVER_LEVEL is exported on that path too, so that a
later step reading it does not read an empty value.

Close #4
The commits of a pull request were requested anonymously, and GitHub allows an
unauthenticated caller 60 requests per hour counted per IP address. Runners
share those addresses, so the quota is spent by unrelated jobs and the request
fails with 403 (rate limit exceeded) on pull requests that have nothing wrong
with them. It also cannot read the commits of a private repository at all.

The request now carries a token, taken from a new input whose default is the
token of the workflow, so no caller has to be changed. An empty value restores
the anonymous request and warns: since the input defaults to a token, reading
the commits anonymously is a decision, and most often an oversight in the
configuration of the caller.

Close #8
The list of commits of a pull request is paginated. The request asked for no
page size, so it received the default of 30 commits and read that page alone:
every commit after the thirtieth went unchecked, and a pull request whose only
offending commit was past the boundary was reported as clean. Nothing said so,
because the log ends where the reading ended.

The request now asks for 100 commits at a time and follows the Link header
until there is no next page, so the whole branch is read whatever its length.
Following the header needs nothing but the request that reads the first page,
so this works with or without a token. The number of commits that were read is
logged, so that a pull request checked only in part is visible in the log
rather than only in what is missing.

Close #5
The bundle is rebuilt from the current sources.
@javier-godoy javier-godoy changed the title fix: read every commit of a pull request, and fail when they cannot be retrieved fix: read the commits of a pull request completely, authenticated, and fail when they cannot be read Sep 10, 2026
@javier-godoy
javier-godoy marked this pull request as draft September 10, 2026 18:13
@javier-godoy javier-godoy changed the title fix: read the commits of a pull request completely, authenticated, and fail when they cannot be read feat: read the commits with the token of the workflow AND fix: fail when the commits cannot be retrieved AND fix: read every page of the commits of a pull request Sep 11, 2026
@javier-godoy
javier-godoy marked this pull request as ready for review September 11, 2026 01:33
@javier-godoy
javier-godoy merged commit 10a5a8c into master Sep 11, 2026
@github-project-automation github-project-automation Bot moved this from To Do to Pending release in Flowing Code Addons Sep 11, 2026
@javier-godoy
javier-godoy deleted the fix/read-all-commits branch September 11, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pending release

2 participants