playwright: [Bug]: Using--only-changed=$GITHUB_BASE_REF (or --only-changed=main) option to run only changed tests, results in a error in GitHub

Version

1.46.1

Steps to reproduce

Steps:

  1. Copy the workflow from as shown in the official playwright docs from here: https://playwright.dev/docs/ci-intro#fail-fast
  2. Paste to your test repository.
  3. Change a test file.
  4. Create a pull request with this file to the main branch.

Expected behavior

This should trigger the workflow and run changed tests.

Actual behavior

We instead get this error. test

Error: The repository is a shallow clone and does not have 'main' available locally.
Note that GitHub Actions checkout is shallow by default: https://github.com/actions/checkout

Additional context

No response

Environment

System:
    OS: macOS 14.4
    CPU: (10) arm64 Apple M1 Max
    Memory: 21.78 GB / 64.00 GB
  Binaries:
    Node: 21.6.2 - /opt/homebrew/bin/node
    npm: 10.2.4 - /opt/homebrew/bin/npm
  Languages:
    Bash: 3.2.57 - /bin/bash
  npmPackages:
    @playwright/test: ^1.46.1 => 1.46.1

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 15 (7 by maintainers)

Commits related to this issue

Most upvoted comments

We’ve investigated a bit more, and this seems to happen for all Actions workflows that use containers. https://github.com/actions/runner/issues/2033 tracks this, and https://github.com/actions/runner/issues/2033#issuecomment-1598547465 seems to be another good workaround.

I’ll leave this issue open and mark it as “Collecting Feedback”. Let’s collect upvotes on this comment from everyone who runs into this. If a lot of people see this, we can see if we can add a workaround on our end. Until then, let’s hope the upstream issue gets resolved.

@Skn0tt : One last tip from my experiments that may be useful in documentation.

image

Thanks for the repro, this was super helpful! I SSH-ed into the execution and took a look. It seems that the “dubious ownership” error is triggered by the .git directory being owned by a different Unix user than the cloned repository. This blog post explains that better. Because Docker is used here, .git is owned by root but the repo is owned by 127, which I believe is the user that owns Docker mounts.

The fix is to do what the command says, and execute git config --global --add safe.directory '*'. I’ll discuss with the team later today if we can add this to the default config for our Playwright Docker image.

@Skn0tt : This did the job. We are good and green in both pipelines (when running inside container and running directly in the runner): Here are the latest runs:

image

P.S. I had infact tried fixing the run by adding git config --global --add safe.directory '*' before but then since I missed to fetch git history using fetch-depth image

and missed to add origin in the target before $GITHUB_BASE_REF, it didnt work. image

Now with all these 3 changes, it works as expected 😃.

Thanks for all your help in resolving this. I appreciate it 😃.

Thanks for the repro, this was super helpful! I SSH-ed into the execution and took a look. It seems that the “dubious ownership” error is triggered by the .git directory being owned by a different Unix user than the cloned repository. This blog post explains that better. Because Docker is used here, .git is owned by root but the repo is owned by 127, which I believe is the user that owns Docker mounts.

The fix is to do what the command says, and execute git config --global --add safe.directory '*'. I’ll discuss with the team later today if we can add this to the default config for our Playwright Docker image.

Sure. If you can wait a bit, I can try it today or over the weekend and share the results with you?

I indeed was testing in a monorepo that contains frontend and backend as sub directories in it.

Thanks for confirming! I’d assume that the --only-changed implementation is tripping up on the submodules, and maybe it doesn’t know what module it should use for comparing? You should be able to reproduce this locally on your machine by running with --only-changed=main. I can’t give advice for your specific setup because I don’t have it locally, but if you could provide a minimal reproduction case I can take a look.

That said, I tried it on a simple playwright project where the test are directly in the repository and still see failures

Hmm, this is surprising! I’ll take a look.