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:
- Copy the workflow from as shown in the official playwright docs from here: https://playwright.dev/docs/ci-intro#fail-fast
- Paste to your test repository.
- Change a test file.
- 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
- chore(test runner): document that --only-changed on CI needs history Closes https://github.com/microsoft/playwright/issues/32452 --only-changed needs more than a single commit locally to work prop... — committed to microsoft/playwright by Skn0tt 2 years ago
- chore(test runner): document that --only-changed on CI needs history (#32461) Closes https://github.com/microsoft/playwright/issues/32452 `--only-changed=$GITHUB_BASE_REF` needs the base ref avail... — committed to Skn0tt/playwright by Skn0tt 2 years ago
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.
@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:
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 usingfetch-depthand missed to add origin in the target before $GITHUB_BASE_REF, it didnt work.
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
.gitdirectory being owned by a different Unix user than the cloned repository. This blog post explains that better. Because Docker is used here,.gitis owned byrootbut the repo is owned by127, 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?
Thanks for confirming! I’d assume that the
--only-changedimplementation 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.Hmm, this is surprising! I’ll take a look.