-
-
Notifications
You must be signed in to change notification settings - Fork 235
test: GitHub Actions workflow to test PR head-sha detection #2787
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
Closed
Conversation
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
4591371
to
8df1dd0
Compare
When sentry-cli build upload runs in GitHub Actions for pull requests, it was using the temporary merge commit SHA (from git rev-parse HEAD) instead of the actual PR head commit SHA. This caused build uploads to be associated with non-existent commit SHAs. Changes: - Modify find_head() to check for GITHUB_EVENT_PATH environment variable - Extract PR head SHA from GitHub Actions event payload when available - Fall back to existing git rev-parse HEAD behavior when not in GitHub Actions - Add comprehensive tests for JSON parsing and event handling This ensures build uploads in GitHub Actions PR workflows use the correct commit SHA for size analysis and other features that rely on commit tracking. Fixes EME-325 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Use iterator instead of needless range loop - Use to_owned() instead of to_string() on &str 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Fixes clippy str_to_string warnings in test code. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This workflow will: - Build the actual sentry-cli binary - Run it in a real GitHub Actions PR environment - Demonstrate that it correctly detects GITHUB_EVENT_PATH - Show it extracts the real PR head SHA instead of merge commit - Verify the fix works end-to-end 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Use --log-level debug parameter instead of RUST_LOG env var to see the GitHub Actions PR head SHA detection debug logs in CI output. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This allows the CLI to proceed past authentication and reach the head-sha detection logic where we can see our debug logs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Copy real APK from hackernews project to test_artifacts/ - Update workflow to use app-debug.apk instead of creating fake file - This provides more realistic testing for sentry-cli build upload 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add --org test-org --project test-project to sentry-cli commands - This allows the CLI to proceed further into execution flow - Should help reach the head SHA detection logic for testing 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Change --org to -o and --project to -p (correct build subcommand flags) - Move org/project flags to after build subcommand where they belong 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add debug logs to trace HEAD finding process - Log event path when GITHUB_EVENT_PATH is set - Log event file content for debugging - This helps troubleshoot why SHA detection message isn't appearing 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
75d4792
to
19ef6ad
Compare
- Remove test_get_github_base_ref() test that references non-existent function - The function get_github_base_ref() was never implemented - This test was incorrectly added during merge conflict resolution 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Simplify JSON parsing logic to be more reliable - Use sequential string searching instead of line-by-line parsing - Add test case with real GitHub Actions JSON format - Fix clippy warning by using to_owned() instead of to_string() This should fix the issue where SHA detection message wasn't appearing in the test workflow by properly parsing the real event payload structure. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
runningcode
added a commit
that referenced
this pull request
Sep 24, 2025
…#2785) ## Summary Fixes the issue where `sentry-cli build upload` uses incorrect commit SHAs when running in GitHub Actions for pull requests. Previously, when running in GitHub Actions PR builds, sentry-cli would use the temporary merge commit SHA (created by GitHub Actions when it merges the PR branch with the target branch) instead of the actual PR head commit SHA. This caused build uploads to be associated with commit SHAs that don't exist in the actual repository history. - **Modified `find_head()` function**: Now checks for `GITHUB_EVENT_PATH` environment variable - This once again affects the release functionality. I don’t think there is a case where the release functionality would work from a PR branch but if it did this would in either case improve the logic to use an actual commit instead of the temporary merge commit. ## How it works 1. If `--head-sha` is explicitly provided → use that (existing behavior) 2. If `GITHUB_EVENT_PATH` is set → extract PR head SHA from event payload 3. Otherwise → use `git rev-parse HEAD` (existing behavior) ## Alternative Alternatively, we could use a complex regex to parse the json, i think the logic here is easier to follow/debug than a regex. ## Testing I tested this functionality in this test PR: #2787 ## Fixes Closes EME-325 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Daniel Szoke <7881302+szokeasaurusrex@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Test Workflow for PR Head-SHA Detection
This PR contains a GitHub Actions workflow that will test our PR head-sha detection fix in a real CI environment.
What the workflow does:
Expected Results:
This will demonstrate that the fix works end-to-end in the exact scenario described in EME-325.
🤖 Generated with Claude Code