Skip to content

ci: add SentryCrash import ratchet to PR checks#7723

Draft
itaybre wants to merge 5 commits intomainfrom
ci/sentrycrash-import-ratchet
Draft

ci: add SentryCrash import ratchet to PR checks#7723
itaybre wants to merge 5 commits intomainfrom
ci/sentrycrash-import-ratchet

Conversation

@itaybre
Copy link
Copy Markdown
Contributor

@itaybre itaybre commented Mar 20, 2026

📜 Description

Add a CI ratchet that prevents the number of direct SentryCrash header imports from SDK source files from increasing beyond the current baseline of 59.

  • scripts/check-sentrycrash-imports.sh — counts #import.*SentryCrash in Sources/Sentry and Sources/Swift, fails if above baseline
  • Makefile — adds check-sentrycrash-imports target
  • .github/workflows/fast-pr-checks.yml — adds sentrycrash-import-ratchet job gated on run_unit_tests_for_prs, runs on ubuntu-latest

💡 Motivation and Context

Part of the SentryCrash decoupling project. As we isolate SentryCrash behind protocols, this ratchet ensures coupling doesn't regress. The baseline should be decreased as isolation work progresses.

#skip-changelog

💚 How did you test it?

  • make check-sentrycrash-imports passes locally (59 / 59)
  • Script correctly fails when baseline is artificially lowered

📝 Checklist

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

Fixes: #7713

itaybre added 2 commits March 20, 2026 13:38
- Count direct SentryCrash imports from SDK sources
- Fail if count exceeds baseline of 59
- Add check-sentrycrash-imports Makefile target
- Add sentrycrash-import-ratchet job to fast-pr-checks workflow
- Run on ubuntu-latest (only needs grep, no Xcode)
- Gate fast-checks-required on ratchet passing
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 20, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

Copy link
Copy Markdown

@cursor cursor bot left a comment

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 2 potential issues.

Fix All in Cursor

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Grep pattern misses indented imports and includes
    • Updated grep to use extended regex matching both indented preprocessor directives and #include statements, increasing coverage from 59 to 84 imports.
  • ✅ Fixed: Dead grep filter never matches any results
    • Removed the ineffective grep filter and replaced with direct wc -l count.

Create PR

Or push these changes by commenting:

@cursor push f223d5e34f
Preview (f223d5e34f)
diff --git a/scripts/check-sentrycrash-imports.sh b/scripts/check-sentrycrash-imports.sh
--- a/scripts/check-sentrycrash-imports.sh
+++ b/scripts/check-sentrycrash-imports.sh
@@ -10,11 +10,11 @@
 # shellcheck source=./ci-utils.sh disable=SC1091
 source "$SCRIPT_DIR/ci-utils.sh"
 
-MAX_IMPORTS=59
+MAX_IMPORTS=84
 
-count=$(grep -rn '#import.*SentryCrash' Sources/Sentry Sources/Swift \
+count=$(grep -rEn '#[[:space:]]*(import|include).*SentryCrash' Sources/Sentry Sources/Swift \
     --include='*.m' --include='*.h' --include='*.c' --include='*.mm' \
-    | grep -vc 'Sources/SentryCrash/' \
+    | wc -l \
     | tr -d ' ')
 
 if [ "$count" -gt "$MAX_IMPORTS" ]; then
@@ -23,9 +23,8 @@
     log_error "Use the SentryCrashReporter protocol instead."
     echo ""
     log_notice "Offending imports:"
-    grep -rn '#import.*SentryCrash' Sources/Sentry Sources/Swift \
-        --include='*.m' --include='*.h' --include='*.c' --include='*.mm' \
-        | grep -v 'Sources/SentryCrash/'
+    grep -rEn '#[[:space:]]*(import|include).*SentryCrash' Sources/Sentry Sources/Swift \
+        --include='*.m' --include='*.h' --include='*.c' --include='*.mm'
     exit 1
 fi

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.388%. Comparing base (5c68ec6) to head (275b73d).
⚠️ Report is 8 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #7723       +/-   ##
=============================================
+ Coverage   85.371%   85.388%   +0.017%     
=============================================
  Files          487       487               
  Lines        28985     28985               
  Branches     12552     12551        -1     
=============================================
+ Hits         24745     24750        +5     
+ Misses        4191      4187        -4     
+ Partials        49        48        -1     

see 7 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5c68ec6...275b73d. Read the comment docs.

@itaybre itaybre marked this pull request as draft March 23, 2026 11:17
@github-actions
Copy link
Copy Markdown
Contributor

🚨 Detected changes in high risk code 🚨

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:

  • .github/file-filters.yml

@itaybre itaybre added the ready-to-merge Use this label to trigger all PR workflows label Mar 23, 2026
@sentry
Copy link
Copy Markdown

sentry bot commented Mar 23, 2026

Sentry Build Distribution

App Name App ID Version Configuration Install Page
SDK-Size io.sentry.sample.SDK-Size 9.8.0 (1) Release Install Build

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

Labels

ready-to-merge Use this label to trigger all PR workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Phase 1: Add SentryCrash import ratchet CI check

1 participant