Skip to content

feat(ci): Add workflow_run workflow for posting CI failure comments on PRs#17022

Closed
kgpai wants to merge 1 commit intofacebookincubator:mainfrom
kgpai:ci-failure-comment-workflow
Closed

feat(ci): Add workflow_run workflow for posting CI failure comments on PRs#17022
kgpai wants to merge 1 commit intofacebookincubator:mainfrom
kgpai:ci-failure-comment-workflow

Conversation

@kgpai
Copy link
Copy Markdown
Contributor

@kgpai kgpai commented Apr 3, 2026

Summary

Why workflow_run?

The pull_request event gives fork PRs a read-only GITHUB_TOKEN — this is a GitHub security restriction that cannot be overridden by the workflow's permissions block. Since most Velox PRs come from forks, direct gh pr comment calls from status jobs always fail with Resource not accessible by integration.

The workflow_run pattern solves this by running a separate workflow in the base repo context after the build completes, with its own write permissions. This is the same pattern used by build-impact-comment.yml in this repo.

How it works

  1. Status jobs in linux-build-base.yml (from feat(ci): Add test failure reporting with PR comments and error annotations #17015) upload failure details as ci-failure-* artifacts
  2. This workflow triggers when "Linux Build using GCC" completes with failures
  3. It downloads the artifacts, reads the markdown content, and posts a combined PR comment

Security

  • Never checks out or executes PR code — only reads artifacts and posts comments
  • Artifact content is read via fs.readFileSync and passed through the GitHub REST API (no shell interpolation)
  • Artifacts are generated entirely by our own status job code, not by arbitrary PR code
  • Added to zizmor's dangerous-triggers ignore list with justification

Test plan

Companion to #17015 which adds the artifact uploads in status jobs.

…n PRs

Add ci-failure-comment.yml, a workflow_run-triggered workflow that posts
PR comments when CI builds or tests fail. This is needed because the
pull_request event gives fork PRs a read-only GITHUB_TOKEN, preventing
direct commenting from status jobs.

The workflow:
- Triggers when "Linux Build using GCC" completes with failures
- Downloads ci-failure-* artifacts uploaded by status jobs
- Posts a combined comment on the PR listing failures and log links

Also reverts pull-requests:write from linux-build.yml (facebookincubator#17021) since
the workflow_run pattern provides its own permissions.

Security: This workflow never checks out or executes PR code. It only
reads markdown artifacts generated by our own status jobs and posts
them via the GitHub REST API through actions/github-script.

Companion to facebookincubator#17015 which adds the artifact uploads in status jobs.
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 3, 2026

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 98d74c4
🔍 Latest deploy log https://app.netlify.com/projects/meta-velox/deploys/69cf48deba794d0008a400fe

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

Build Impact Analysis

No build targets affected by this change.


Fast path • Graph from main@d14cd0c27e72ddc11be0d3a09b81aa3832b370f7

@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 3, 2026

@kgpai has imported this pull request. If you are a Meta employee, you can view this in D99400012.

@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 3, 2026

@kgpai merged this pull request in 4bbea83.

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants