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: ref not being persisted after checkout #18

Closed
1 task done
tmountjr opened this issue May 13, 2022 · 3 comments
Closed
1 task done

Bug: ref not being persisted after checkout #18

tmountjr opened this issue May 13, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@tmountjr
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Triggering a CircleCI job against an opened PR sends over a SHA1 ref that CircleCI can't find.

Minimum reproduction code

https://github.com/tmountjr/l0-express

Steps to reproduce

  1. Create new branch (feature-1) and commit code. GH action not run.
  2. Create PR from feature-1 to main. GH action is run and successfully triggers CircleCI.
  3. CircleCI run fails with the following message:
Using SSH Config Dir '/home/circleci/.ssh'
git version 2.35.1
Cloning git repository
Cloning into '.'...
Warning: Permanently added the ECDSA host key for IP address '140.82.113.3' to the list of known hosts.
remote: Enumerating objects: 25, done.        
remote: Counting objects: 100% (25/25), done.        
remote: Compressing objects: 100% (14/14), done.        
remote: Total 25 (delta 5), reused 24 (delta 4), pack-reused 0        
Receiving objects: 100% (25/25), 103.51 KiB | 20.70 MiB/s, done.
Resolving deltas: 100% (5/5), done.
Checking out branch
fatal: reference is not a tree: 7c9319c338312cd6720fc85e0d05263a65172370

exit status 128

$CIRCLE_SHA1 is set to 7c9319c338312cd6720fc85e0d05263a65172370 but that ref does not exist on the repo (running git log doesn't show that). I believe that ref is generated by the "fetch" phase of the checkout action with this command (taken from the details of the successful GH action):

/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +7c9319c338312cd6720fc85e0d05263a65172370:refs/remotes/pull/1/merge

Expected behavior

Either the checkout phase of the CircleCI pipeline should use the refs/pull/1/merge ref directly rather than a hash, or the GH action should commit the new ref to the repo (if possible) or send over a different SHA1 so that the CircleCI pipeline can use $CIRCLE_SHA1 properly.

Worth noting that, after the Circle run failed and I restarted with SSh, when I run the git fetch command from the GH pipeline in the SSH container the git checkout --force -B "$CIRCLE_BRANCH" "$CIRCLE_SHA1" command succeeds.

GitHub Action Version

1.0.4

Other

CircleCI config.yml file:

version: 2.1

parameters:
  GHA_Actor:
    type: string
    default: ""
  GHA_Action:
    type: string
    default: ""
  GHA_Event:
    type: string
    default: ""
  GHA_Meta:
    type: string
    default: ""

jobs:
  show_env_vars:
    docker:
      - image: cimg/base:stable
    steps:
      - checkout
      - run:
          name: echo CIRCLE_PULL_REQUEST
          command: echo $CIRCLE_PULL_REQUEST
      - run:
          name: echo CIRCLE_PULL_REQUESTS
          command: echo $CIRCLE_PULL_REQUESTS
      - run:
          name: echo CIRCLE_TAG
          command: echo $CIRCLE_TAG
      - run:
          name: echo GH_META
          command: echo $GH_META
      - run:
          name: echo CIRCLE_BRANCH
          command: echo $CIRCLE_BRANCH
      - run:
          name: echo CIRCLE_SHA1
          command: echo $CIRCLE_SHA1
      - run:
          name: run git log
          command: git log

workflows:
  version: 2.1
  build_and_deploy:
    jobs:
      - show_env_vars:
          filters:
            tags:
              only: /^v\d+.*/
            branches:
              only: /.*/

Output of the git log command from a failed run (restarted with SSH):

commit a7decbb6888239afabedff6d7e309df133578208 (HEAD -> main, origin/main, origin/HEAD)
Author: Tom Mount <[email protected]>
Date:   Fri May 13 10:10:10 2022 -0400

    add sha1 and git log commands

commit c78dde9ddaed52c9c34b2df64b3442f58b1c67c3
Author: Tom Mount <[email protected]>
Date:   Fri May 13 10:09:09 2022 -0400

    push up pipelines

commit 8838f6fadd4d1ae02612be942346ce9f68348133
Author: Tom Mount <[email protected]>
Date:   Thu May 12 17:28:44 2022 -0400

    initial commit
@tmountjr tmountjr added the bug Something isn't working label May 13, 2022
@tmountjr
Copy link
Author

There seems to be a similar PR (#16) that might solve this.

@tmountjr tmountjr changed the title Bug: Bug: ref not being persisted after checkout May 13, 2022
@KyleTryon
Copy link
Contributor

Looks like his was closed with #16, please let me know if there is still an issue.

@Jelly65
Copy link

Jelly65 commented Jul 9, 2023

#59

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

3 participants