[Bug] 自动格式化工作流只读取第一页,PR 变更超过 30 个文件时会漏掉待格式化文件

Open Beginner friendly
#12,106 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c, github, github-actions
Domain
ci-cd, tooling

Research direction

Read .github/workflows/pr_clang_format.yml, especially the file-list request around lines 113–125, and check how it handles GitHub REST API pagination and request failures. Reproduce with a PR that changes more than 30 files and has a C or C++ file on a later page. Done when all pages are included, formatting failures are reported clearly, and the later-page file is checked.

Written by the indexing model from the issue text.

Description

action bug
RT-Thread Version

RT-Thread Version:master @ fbdb9711;复现 PR #12090,分支提交 8809d3c

Affected area

CI / GitHub Actions

Hardware/BSP vendor

Not applicable / Other

Architecture

Not applicable / Other

Board and hardware details

不涉及开发板或外设

Develop Toolchain

Other

Describe the bug
复现步骤

对一个变更超过 30 个文件的 PR,在 fork 上手动运行 Code Format with Clang-Format。以 RT-Thread/rt-thread#12090(head: 8809d3c)为例,该 PR 有 46 个变更文件。

实际结果

自动格式化日志显示只取到了 30 个文件。第一页里没有 components/drivers/can/utest/can_framework_tc.c,所以此文件根本没有被格式化。工作流最后显示「代码无需格式化」,并跳过提交和推送。与此同时,上游格式检查仍在该文件第 102–112 行报错。

上游的 pr_clang_format.yml也只请求了一次 PR 文件列表,没有读取后续页面。该接口默认每页返回 30 项。

预期结果

获取 PR 的全部文件页,再按现有规则筛选并格式化 C/C++ 文件。如果分页请求失败,应明确报错,不应在文件列表不完整时报告「代码无需格式化」。

Other additional context

建议按 GitHub REST API 的分页信息读取所有页面,不只把每页上限调大。验证时可以找一个变更超过 30 个文件、且待格式化的 C 文件在第二页的 PR,确认该文件被纳入格式化列表。

参考:List pull requests files

Dominant language
C
Stars
12.4k
Forks
5.5k
Avg merge
3d 11h
Merged PRs (30d)
80

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RT-Thread/rt-thread

All issues in RT-Thread/rt-thread

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.