ci: add SentryCrash import ratchet to PR checks#7723
Conversation
- 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
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
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.
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
fiThis Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7723 +/- ##
=========================================
Coverage 85.490% 85.490%
=========================================
Files 487 487
Lines 29311 29311
Branches 12669 12669
=========================================
Hits 25058 25058
Misses 4203 4203
Partials 50 50 see 7 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
📲 Install BuildsiOS
|
…rycrash-import-ratchet
🚨 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:
|
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| e1e5f3b | 1220.60 ms | 1241.63 ms | 21.04 ms |
| f194b9c | 1216.71 ms | 1249.02 ms | 32.31 ms |
| 45eb835 | 1216.00 ms | 1248.48 ms | 32.48 ms |
| 39fbc4b | 1230.95 ms | 1257.53 ms | 26.58 ms |
| d29a425 | 1209.96 ms | 1239.00 ms | 29.04 ms |
| f38f4e9 | 1221.50 ms | 1242.64 ms | 21.14 ms |
| 1b7b7b4 | 1228.40 ms | 1260.20 ms | 31.80 ms |
| 7b14762 | 1221.13 ms | 1261.41 ms | 40.28 ms |
| 142310c | 1219.87 ms | 1248.71 ms | 28.84 ms |
| f84c826 | 1216.38 ms | 1241.98 ms | 25.60 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| e1e5f3b | 24.14 KiB | 1.06 MiB | 1.04 MiB |
| f194b9c | 24.14 KiB | 1.12 MiB | 1.10 MiB |
| 45eb835 | 24.14 KiB | 1.07 MiB | 1.04 MiB |
| 39fbc4b | 24.14 KiB | 1.12 MiB | 1.09 MiB |
| d29a425 | 24.14 KiB | 1.04 MiB | 1.02 MiB |
| f38f4e9 | 24.14 KiB | 1.10 MiB | 1.07 MiB |
| 1b7b7b4 | 24.14 KiB | 1.13 MiB | 1.11 MiB |
| 7b14762 | 24.14 KiB | 1.13 MiB | 1.11 MiB |
| 142310c | 24.14 KiB | 1.12 MiB | 1.10 MiB |
| f84c826 | 24.14 KiB | 1.04 MiB | 1.02 MiB |


📜 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 86.
💡 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-importspasses locally (86 / 86)📝 Checklist
sendDefaultPIIis enabled.Fixes: #7713