-
Notifications
You must be signed in to change notification settings - Fork 123
Improve fork safety: consolidate approval and add pull_request trigger #919
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
base: master
Are you sure you want to change the base?
Improve fork safety: consolidate approval and add pull_request trigger #919
Conversation
- Add pull_request trigger for internal PRs (non-forks) to test workflow changes immediately - Keep pull_request_target for fork PRs that need access to secrets - Move approval step to test-all-warehouses.yml (runs once instead of per-platform) - Remove per-platform approval from test-warehouse.yml to reduce spam Fixes ELE-5221 Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
👋 @devin-ai-integration[bot] |
📝 WalkthroughWalkthroughAdds fork-aware gating to Changes
Sequence Diagram(s)sequenceDiagram
actor GitHub
participant CheckFork as "check-fork-status\n(runner)"
participant Approve as "approve-fork\n(manual)"
participant Test as "test job\n(runner)"
GitHub->>CheckFork: Trigger workflow (pull_request / pull_request_target)
CheckFork->>CheckFork: Determine if PR is from a fork
CheckFork->>Approve: Emit fork status (needs approval if fork)
alt PR is from a fork
Approve->>Approve: Await manual approval
Approve->>Test: Signal approval granted
else PR is internal
CheckFork->>Test: Bypass approval, proceed
end
Test->>Test: Run tests (conditional on approval/bypass)
Test->>GitHub: Report results/status
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.github/workflows/test-all-warehouses.yml:
- Around line 78-83: The current workflow condition reads outputs from
needs.check-fork-status even when that job may have failed (leaving outputs
empty) which lets tests run; update the if condition to also verify the job
succeeded by adding an explicit check like needs.check-fork-status.result ==
'success' (in addition to the existing outputs checks) so the overall clause
becomes: always() && needs.check-fork-status.result == 'success' &&
needs.check-fork-status.outputs.should_skip != 'true' &&
(needs.check-fork-status.outputs.is_fork != 'true' || needs.approve-fork.result
== 'success'); this ensures tests only run when the fork-check job completed
successfully.
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
|
|
||
| test: | ||
| needs: [check-fork-status, approve-fork] | ||
| # Run if: not cancelled, fork check succeeded, not skipped, AND (not a fork OR fork approval succeeded) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the redundant comment. Applied the same fix to the elementary repo as well.
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
Summary
This PR improves the fork testing workflow by:
pull_requesttrigger for internal PRs (non-forks) so workflow changes can be tested immediately without waiting for mergepull_request_targetfor fork PRs that need access to secretstest-warehouse.ymltotest-all-warehouses.ymlso approval happens once instead of per-platform (reduces approval spam)pull_request_target, fork PRs skippull_request)Trigger behavior after this change:
pull_request(no approval needed)pull_request_target(single approval required)Fixes ELE-5221
Updates since last revision
always()to! cancelled()in the test job condition so that workflow cancellation still behaves as expectedneeds.check-fork-status.result == 'success'guard to prevent tests from running if the fork check job fails (when outputs would be empty strings)Review & Testing Checklist for Human
elementary_test_envenvironment before accessing secrets - the approval gate should only trigger forpull_request_targetfrom forksshould_skipcondition should correctly skippull_requestevents from forks andpull_request_targetevents from non-forks! cancelled()logic)pull_requestwithout approval; have someone create a fork PR to verify it requires approvalRecommended test plan:
Notes
This is part of a two-repo change - the same changes need to be applied to the
elementaryrepo.Link to Devin run: https://app.devin.ai/sessions/268e854e9d814cd4a6e23511732beb37
Requested by: Itamar Hartstein (@haritamar)
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.