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

Fix golden test for forked repository #273

Merged
merged 3 commits into from
Aug 21, 2024
Merged

Conversation

yuxincs
Copy link
Contributor

@yuxincs yuxincs commented Aug 20, 2024

We were facing permission issues for GITHUB_TOKEN in our Golden Test CI job for forked repository. This is because the GITHUB_TOKEN by default does not have permissions to post comments by design for security reasons.

The recommended way from GitHub is to break this into two parts: (1) the first job that executes the (potentially malicious) code from forked repository with limited default permission, and upload the results as a non-executable artifact, and (2) the second job that is triggered by the completion of the first job via workflow_run trigger. This job always runs on main branch, and has proper permissions to post comments. It downloads the artifact from (1) and posts the comment.

Copy link

codecov bot commented Aug 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.60%. Comparing base (8ff8105) to head (49f33ac).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #273   +/-   ##
=======================================
  Coverage   87.60%   87.60%           
=======================================
  Files          63       63           
  Lines        7916     7916           
=======================================
  Hits         6935     6935           
  Misses        799      799           
  Partials      182      182           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yuxincs yuxincs mentioned this pull request Aug 21, 2024
@yuxincs yuxincs marked this pull request as ready for review August 21, 2024 20:43
@yuxincs
Copy link
Contributor Author

yuxincs commented Aug 21, 2024

We did not see the Golden Test comment because the 2nd job has to be in main branch in order for this to take effect. I have run it in my forked repository as an example https://github.com/yuxincs/nilaway/pull/2

Copy link
Contributor

@sonalmahajan15 sonalmahajan15 left a comment

Choose a reason for hiding this comment

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

This is awesome! Glad you fixed the problem for our OSS contributors!

@yuxincs yuxincs merged commit 58a288b into main Aug 21, 2024
8 checks passed
@yuxincs yuxincs deleted the yuxincs/fix-golden-test branch August 21, 2024 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants