fix(ci) : Optimize Workflow Triggers for Collaborators vs. External Contributors #2162
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.
What does this PR do ?
This PR updates the
cpu-tests.ymlworkflow to select the correct trigger based on the author's association with the repository. It eliminates duplicate CI runs and ensures workflow modifications can be properly tested by maintainers.Problem
Previously, when a collaborator opened a PR, two workflow runs would often trigger simultaneously:
pull_request: Uses the PR's code and workflow file (but often lacks secrets if from a fork).pull_request_target: Uses the PR's code but ignores workflow changes, using the version frommaininstead.This caused confusion because updates to the workflow file itself (e.g., changing python versions or steps) were ignored by the
pull_request_targetrun, while thepull_requestrun might fail due to missing secrets.Solution
I have updated the
ifconditions in thepytesterandtesting-guardianjobs to enforce strict separation:For Collaborators/Members:
pull_requesttrigger runs.pull_request_targettrigger is skipped.HF_TOKEN).For External Contributors (Forks):
pull_request_targettrigger runs.pull_requesttrigger is skipped.mainwhile still having access to necessary secrets.