conan-io / docs

conan.io reStructuredText documentation
http://docs.conan.io
MIT License
110 stars 361 forks source link

[bug] scm capture fails during Github PR workflow #3868

Open planetmarshall opened 2 months ago

planetmarshall commented 2 months ago

Describe the bug

Not strictly a conan bug, more of an oversight in the documentation but since the Documentation on SCM capture explicitly uses a github workflow as illustration, it's probably worth reporting.

Expected Result

A conanfile using the SCM capture feature should build during a workflow triggered by a Github PR event

Actual Result

Conanfile build fails with

fatal: unable to read tree (cf912fbe1bc5dee48e6117f9a34b60f59a51f578)

See Logs for failing action.

Workaround

Explicitly specify the pull request head ref when checking out the code

- name: Checkout
  uses: actions/checkout@v4
  with:
    ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
    ref: ${{ github.event.pull_request.head.sha }}

How to reproduce it

Clone the repository at https://github.com/planetmarshall/conan-scm-capture.git and create a pull request for the setup-ci branch

memsharded commented 2 months ago

Thanks for pointing this out @planetmarshall

I agree it would be good to at least add some note in the docs.

But I'd like to ask first, just in case. At the moment, the scm approach is doing internally:

commit = self.run(f'rev-list HEAD -n 1 --full-history {path}')

And this is the command that is failing in case of that PR checkout. Is there any other way to get a "permanent" commit reference that could be used? Or is that PR checkout by default kind of a headless checkout and it is not possible to obtain a commit

memsharded commented 2 months ago

Hi @planetmarshall

Any further feedback here? What do you think would be the best approach, just a note in the docs?

memsharded commented 1 month ago

Moving this to the docs repo.