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] fatal: ref HEAD is not a symbolic ref thrown by Buildx in CI workflow triggered by a PR #2542

Closed
3 tasks done
tschaffter opened this issue Mar 1, 2024 · 5 comments · Fixed by #2544
Closed
3 tasks done
Assignees
Labels
bug Something isn't working ci Continuous integration docker

Comments

@tschaffter
Copy link
Member

tschaffter commented Mar 1, 2024

Is there an existing issue for this?

  • I have searched the existing issues

What product(s) are you seeing the problem on?

Sage Monorepo

Current behavior

This bug is following the merge of this PR: #2538

The task build-image fails when run by the CI workflow in PRs.

 nx run openchallenges-api-docs:build-image


>  Docker info 

/usr/bin/docker version
Client: Docker Engine - Community
 Version:           24.0.5
 API version:       1.43
 Go version:        go1.20.6
 Git commit:        ced0996
 Built:             Fri Jul 21 20:35:18 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.5
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.6
  Git commit:       a61e2b4
  Built:            Fri Jul 21 20:35:18 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
/usr/bin/docker info
Client: Docker Engine - Community
 Version:    24.0.5
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.1
    Path:     /home/vscode/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.24.6
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 24.0.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.5.0-1015-azure
 Operating System: Ubuntu 22.04.2 LTS (containerized)
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 15.61GiB
 Name: 0848af3701b8
 ID: d9e9d8bc-e782-456c-a4bc-d7e79f4561cd
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false


>  Buildx version 

/usr/bin/docker buildx version
github.com/docker/buildx v0.12.1 30feaa1a915b869ebc2eea6328624b49facd4bfb
Unsupported CI Provider... Using Local Environment as fallback
/usr/bin/git log -1 --pretty=format:%ae
haffter@gmail.com[command]/usr/bin/git symbolic-ref HEAD
fatal: ref HEAD is not a symbolic ref

>  Removing temp folder /tmp/docker-build-push-XVoFAY 


 >  NX   The process '/usr/bin/git' failed with exit code 128

Expected behavior

Here are the logs of the last run of this task, triggered when pushing to main and for the challenge service.

 >  Buildx version 

/usr/bin/docker buildx version
github.com/docker/buildx v0.12.1 30feaa1a915b869ebc2eea6328624b49facd4bfb
Unsupported CI Provider... Using Local Environment as fallback
/usr/bin/git log -1 --pretty=format:%ae
github-actions[bot]@users.noreply.github.com[command]/usr/bin/git symbolic-ref HEAD
refs/heads/main
/usr/bin/git rev-parse HEAD
97a2ef0a32fccc32d9f2c4dcfebf8b8a01d49711

>  Context info 

eventName: push
sha: 97a2ef0a32fccc32d9f2c4dcfebf8b8a01d49711
ref: refs/heads/main
actor: 41898282+github-actions[bot]@users.noreply.github.com
runNumber: 0
runId: 0

Anything else?

No response

Commit ID

No response

Are you developing inside the dev container?

  • I am using the dev container

Code of Conduct

  • I agree to follow this project's Code of Conduct
@tschaffter tschaffter added the bug Something isn't working label Mar 1, 2024
@tschaffter tschaffter self-assigned this Mar 1, 2024
@tschaffter tschaffter added ci Continuous integration docker labels Mar 1, 2024
@tschaffter
Copy link
Member Author

@mdsage1 bumped into this issue in a PR for these projects:

  • openchallenges-organization-service:build-image

I bumped into this issue for these projects:

  • openchallenges-api-docs:build-image
  • openchallenges-app:build-image
  • openchallenges-challenge-service:build-image
  • openchallenges-organization-service:build-image
  • openchallenges-image-service:build-image

@tschaffter
Copy link
Member Author

The project openchallenges-app ran the build-image task successfully in the CI workflow when pushing to main.

>  Buildx version 

/usr/bin/docker buildx version
github.com/docker/buildx v0.12.1 30feaa1a915b869ebc2eea6328624b49facd4bfb
Unsupported CI Provider... Using Local Environment as fallback
/usr/bin/git log -1 --pretty=format:%ae
pchung@users.noreply.github.com[command]/usr/bin/git symbolic-ref HEAD
refs/heads/main
/usr/bin/git rev-parse HEAD
da6340af0af9d2ce1fd22ad2082fef3ee2fd51f1

@tschaffter
Copy link
Member Author

actions/checkout has always checked out a merge commit during pull request events. This is not a branch, it's a commit that is a merge of the pull request branch and the base. This is so CI can test the merge before it happens. If you are trying to create a pull request to merge into your existing pull request branch then you don't want to do that on the merge commit, instead you should checkout the head_ref. See the documentation here.

Source

@tschaffter
Copy link
Member Author

The solution I found is to switch from the detach head to a new branch:

* (HEAD detached at pull/2534/merge) b5977331 Merge 21015cda8e8a29260f5d93574ccaad6377f007e5 into 394b97a1fdd194393b3e8d3e04f7235a5d225ef9
Switched to a new branch 'new-branch'
* new-branch b5977331 Merge 21015cda8e8a29260f5d93574ccaad6377f007e5 into 394b97a1fdd194393b3e8d3e04f7235a5d225ef9

Buildx then runs successfully from this branch.

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

Successfully merging a pull request may close this issue.

1 participant