Skip to content

ci: add SentryCrash import ratchet to PR checks#7723

Open
itaybre wants to merge 7 commits intomainfrom
ci/sentrycrash-import-ratchet
Open

ci: add SentryCrash import ratchet to PR checks#7723
itaybre wants to merge 7 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 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-imports passes locally (86 / 86)
  • 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.

Comment thread scripts/check-sentrycrash-imports.sh Outdated
Comment thread scripts/check-sentrycrash-imports.sh Outdated
@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.490%. Comparing base (8a7f95f) to head (da820ad).
⚠️ Report is 5 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.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.

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

@itaybre itaybre marked this pull request as draft March 23, 2026 11:17
@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

📲 Install Builds

iOS

🔗 App Name App ID Version Configuration
SDK-Size io.sentry.sample.SDK-Size 9.11.0 (1) Release

⚙️ sentry-cocoa Build Distribution Settings

@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

@github-actions
Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1229.13 ms 1252.06 ms 22.94 ms
Size 24.14 KiB 1.13 MiB 1.11 MiB

Baseline results on branch: main

Startup times

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

@itaybre itaybre marked this pull request as ready for review April 24, 2026 19:35
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