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

[BUG] "Unable to locate the current sha" when using use_fork_point #506

Closed
3 tasks done
dmohns opened this issue May 30, 2022 · 4 comments
Closed
3 tasks done

[BUG] "Unable to locate the current sha" when using use_fork_point #506

dmohns opened this issue May 30, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@dmohns
Copy link

dmohns commented May 30, 2022

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?

Running changed-files action one a large mono repo "sometimes" yields

 Warning: Unable to locate the previous sha: 
  Warning: You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See https://github.com/tj-actions/changed-files#usage

in an un-reproducible way. Sometimes rebasing and force-pushing fixes it, sometimes merging main fixes it. But also sometimes neither of them does.

The configuration I use is

jobs:
  sqlfluff:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0  # OR "2" -> To retrieve the preceding commit.
      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v20
        with:
          use_fork_point: "true"

Note how previous sha is empty. Unfortunately this happens in private repos and I cannot share the exact workflow run.

To Reproduce

Unfortunately, I couldn't find a way to reproduce this error 100% of the time.

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

changed-files should work on every workflow run.

Relevant log output

Resolving repository path...
  Getting HEAD SHA...
  Getting fork point...
  From https://github.com/***
   * [new branch]            main       -> main
  Verifying commit SHA...
  Warning: Unable to locate the previous sha: 
  Warning: You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See https://github.com/tj-actions/changed-files#usage
  Error: Process completed with exit code 1.

Anything else?

PS: Converted from a comment in #458 as I think it's a different issue.

Code of Conduct

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

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

@dmohns
Copy link
Author

dmohns commented May 30, 2022

I have been doing "some" investigation (or trial and error rather). I'm not a git expert, so not sure if any of the following makes sense 😉

The documentation of git merge-base notes a couple of caveats about using the --fork-point mode. I.e. git gc was mentioned. I saw we are running git merge-base --fork-point, but I don't fully understand why.

I have been testing to run changed-files without using --fork-point like so

      - name: changed-files Github Action SHA workaround
        id: changed-files-sha-workaround
        run: |
          git fetch --no-tags -u --progress origin "main":"main"
          CURRENT_SHA=$(git rev-list --no-merges -n 1 HEAD 2>&1)
          echo "Current SHA: $CURRENT_SHA"
          FORK_POINT=$(git name-rev --name-only "$CURRENT_SHA")
          echo "Fork point: $FORK_POINT"
          PREVIOUS_SHA=$(git merge-base "main" "$FORK_POINT")
          echo "Previous SHA: $PREVIOUS_SHA"
          echo "::set-output name=current_sha_workaround::$CURRENT_SHA"
          echo "::set-output name=previous_sha_workaround::$PREVIOUS_SHA"
      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v20
        with:
          sha: ${{ steps.changed-files-sha-workaround.outputs.current_sha_workaround }}
          base_sha: ${{ steps.changed-files-sha-workaround.outputs.previous_sha_workaround }}

and it seems to be working.

While running with --fork-point yielded

Error: Process completed with exit code 1.

One other thing I noted is, that in the repository I'm working with we use tags very heavily. Also, it's a relatively large repo with a lot of commits. I was wondering if tagging might have some negative influence on how --fork-point works.

@zhakanov
Copy link

is it possible to count all the changed files?

@dmohns
Copy link
Author

dmohns commented Jun 1, 2022

After more investigation it doesn't look like the problem is actually related to this Github Action.

For some reason $(git rev-list --no-merges -n 1 HEAD 2>&1) sometimes returns the latest commit on the main branch. I suspect this is some weird interaction between how our repository is managed and the checkout action.

I'm closing this, as I don't think there is anything that can be done here.

@dmohns dmohns closed this as completed Jun 1, 2022
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

No branches or pull requests

2 participants