Skip to content

ci: split clang-tidy-bazel into pull_request + workflow_run stages#10527

Closed
openroad-ci wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:ci/clang-tidy-bazel-fork-pr-fix
Closed

ci: split clang-tidy-bazel into pull_request + workflow_run stages#10527
openroad-ci wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:ci/clang-tidy-bazel-fork-pr-fix

Conversation

@openroad-ci
Copy link
Copy Markdown
Collaborator

Summary

  • Split clang-tidy-bazel into two stages so reviewdog can post review comments on fork PRs on the public repo, where the pull_request token is read-only.
  • Stage A (clang-tidy-bazel) keeps the bazel --config=lint build and uploads clang-tidy.txt + pr-meta.txt as an artifact. No write permissions.
  • Stage B (clang-tidy-bazel-post) runs on workflow_run in base-repo context with a writable token. Downloads the artifact, validates pr-meta.txt fields against a strict regex allowlist, synthesizes a pull_request event JSON (because workflow_run.pull_requests[] is empty for fork PRs), then runs reviewdog with -reporter=github-pr-review.

Why

Single-stage pull_request workflow can't post reviewdog reviews on fork PRs — GitHub gives those runs a read-only GITHUB_TOKEN regardless of permissions:, so POST /pulls/N/reviews returned 403 and reviewdog exited 1 (see failed run on public tier). This mirrors the legacy two-stage clang-tidy-review / clang-tidy-review-post setup that solved the same problem before the bazel-based rewrite landed.

Security

  • Stage B never checks out fork code and never runs any fork scripts. It only consumes the text artifact + validated metadata.
  • pr-meta.txt is parsed with a strict allowlist (pr_number numeric, SHAs hex-40, repo slugs ^[A-Za-z0-9._-]+/[A-Za-z0-9._-]+$).
  • Bazel build of fork code stays on Stage A's read-only token; BAZEL_CACHE_PASSWORD is not available there (consistent with prior behaviour).

Test plan

  • Sync to staging and public; verify Stage A succeeds and uploads artifact on a normal in-org PR.
  • Verify Stage B triggers on workflow_run completed and posts a review on the in-org PR.
  • Re-trigger public PR mpl: Fixes MPL-45 can't split cluster error #10520 (or equivalent fork PR) and confirm reviewdog posts review comments instead of 403'ing.
  • Confirm Stage B is skipped when Stage A's conclusion != 'success'.

The split workflow removed the inline reviewdog step from stage A, which
silently downgraded enforcement: stage A now exits 0 even when PR-diff
clang-tidy findings exist, so branch protection on the `clang-tidy-bazel`
check passes and merges are no longer blocked on lint findings. Stage
B's `-fail-level=any` runs in workflow_run context where the resulting
check binds to the default-branch SHA, not the PR head, so it cannot
satisfy a required PR check.

Restore the old behaviour:

- Stage A re-adds reviewdog (set up + run with -reporter=local
  -filter-mode=added -fail-level=any). The fork-PR token is read-only,
  but `-reporter=local` only needs the filesystem and a `-diff` command,
  so this works in all PR contexts. Step is positioned AFTER the
  artifact upload so the post workflow still has the findings to post
  as review comments even when this step exits non-zero.
- Stage B's guard relaxes from `conclusion == 'success'` to
  `conclusion != 'cancelled'`, so it still runs when Stage A's check
  step failed (artifact is uploaded before that fail step).

Signed-off-by: Joao Luis Sombrio <sombrio@sombrasoft.dev>
@openroad-ci openroad-ci requested a review from a team as a code owner May 27, 2026 17:09
@openroad-ci openroad-ci requested a review from precisionmoon May 27, 2026 17:09
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants