Skip to content

feat: support testing on forked repos #4057

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

Merged
merged 17 commits into from
Apr 4, 2025
Merged

feat: support testing on forked repos #4057

merged 17 commits into from
Apr 4, 2025

Conversation

davidcavazos
Copy link
Contributor

Description

Adds support to run tests on forked repos (after reviewer's approval).

This adds a workflow_run file for both prod and dev. They all report back their check status to the PR.

Checklist

  • I have followed guidelines from CONTRIBUTING.MD and Samples Style Guide
  • Tests pass: npm test (see Testing)
  • Lint pass: npm run lint (see Style)
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • This pull request is from a branch created directly off of GoogleCloudPlatform/nodejs-docs-samples. Not a fork.
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new sample directory, and I created GitHub Actions workflow for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

@product-auto-label product-auto-label bot added samples Issues that are directly related to samples. api: workflows Issues related to the Workflows API. labels Apr 1, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @davidcavazos, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request adds support for running tests on forked repositories after a reviewer's approval. It introduces workflow_run files for both production and development environments, ensuring that check statuses are reported back to the pull request.

Highlights

  • Fork Support: Enables testing on forked repositories, enhancing collaboration and contribution workflows.
  • Workflow Automation: Implements workflow_run files for production and development to automatically report check statuses to the pull request.

Changelog

  • .github/workflows/dev.yml
    • Added workflow file to run tests on development environment for forked repos and report check status to the PR.
  • .github/workflows/prod.yml
    • Added workflow file to run tests on production environment for forked repos and report check status to the PR.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A fork in the road,
Tests now run, code bestowed,
Checks pass with grace,
PR's warm embrace,
Bugs vanish, neatly stowed.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces workflow runs for forked repositories, enhancing the testing process. The changes seem well-structured, but I have a few suggestions to improve clarity and maintainability.

Merge Readiness

The changes look good overall. I recommend addressing the identified issues before merging. I am unable to directly approve the pull request, and others should review and approve this code before merging.

@davidcavazos davidcavazos changed the title Support forks feat: support testing on forked repos Apr 1, 2025
@davidcavazos davidcavazos marked this pull request as ready for review April 1, 2025 22:14
@davidcavazos davidcavazos requested review from a team as code owners April 1, 2025 22:14
Copy link
Member

@briandorsey briandorsey left a comment

Choose a reason for hiding this comment

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

LGTM, with caveat that I still don't understand Actions well enough for a deep review, comments mostly about comments/communication.

timeout-minutes: 5
steps:
- name: Check in_progress
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/[email protected]
Copy link
Member

Choose a reason for hiding this comment

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

I think we may get an immediate renovate PR to bump all these versions to 0.2.4, but that might be a good follow up test for running tests from forks?

description: Branch, tag, or commit SHA to run tests on
type: string
default: main
# schedule:
Copy link
Member

Choose a reason for hiding this comment

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

Will we ever want to schedule tests on forked runs? If not we could remove this comment.

Copy link
Contributor Author

@davidcavazos davidcavazos Apr 4, 2025

Choose a reason for hiding this comment

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

The schedule runs from main always, not from forks. This would basically enable nightly tests. I haven't tested it yet so that's why it's commented out, but we eventually want to enable schedule for nightlies. There would be a special case handling on affected to run on everything if it's a schedule (rather than diffs).

- main
workflow_run:
workflows:
- Custard CI # .github/workflows/custard-ci.yaml
Copy link
Member

Choose a reason for hiding this comment

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

Apologies, I don't understand this comment. Is it referencing that this workflow is related to the main ones. Or is it something that could be updated or just removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, the workflow_run references workflows by name, not by filename. That comment is just the filename that contains that job name. For our own discoverability.

Copy link
Member

Choose a reason for hiding this comment

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

Ah! I misunderstood. In that case... are the dev and prod versions of -run both running the same workflow by name then?

Copy link
Contributor Author

@davidcavazos davidcavazos Apr 4, 2025

Choose a reason for hiding this comment

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

Yes, both are triggered by the same pull_request workflow.

# See the License for the specific language governing permissions and
# limitations under the License.

name: (experimental) Custard run
Copy link
Member

Choose a reason for hiding this comment

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

Is there a way to add a note or description (that would surface in the GH UI) or at least a code comment to let folks know that the purpose of the -run workflows are to "support to run tests on forked repos (after reviewer's approval)"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add a bit more context around this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The "Custard run" workflows are never visible from a PR, they're basically an implementation detail. That's why we're manually creating checks to reflect back on the PR. I added some comments on the purpose of every event trigger.

@davidcavazos davidcavazos merged commit 0e0c99b into main Apr 4, 2025
11 checks passed
@davidcavazos davidcavazos deleted the support-forks branch April 4, 2025 20:22
rudrakhsha-crest pushed a commit to rudrakhsha-crest/nodejs-docs-samples that referenced this pull request Apr 18, 2025
* feat: support testing on forked repos

* add pull_request to test on PR

* remove prod suffix

* decode json on matrix paths

* add experimental to check names

* add experimental to job names

* run test only if paths is not empty

* test explicitly against empty array

* move experimental as a prefix

* success check if no paths are found

* always set check to done

* remove pull_request trigger

* rearrange if check

* add more comments
rudrakhsha-crest added a commit to rudrakhsha-crest/nodejs-docs-samples that referenced this pull request Apr 18, 2025
* feat: support testing on forked repos

* add pull_request to test on PR

* remove prod suffix

* decode json on matrix paths

* add experimental to check names

* add experimental to job names

* run test only if paths is not empty

* test explicitly against empty array

* move experimental as a prefix

* success check if no paths are found

* always set check to done

* remove pull_request trigger

* rearrange if check

* add more comments
rudrakhsha-crest added a commit to rudrakhsha-crest/nodejs-docs-samples that referenced this pull request Apr 18, 2025
* feat: support testing on forked repos

* add pull_request to test on PR

* remove prod suffix

* decode json on matrix paths

* add experimental to check names

* add experimental to job names

* run test only if paths is not empty

* test explicitly against empty array

* move experimental as a prefix

* success check if no paths are found

* always set check to done

* remove pull_request trigger

* rearrange if check

* add more comments
rudrakhsha-crest added a commit to rudrakhsha-crest/nodejs-docs-samples that referenced this pull request Apr 18, 2025
* feat: support testing on forked repos

* add pull_request to test on PR

* remove prod suffix

* decode json on matrix paths

* add experimental to check names

* add experimental to job names

* run test only if paths is not empty

* test explicitly against empty array

* move experimental as a prefix

* success check if no paths are found

* always set check to done

* remove pull_request trigger

* rearrange if check

* add more comments
rudrakhsha-crest pushed a commit to rudrakhsha-crest/nodejs-docs-samples that referenced this pull request Apr 18, 2025
* feat: support testing on forked repos

* add pull_request to test on PR

* remove prod suffix

* decode json on matrix paths

* add experimental to check names

* add experimental to job names

* run test only if paths is not empty

* test explicitly against empty array

* move experimental as a prefix

* success check if no paths are found

* always set check to done

* remove pull_request trigger

* rearrange if check

* add more comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: workflows Issues related to the Workflows API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants