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

Unable to locate a common ancestor between production_migration and HEAD #802

Closed
3 tasks done
vinothgitkumar opened this issue Nov 14, 2022 · 9 comments · Fixed by #804
Closed
3 tasks done

Unable to locate a common ancestor between production_migration and HEAD #802

vinothgitkumar opened this issue Nov 14, 2022 · 9 comments · Fixed by #804
Labels
bug Something isn't working

Comments

@vinothgitkumar
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

My github workflow triggered using PR creation event. Once the workflow triggered the action throws below error and workflow failed.

Error: Unable to locate a common ancestor between production_migration and HEAD
Error: Process completed with exit code 1.

I am using checkout action v3 with depth 0 and tj-actions/changed-files@v34

To Reproduce

I Encouter this issue now only and not able to reproduce but it may occur sometime later.

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

tj-actions/changed-files@v34 action needs to complete the execution and provide the putout as files in PR.

Relevant log output

changed-files-diff-sha
  Verifying git version...
  Valid git version found: (2.38.1)
  Running on a pull request event...
  Fetching remote refs...
  remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0        
  branch 'production_migration' set up to track 'origin/production_migration'.
  From https://github.com/org1/dataeng-enterprise
   * branch            production_migration -> FETCH_HEAD
   * branch            HEAD       -> FETCH_HEAD
  From https://github.com/org1/dataeng-enterprise
   * branch            production_migration -> FETCH_HEAD
   * branch            HEAD       -> FETCH_HEAD
  From https://github.com/org1/dataeng-enterprise
   * branch            production_migration -> FETCH_HEAD
   * branch            HEAD       -> FETCH_HEAD
  From https://github.com/org1/dataeng-enterprise
   * branch            production_migration -> FETCH_HEAD
   * branch            HEAD       -> FETCH_HEAD
  From https://github.com/org1/dataeng-enterprise
   * branch            production_migration -> FETCH_HEAD
   * branch            HEAD       -> FETCH_HEAD
  From https://github.com/org1/dataeng-enterprise
   * branch            production_migration -> FETCH_HEAD
   * branch            HEAD       -> FETCH_HEAD
  From https://github.com/org1/dataeng-enterprise
   * branch            production_migration -> FETCH_HEAD
   * branch            HEAD       -> FETCH_HEAD
  From https://github.com/org1/dataeng-enterprise
   * branch            production_migration -> FETCH_HEAD
   * branch            HEAD       -> FETCH_HEAD
  From https://github.com/org1/dataeng-enterprise
   * branch            production_migration -> FETCH_HEAD
   * branch            HEAD       -> FETCH_HEAD
  From https://github.com/org1/dataeng-enterprise
   * branch            production_migration -> FETCH_HEAD
   * branch            HEAD       -> FETCH_HEAD
  From https://github.com/org1/dataeng-enterprise
   * branch            production_migration -> FETCH_HEAD
   * branch            HEAD       -> FETCH_HEAD
  From https://github.com/org1/dataeng-enterprise
   * branch            production_migration -> FETCH_HEAD
   * branch            HEAD       -> FETCH_HEAD
  From https://github.com/org1/dataeng-enterprise
   * branch            production_migration -> FETCH_HEAD
   * branch            HEAD       -> FETCH_HEAD
  From https://github.com/org1/dataeng-enterprise
   * branch            production_migration -> FETCH_HEAD
   * branch            HEAD       -> FETCH_HEAD
  From https://github.com/org1/dataeng-enterprise
   * branch            production_migration -> FETCH_HEAD
   * branch            HEAD       -> FETCH_HEAD
  From https://github.com/org1/dataeng-enterprise
   * branch            production_migration -> FETCH_HEAD
   * branch            HEAD       -> FETCH_HEAD
  From https://github.com/org1/dataeng-enterprise
   * branch            production_migration -> FETCH_HEAD
   * branch            HEAD       -> FETCH_HEAD
  Error: Unable to locate a common ancestor between production_migration and HEAD
  Error: Process completed with exit code 1.

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@vinothgitkumar vinothgitkumar added the bug Something isn't working label Nov 14, 2022
@github-actions
Copy link
Contributor

Thanks for reporting this issue, don't forget to star this project if you haven't already to help us reach a wider audience.

@jackton1
Copy link
Member

jackton1 commented Nov 14, 2022

Hi @vinothgitkumar, can you include the configuration for the checkout action, since the merge-base shouldn't be checked when using fetch-depth: 0?

See: https://github.com/tj-actions/changed-files/blob/main/diff-sha.sh#L186

Example: https://github.com/tj-actions/demo3/actions/runs/3463263129/jobs/5783253769#step:3:49

@jarojasm95
Copy link

jarojasm95 commented Nov 15, 2022

I'm also running into this issue, here's a snippet of the workflow:

- uses: actions/checkout@v3
  with:
    fetch-depth: 0
    ref: ${{ github.event.pull_request.head.sha }}
- id: files
  uses: tj-actions/changed-files@v34.3.0
  with:
    separator: ","
    base_sha: ${{ github.event.pull_request.base.sha }}
    sha: ${{ github.event.pull_request.head.sha }}

I think this seems to happen when the pull request is not up to date with the "default/target" branch

@jackton1
Copy link
Member

Hi, @jarojasm95 have you tried upgrading? I believe the change was introduced in v34.4.0

@stof
Copy link

stof commented Nov 15, 2022

I get a similar issue using v34 (which is v34.4.0 right now). tj-actions/changed-files runs for ~15min (apparently fetching lots of git objects) and then fails with Unable to locate a common ancestor between master and HEAD

@tsigouris007
Copy link

I get a similar issue using v34 (which is v34.4.0 right now). tj-actions/changed-files runs for ~15min (apparently fetching lots of git objects) and then fails with Unable to locate a common ancestor between master and HEAD

Hi @stof I am facing the same issue and opened a similar case.
It seems to be working if you use the actions/checkout@v3 with fetch-depth: 0.
Can you try this too?

@vinothgitkumar
Copy link
Author

Hi
I am using actions/checkout@v3 with fetch depth:0.

What change do I need to do in the action "tj-actions/changed-files" to avoid this error?

@ViacheslavKudinov
Copy link

Hi,
eh, same issue with 34.4.0.
We use it as part of reusable workflow. This part looks like:

    steps:
      - name: "Checkout for Push event (full history)"
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Get changed dirs
        id: get_changes
        uses: tj-actions/changed-files@94e6fba8d802f0fa80db51937e8752e9c165ee26 # tag v34.4.0
        with:
          dir_names: ${{ inputs.dir_names }}
          files_ignore: ${{ inputs.excluded_folders }}
          files: ${{ inputs.included_folders }}

Didn't face the issue with 34.1.1.

@jackton1 jackton1 linked a pull request Nov 15, 2022 that will close this issue
@jackton1
Copy link
Member

jackton1 commented Nov 17, 2022

High-level description: This bug occurs when the fork point and the last commit of the base branch differ, resulting in errors finding the merge-base as the checkout action merges the tip of the target branch to the PR branch.

To prevent this error going forward a pre-check to determine the validity of merge-base would be used falling back to the last commit of the target branch where necessary.

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

Successfully merging a pull request may close this issue.

6 participants