Skip to content

Conversation

Copy link

Copilot AI commented Jul 15, 2025

Problem

The Playwright workflow in .github/workflows/playwright.yml fails to detect modified projects in pull request contexts, causing the samples/find-changes.sh script to return empty results and skip running tests on changed samples.

Root Cause: The workflow attempts to compare changes against origin/${{ github.base_ref }} (e.g., origin/main), but GitHub Actions checkout@v4 only fetches the current branch (PR branch) by default. When find-changes.sh tries to run:

git diff --name-only --diff-filter=AM origin/main HEAD -- "samples/"

It fails with:

fatal: bad revision 'origin/main'

Solution

Add a step after actions/checkout@v4 to explicitly fetch the base branch for PR events:

- name: Fetch base branch for PR comparison
  if: github.event_name == 'pull_request'
  run: git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}

This step:

  • Only runs for pull_request events (not push events)
  • Fetches the base branch from origin and creates a local tracking reference
  • Ensures the origin/main reference exists locally for comparison

Testing

  • ✅ Verified the fix resolves the "bad revision 'origin/main'" error
  • ✅ Confirmed change detection works correctly with the fetched base branch
  • ✅ Validated the step only runs for pull_request events
  • ✅ Ensured YAML syntax is valid and no existing functionality is broken
  • ✅ Tested end-to-end change detection with actual file modifications

Impact

This fix ensures that PR workflows properly detect modified projects, allowing Playwright tests to run on the correct samples rather than being skipped due to empty change detection results.

This pull request was created as a result of the following prompt from Copilot chat.

The Playwright workflow in .github/workflows/playwright.yml fails to detect modified projects in pull request contexts, because it attempts to compare changes against a base branch ref (origin/${{ github.base_ref }}) which may not be present locally after checkout. This causes the samples/find-changes.sh script to return empty results. To fix this, add a step after the checkout to explicitly fetch the base branch for PR events, ensuring the ref exists locally for comparison. Insert the following step after 'actions/checkout@v4' in jobs.pr_and_push_tests.steps:

  • name: Fetch base branch for PR comparison
    if: github.event_name == 'pull_request'
    run: git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}

This ensures the base branch is available for the find-changes.sh script, so modified projects are detected correctly in PRs.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@google-cla
Copy link

google-cla bot commented Jul 15, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@willum070 willum070 closed this Jul 15, 2025
@willum070 willum070 deleted the copilot/fix-f67dae01-3635-44b5-ad05-5a18dc4d9f92 branch July 15, 2025 17:17
Copilot AI restored the copilot/fix-f67dae01-3635-44b5-ad05-5a18dc4d9f92 branch July 15, 2025 17:20
Copilot AI changed the title [WIP] Fix Playwright workflow to fetch base branch for PR comparison in find-changes.sh Fix Playwright workflow to fetch base branch for PR comparison Jul 15, 2025
Copilot AI requested a review from willum070 July 15, 2025 17:27
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.

1 participant