-
-
Notifications
You must be signed in to change notification settings - Fork 395
ci: add SentryCrash import ratchet to PR checks #7723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7dbae14
ci(01-02): add SentryCrash import ratchet script
itaybre 8e08b3e
ci(01-02): wire SentryCrash import ratchet into PR checks
itaybre 27eb999
Fix script to cover imports with whitespaces
itaybre 306592c
Update SentryCrash import check script to focus on specific source di…
itaybre 275b73d
Extract check to a new workflow
itaybre 83dc0e8
Merge branch 'main' of github.com:getsentry/sentry-cocoa into ci/sent…
itaybre da820ad
Bump number to 86
itaybre 8241081
Merge branch 'main' into ci/sentrycrash-import-ratchet
itaybre 4667cf1
Merge branch 'main' into ci/sentrycrash-import-ratchet
philprime 8028b90
fix: Update SentryCrash import check to include .hpp files
itaybre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| name: Lint SentryCrash Imports | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - v8.x | ||
|
|
||
| pull_request: | ||
|
|
||
| # Concurrency configuration: | ||
| # - We use workflow-specific concurrency groups to prevent multiple lint runs on the same code, | ||
| # as linting checks are deterministic and don't require parallel validation. | ||
| # - For pull requests, we cancel in-progress runs when new commits are pushed since only the | ||
| # latest linting matters for merge decisions. | ||
| # - For main branch pushes, we never cancel to ensure the ratchet runs for every push. | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| jobs: | ||
| files-changed: | ||
| name: Detect File Changes | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| run_sentrycrash_import_ratchet_for_prs: ${{ steps.changes.outputs.run_sentrycrash_import_ratchet_for_prs }} | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
| - name: Get changed files | ||
| id: changes | ||
| uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1 | ||
| with: | ||
| token: ${{ github.token }} | ||
| filters: .github/file-filters.yml | ||
|
|
||
| check-imports: | ||
| name: Check SentryCrash Imports | ||
| if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_sentrycrash_import_ratchet_for_prs == 'true' | ||
| needs: files-changed | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
| - name: Check SentryCrash import count | ||
| run: ./scripts/check-sentrycrash-imports.sh | ||
|
|
||
| - name: Run CI Diagnostics | ||
| if: failure() | ||
| run: ./scripts/ci-diagnostics.sh | ||
|
|
||
| lint_sentrycrash_imports-required-check: | ||
| needs: [files-changed, check-imports] | ||
| name: Lint SentryCrash Imports | ||
| if: always() | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check for failures | ||
| if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') | ||
| run: | | ||
| echo "One of the SentryCrash import ratchet jobs has failed." && exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #!/bin/bash | ||
|
|
||
| # CI ratchet: ensures SentryCrash import count doesn't increase in SDK sources. | ||
| # Decrease MAX_IMPORTS as phases eliminate imports. Never increase it. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # Source CI utilities for proper logging | ||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| # shellcheck source=./ci-utils.sh disable=SC1091 | ||
| source "$SCRIPT_DIR/ci-utils.sh" | ||
|
|
||
| # Baseline count of #import / #include lines referencing SentryCrash in Sources/Sentry | ||
| # and Sources/Swift only (not Sources/SentryCrash). Pattern allows whitespace after '#' | ||
| # so indented directives under #if are counted; matches #include and #import. | ||
| MAX_IMPORTS=86 | ||
|
|
||
| count=$(grep -rnE '#[[:space:]]*(import|include).*SentryCrash' Sources/Sentry Sources/Swift \ | ||
| --include='*.m' --include='*.h' --include='*.c' --include='*.mm' --include='*.cpp' \ | ||
| | wc -l | tr -d ' ') | ||
|
itaybre marked this conversation as resolved.
Outdated
itaybre marked this conversation as resolved.
Outdated
|
||
|
|
||
| if [ "$count" -gt "$MAX_IMPORTS" ]; then | ||
| log_error "SentryCrash import count increased from $MAX_IMPORTS to $count" | ||
| log_error "New #import / #include of SentryCrash from SDK files is not allowed." | ||
| log_error "Use the SentryCrashReporter protocol instead." | ||
| echo "" | ||
| log_notice "Offending imports:" | ||
| grep -rnE '#[[:space:]]*(import|include).*SentryCrash' Sources/Sentry Sources/Swift \ | ||
| --include='*.m' --include='*.h' --include='*.c' --include='*.mm' --include='*.cpp' | ||
| exit 1 | ||
| fi | ||
|
|
||
| log_notice "SentryCrash import ratchet: $count / $MAX_IMPORTS (OK)" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.