Skip to content
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

Account for Forked PRs + refactor testing #45

Merged
merged 4 commits into from
Feb 12, 2024

Conversation

pv72895
Copy link
Collaborator

@pv72895 pv72895 commented Feb 12, 2024

PR Overview

This PR includes necessary updated for getting the merge action to work for forked PRs. When this action runs on pull_request events for forked PRs, the action will not have access to any secrets, most likely including the trunk token necessary for this action to work. To account for this, the setImpactedTargets API allows for uploading impacted targets using the github workflow run ID of the job that is uploading impacted targets. If the provided ID belongs to an in-progress run from a forked PR, and the SHA within the request matches that SHA of that workflow run ID, then the upload will be allowed

This PR handles the above, making it so that if the workflow is coming from a fork, we properly make the setImpactedTargets API call using the forked workflow run ID

Changes to how this action is used

None

Testing

I added tests verifying the new conditions around not always needing the API token. Additionally, I refactored the tests to make future changes like this easier

Other changes

  • In adjusting testing, I noticed some bugs within the bash script and fixed those as well
  • I updated trunk

echo "Missing API Token"
# API Token is required if PR is not from a fork, or
# RUN ID is required if PR is from a fork
if [[ (-z ${API_TOKEN-}) && (${IS_FORK} == 'false') ]]; then
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the action was still allowing the request through when the API token wasn't provided

@pv72895 pv72895 merged commit b3317e9 into main Feb 12, 2024
3 checks passed
@pv72895 pv72895 deleted the phil/pass-run-id-to-upload-impacted-targets branch February 12, 2024 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants