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

--affected failing to resolve main even on full checkout #9320

Open
1 task done
chris-olszewski opened this issue Oct 23, 2024 · 2 comments
Open
1 task done

--affected failing to resolve main even on full checkout #9320

chris-olszewski opened this issue Oct 23, 2024 · 2 comments
Labels
kind: bug Something isn't working

Comments

@chris-olszewski
Copy link
Member

Verify canary release

  • I verified that the issue exists in the latest Turborepo canary release.

Link to code that reproduces this issue

https://github.com/amannn/next-intl

What package manager are you using / does the bug impact?

pnpm

What operating system are you using?

Linux

Which canary version will you have in your reproduction?

2.2.3

Describe the Bug

Using --affected results in the following log line:

Failed to resolve base ref 'main' from GitHub Actions event: git error: fatal: ambiguous argument 'main': unknown revision or path not in the working tree.

example in GH Actions

Expected Behavior

We shouldn't have get an ambiguous argument when testing out main. Especially with fetch-depth: 0

To Reproduce

See next-intl attempting to use --affected: example job

Additional context

No response

@chris-olszewski chris-olszewski added kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage and removed needs: triage New issues get this label. Remove it after triage labels Oct 23, 2024
@ryanarmstrong
Copy link

ryanarmstrong commented Oct 31, 2024

Had a similar issue over on GitLab. The issue was that GitLab Runner will checkout in a detached HEAD mode, which is not a branch, and thus main isn't a branch there.

The fix was to set TURBO_SCM_BASE: "origin/main"

Looking at the logs in your CI, you are also running in a detached HEAD mode, so the above may solve your issue. Alternatively, you could checkout the main branch so you're not in detached HEAD.

Since it seems like this can happen pretty easily in both GitLab and GitHub, it might be a good idea for Turborepo to update its docs to talk about this. It took me quite some time to figure this out.

@amannn
Copy link

amannn commented Oct 31, 2024

Thanks for chiming in here @ryanarmstrong!

Preferably, I'd like to avoid setting TURBO_SCM_BASE, so that --affected also works when targeting other branches than origin/main. Maybe github.base_ref could work to set this dynamically?

I was curious if Turbo tries to do this for you since apparently --affected should work with zero config in GitHub Actions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants