Skip to content

Post GitHub PR comment on CI test failure#6818

Merged
facumenzella merged 16 commits into
mainfrom
worktree-ticklish-wondering-meerkat
May 21, 2026
Merged

Post GitHub PR comment on CI test failure#6818
facumenzella merged 16 commits into
mainfrom
worktree-ticklish-wondering-meerkat

Conversation

@facumenzella

@facumenzella facumenzella commented May 19, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds a new github-notify-pr-on-fail CircleCI command that posts (or updates) a sticky comment on the PR when a job fails
  • Parses JUnit XML from fastlane/test_output/ using Ruby stdlib REXML — no API calls to CircleCI needed
  • Wired into the lint job as an initial test target

🤖 Generated with Claude Code


Note

Medium Risk
Changes CI behavior by posting/updating/deleting GitHub PR comments via the GitHub API using a token from CircleCI contexts; misconfiguration could spam PRs or fail jobs if secrets/permissions are wrong.

Overview
Adds a new CircleCI command, github-notify-pr-on-fail, that posts/updates a per-job “sticky” GitHub PR comment on failure (including failed test names parsed from JUnit XML) and deletes the comment on success.

Implements the behavior in Fastlane via new lanes notify_pr_ci_failure and clear_pr_ci_failure, plus a helper to find existing marker-tagged comments, and wires this into the lint and run-test-ios-26 jobs. Updates on-demand job config and workflows so lint runs with the slack-secrets context (to ensure required tokens are available).

Reviewed by Cursor Bugbot for commit 37ead5e. Bugbot is set up for automated code reviews on this repo. Configure here.

facumenzella and others added 4 commits May 19, 2026 08:44
Posts a sticky GitHub PR comment with failing test names when a CI job
fails, by parsing JUnit XML from fastlane/test_output/. Wired into the
lint job as an initial test.

Requires GITHUB_TOKEN_RC_OPS in the slack-secrets CircleCI context.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
CircleCI v2.1 requires << to be escaped as \<< anywhere in the config.
Replaced the <<< here-string with an echo pipe and escaped the Ruby
array append operator.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Intentional failure to verify github-notify-pr-on-fail posts a comment.
Remove before merging.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…d logging

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@facumenzella facumenzella marked this pull request as ready for review May 19, 2026 22:34
@facumenzella facumenzella requested a review from a team as a code owner May 19, 2026 22:34
Comment thread .circleci/default_config.yml Outdated
Each job now uses <!-- cci-test-failure:$CIRCLE_JOB --> so a passing
job only cleans up its own failure comment, not another job's.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .circleci/default_config.yml Outdated
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .circleci/default_config.yml Outdated
…ring

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@ajpallares ajpallares left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice QoL improvement indeed! I like it! I have added some comments and questions. Also, I wonder if we should have this logic in fastfile, and only have the orchestration in CircleCI. Then we would have the github-notify-pr-on-fail command be something like

- run:
    when: on_fail
    command: bundle exec fastlane notify_pr_ci_failure
- run:
    when: on_success
    command: bundle exec fastlane clear_pr_ci_failure

My thinking is that, if we're ever going to move to fully dynamic job execution (we're closer now that we have the dynamic config), keeping the config file as thin as possible will make that transition easier.

WDYT?

Comment thread .circleci/default_config.yml
Comment thread .circleci/default_config.yml
Comment thread .circleci/default_config.yml Outdated
Comment thread .circleci/default_config.yml Outdated
Comment thread .circleci/default_config.yml Outdated
Comment thread .circleci/default_config.yml Outdated
Comment thread .circleci/default_config.yml Outdated

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't reviewed this yet, but a thought that came to mind... We should make sure any output on these comments (from the tests results) does not contain any environment variable. CircleCI does obfuscate all environment variables appearances in logs/results, but not sure if the same could happen here... So we should be very careful with that

- Extract notify_pr_ci_failure and clear_pr_ci_failure into Fastlane lanes
- Replace inline shell script in github-notify-pr-on-fail CCI command with thin bundle exec wrappers
- Broaden XPath to //testcase[failure or error] to catch crashes and timeouts
- Add early exit when DANGER_GITHUB_API_TOKEN is unset
- Use Net::HTTP instead of curl for cleaner error handling
- Fix missing slack-secrets context for lint job in release-or-main workflow and generate-requested-jobs-config.js

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@facumenzella

facumenzella commented May 20, 2026

Copy link
Copy Markdown
Member Author

Moved all logic to Fastlane: two lanes (notify_pr_ci_failure and clear_pr_ci_failure) backed by Ruby Net::HTTP helpers. The CircleCI command is now just thin bundle exec fastlane wrappers as you suggested.

@facumenzella

Copy link
Copy Markdown
Member Author

The comment body only includes CIRCLE_JOB and CIRCLE_BUILD_URL (standard non-secret CCI vars) plus test class/method names from JUnit XML attributes. DANGER_GITHUB_API_TOKEN is never written into the body. Test names are code symbol names so they shouldn't carry sensitive values — agreed it's worth being mindful of though.

@facumenzella facumenzella requested a review from ajpallares May 20, 2026 16:05
Comment thread fastlane/Fastfile Outdated
Comment thread fastlane/Fastfile Outdated
- test_output/ not fastlane/test_output/ (Fastlane CWD is ./fastlane/)
- Wrap clear_pr_ci_failure in rescue so network errors don't fail passing CI jobs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@ajpallares ajpallares left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for iterating on this! I think it looks great! Just one potential cleanup about using fastlane's github_api, but other than that, I think it's good to go!

Comment thread fastlane/Fastfile Outdated
facumenzella and others added 2 commits May 20, 2026 14:46
…tion

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 83e6c6f. Configure here.

Comment thread Tests/UnitTests/Misc/RateLimiterTests.swift Outdated
@facumenzella facumenzella enabled auto-merge (squash) May 20, 2026 21:10
@facumenzella facumenzella requested a review from ajpallares May 20, 2026 21:11

@ajpallares ajpallares left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for doing this!

@facumenzella facumenzella merged commit e511d2e into main May 21, 2026
17 of 19 checks passed
@facumenzella facumenzella deleted the worktree-ticklish-wondering-meerkat branch May 21, 2026 07:05
This was referenced May 22, 2026
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.

3 participants