-
Notifications
You must be signed in to change notification settings - Fork 609
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
CI builds fail with "does master exist?" #517
Comments
Just to confirm - your git repo does have a master branch? Or is the base branch named differently? |
Yeah, there is still a master branch and nothing has changed. Initially when we started seeing this, it happened to be on a branch created from another branch. We tried rebasing onto master, and also creating a fresh branch from master, each of which had the same results. |
Could you check if this is also failing for you locally? What's your git version on a failing machine? Could you try to run there |
I did try running it locally in my initial efforts to debug/fix it. It worked fine locally, which was puzzling. On the machine: The pipeline definition uses
When I ran the command you said, it output:
|
Just out of curiosity, I tried |
Are you sure that your setup was/is working correctly with the I was able to reproduce your issue using the given git commands and they just don't lead to a proper checkout - is it, maybe, done afterward in your pipeline? Your cwd is pretty much empty, without any files in it (well, not counting
This won't completely solve the issue yet - because the |
Maybe I missed some git activity between the steps I sent. I do know that it was working before; it fails when there are no changesets in the PR branch and succeeds when they're added. |
Could u take a look and lost all git activities then? And also mention at what exact step changeset gets executed? It would help understanding the issue better. |
Here's the full log (with some details removed for brevity or security).
|
@Andarist I have a github action that has a step calling We just adopted |
You most likely need to set - name: Checkout Repo
uses: actions/checkout@main
with:
fetch-depth: 0 |
@mitchellhamilton yes, I did that and the error is still there. I wonder if you can see my pipeline. You can see the error there. |
@nategreen I don't quite see in this log the moment in which changesets are invoked 🤔 @akphi it's quite hard to tell what has gone wrong - all refs should be downloaded in your case as per the action's source code: Could you try running those on your action before you invoke changeset?
|
I also have a similar problem with the following setup:
But I still get this error: I tried adding
Could this be due to the way checkout is done for PRs? Checkout step logs:
|
Definitely. I'm not a git expert though so usually I have to experiment quite a bit when it comes to such less known command/flags. As mentioned in the previous post - I'm still surprised that you both don't get your base branches fetched with |
@rohit-gohri git pull -f origin master:master # this needs to be run first else the other ones won't even show up
git merge-base master HEAD
git merge-base origin/master HEAD
git branch -r https://github.com/akphi/config-tester/pull/76/checks?check_run_id=2067446422 |
From the the logs for the checkout action, it actually does fetch all the branches:
Will try the other commands tomorrow and report back |
@akhpi so even @rohit-gohri you are right, I can find similar entries in @akphi's logs. This makes the whole thing even more strange |
@akphi could you push out a version without that extra |
@Andarist Ah. Sorry, I grabbed the log only from the step responsible for
|
@Andarist
Looks like |
Ok, I think I somewhat know what to do for the @akhpi case - although the logs from git are somewhat inconsistent in a couple of places there. I'm still not 100% sure what to do in the @nategreen's case - could you check what |
Hello. I have it problem too after run Error:
//config.json
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"linked": [],
"access": "restricted",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": []
}
|
@tema1411 could you tell me how exactly do you fetch your repository/commit/pr? please look through the existing comments here to get a better feeling as to what possible explanations can be |
Maybe we can log the actual error thrown by git here: https://github.com/atlassian/changesets/blob/eae72367e9cb8e708a1d441770dbc70930d4e1ad/packages/git/src/index.ts#L39-L44
|
This is what finally fixed it for me: name: Node.js CI
on:
push:
branches: [develop, main]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npm ci
- run: |
# Checkout PR head commit instead of merge commit
# See: https://github.com/atlassian/changesets/issues/517
git checkout ${{ github.event.pull_request.head.sha }}
npx changeset status --since=origin/main
if: ${{ github.event_name == 'pull_request' }}
According to https://github.jparrowsec.cnmunity/t/running-git-merge-base-fork-point-master-command-as-part-of-a-job-fails/18212/2 So I added a |
wow, that's a nice finding! I think the whole thing can/should be just fixed on our side but I don't have much time to focus on this one right now properly to implement the fix. |
I think Use |
This could fix the issue mentioned in your comment but there are other ones mentioned in this thread and this would not fix them as in those cases "since" is an unknown ref (it has not been fetched at all). |
Thanks to the comments in this issue and others, I had success checking for changeset existence in a PR. If I understood correctly, github action checkout@v2 only checkout a newly created merged commit that is the result of the PR branch head commit and the target commit. This throw off the To solve this:
|
I believe this is a compat issue with Github Check Action v2 and
In case this is helpful to others, this works for me:
|
Any update on this? The following was working for me but it stopped recently and fails with the error
|
It would be great if one could share a repro case with me - that way I could do my own experiments on it to see what would be the most viable solution for the problem. And it would be best if somebody would just prepare a PR with the fix 😉 I'm just a human - I'm as capable to fix/investigate this as any of you. |
For anyone struggling with this in GitLab, I ended up using this in my job:
Please let me know if there's any major downsides to this approach that I am not aware of 😬 |
For those of you struggling with this in GitHub Actions workflows triggered by pull requests, here's what works for me:
|
for processing changesets on your mainline branch name: Process Changesets
description: |
If any changsets are found in the .changeset/ directory - they'll be
processed into CHANGELOGs and declared packages will have their
version fields bumped.
runs:
using: 'composite'
steps:
# reasons: https://github.com/changesets/changesets/issues/517
- name: grab master branch
shell: bash
run: |
git checkout ${{github.sha}}
- name: Check for changesets
shell: bash
id: check-for-changesets
run: echo "::set-output name=HasChangesets::$(pnpm run changeset -- status && echo 'true' || echo 'false')"
- name: Process changesets
if: steps.check-for-changesets.outputs.HasChangesets != 'false'
shell: bash
run: pnpm changeset -- version
- name: 📜 Changesets created the following updates
if: steps.check-for-changesets.outputs.HasChangesets != 'false'
shell: bash
run: git diff-tree --no-commit-id --name-only -r HEAD
- name: 📲 Pulling any updates
if: steps.check-for-changesets.outputs.HasChangesets != 'false'
shell: bash
run: git pull --no-edit origin ${{ github.ref_name }}
- name: 🚚 Pushing new changes
if: steps.check-for-changesets.outputs.HasChangesets != 'false'
shell: bash
run: git push origin ${{ github.ref_name }}
🤝 👍🏻 |
It seems like there are two different things that can cause the issue:
If you're having the second problem (which I am, on CircleCI not GH Actions), it looks like there's a much simpler solution: just pass Another thought would be to put |
My solution for PR CI: https://github.com/blockprotocol/blockprotocol/blob/f5e7748c1c2d5d114eb28241a3912ff4a1f8b6c9/.github/workflows/ci.yml#L19-L41 In essence: - uses: actions/checkout@v3
with:
fetch-depth: 0 ## Needed for Changesets to find `main` branch
- if: ${{ github.event.pull_request.title != 'Version Packages' }}
run: git pull --force --no-tags origin main:main
## yarn install etc.
- if: ${{ github.event.pull_request.title != 'Version Packages' }}
run: yarn changeset status Adding Running
|
Maybe just not have the local main branch |
$ git merge-base master HEAD
fatal: Not a valid object name master $ git pull -f origin master:master
fatal: couldn't find remote ref master $ git merge-base origin/master HEAD
fatal: Not a valid object name origin/master $ git branch -r
origin/HEAD -> origin/develop
origin/develop |
I can confirm using npx @changesets/cli status --since origin/main worked for me on Github |
Affected Packages
@changesets/cli
@changesets/git
Problem
It seems that
2.13.0
of@changesets/cli
broke our CI builds. (I'm assuming that's because of the update to@changesets/git
.) We now get this when runningchangeset status
on PRs:We're running this on Ubuntu machines ("latest" version) in Azure Pipelines. Couldn't reproduce the problem locally.
Confirmed that installing
@changesets/cli
version2.12.0
fixed the problem.Proposed solution
🤷♂️ No clue. Let me know if there is other info I can provide to help debug. Thanks!
The text was updated successfully, but these errors were encountered: