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] pull request with since_last_remote_commit = true returns fatal: bad object #253

Closed
3 tasks done
solarmosaic-kflorence opened this issue Nov 18, 2021 · 8 comments
Closed
3 tasks done
Labels
bug Something isn't working

Comments

@solarmosaic-kflorence
Copy link

solarmosaic-kflorence commented Nov 18, 2021

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?

The action is not able to locate the last remote commit on the pull-request.

To Reproduce

Here is the action YAML:

    steps:
      - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
        with:
          ref: "${{ github.event.pull_request.head.sha }}"
      - id: changed-files
        uses: tj-actions/changed-files@aae164d51be780a235cdeea89752bbacbbfee3c3
        with:
          files: |
            ^${{ env.PROJECT_PATH }}
          sha: "${{ github.event.pull_request.head.sha }}"
          since_last_remote_commit: "true"

When this workflow is executed, it results in several fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3 errors, and all outputs are blank. That commit SHA is correct -- it was the last remote commit on the pull-request branch. It also returns the correct commit SHA if there are multiple commits pushed at the same time.

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

I expect the action to provide a diff of files between the last remote commit on the pull-request (which it correctly figures out) and the HEAD commit of the pull-request (the last commit that was pushed -- which I have confirmed in the output is also correct). Perhaps the base ref needs to be explicitly fetched from the remote in order for it to be found.

Relevant log output

Run tj-actions/changed-files@aae164d51be780a235cdeea89752bbacbbfee3c3
  with:
    files: ^libraries/terraform/name-provider
    since_last_remote_commit: true
    token: ***
    separator:  
    sha: e42496235d245861a95249a5c04c06d3907f19a0
  env:
    PROJECT_NAME: terraform-name-provider
    PROJECT_PATH: libraries/terraform/name-provider
Run bash $GITHUB_ACTION_PATH/sourcefiles.sh
  bash $GITHUB_ACTION_PATH/sourcefiles.sh
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    PROJECT_NAME: terraform-name-provider
    PROJECT_PATH: libraries/terraform/name-provider
    INPUT_FILES: ^libraries/terraform/name-provider
    INPUT_FILES_FROM_SOURCE_FILE: 
changed-files-from-source-file
  Input Files: ^libraries/terraform/name-provider
  All Unique Input files: ^libraries/terraform/name-provider
Run if [[ -n "" ]]; then
  if [[ -n "" ]]; then
    echo "::set-output name=base_sha::"
  elif [[ "true" == "true" && -z "" ]]; then
    echo "::set-output name=base_sha::9b20d537dc9a0943ad43cd8e6a08c444640a75e3"
  fi
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    PROJECT_NAME: terraform-name-provider
    PROJECT_PATH: libraries/terraform/name-provider
Run bash $GITHUB_ACTION_PATH/entrypoint.sh
  bash $GITHUB_ACTION_PATH/entrypoint.sh
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    PROJECT_NAME: terraform-name-provider
    PROJECT_PATH: libraries/terraform/name-provider
    GITHUB_SERVER_URL: https://github.com
    GITHUB_REPOSITORY: [REDACTED]
    GITHUB_BASE_REF: master
    INPUT_SHA: e42496235d245861a95249a5c04c06d3907f19a0
    INPUT_BASE_SHA: 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
    INPUT_TOKEN: ***
    INPUT_FILES: ^libraries/terraform/name-provider
    INPUT_SEPARATOR:  
    INPUT_PATH: 
changed-files
  Resolving repository path...
  Setting up 'temp_changed_files' remote...
  No 'temp_changed_files' remote found
  Creating 'temp_changed_files' remote...
  Getting HEAD info...
  From https://github.com/[REDACTED]
   * [new branch]          master     -> master
   * [new branch]          master     -> temp_changed_files/master
  Retrieving changes between 9b20d537dc9a0943ad43cd8e6a08c444640a75e3 (master) → e42496235d245861a95249a5c04c06d3907f19a0 ([REDACTED])
  Input files: ^libraries/terraform/name-provider
  Checking for file changes: "^libraries/terraform/name-provider"...
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  Matching modified files: 
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  Matching deleted files: 
  Added files: 
  Copied files: 
  Deleted files: 
  Modified files: 
  Renamed files: 
  Type Changed files: 
  Unmerged files: 
  Unknown files: 
  All changed files: 
  All modified files:

Anything else?

As an aside, this logging can be misleading:

Retrieving changes between X (master) → Y (branch)

Since the X commit may not be from master.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@solarmosaic-kflorence solarmosaic-kflorence added the bug Something isn't working label Nov 18, 2021
@jackton1
Copy link
Member

@solarmosaic-kflorence You might be missing fetch-depth: 0 when using the checkout action

@solarmosaic-kflorence
Copy link
Author

Hm, thanks @jackton1 it does work with fetch-depth: 0 -- although this is not going to scale well at all in our monorepo. I will need to find another workaround.

@solarmosaic-kflorence
Copy link
Author

This works:

    steps:
      - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
        with:
          ref: "${{ github.event.pull_request.head.sha }}"
      - run: git fetch --prune --progress --depth=1 origin ${{ github.event.before }}
      - id: changed-files
        uses: tj-actions/changed-files@aae164d51be780a235cdeea89752bbacbbfee3c3
        with:
          files: |
            ^${{ env.PROJECT_PATH }}
          sha: "${{ github.event.pull_request.head.sha }}"
          since_last_remote_commit: "true"

@solarmosaic-kflorence
Copy link
Author

In some cases, I think I don't even need the changed-files action to fetch anything. Would be nice if that could be disabled.

@jackton1
Copy link
Member

jackton1 commented Nov 19, 2021

Okay would remove the redundant pulling of the remote branch. Thanks

@solarmosaic-kflorence
Copy link
Author

Thanks @jackton1 for your always speedy responses, it's appreciated :)

@jackton1
Copy link
Member

jackton1 commented Nov 19, 2021

@solarmosaic-kflorence No worries, I've made the change to use a shallow history of the last commit on the remote branch, which should be available in the latest release.

@solarmosaic-kflorence
Copy link
Author

Confirmed the fix works, thanks!

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