johnwason / vcpkg-action

Simple vcpkg action to build and cache packages
MIT License
19 stars 6 forks source link

Manifest mode and `revision: master` do not work due to shallow git fetch #21

Closed seanmiddleditch closed 9 months ago

seanmiddleditch commented 1 year ago

Given manifest mode with a vcpkg.json file using the August 2023 vcpkg baseline, but requiring a package only available in newer vcpkg commits (capnproto 1.0.1):

{
  "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
  "name": "test-project",
  "version": "0.15.2",
  "dependencies": [
    {
      "name": "capnproto",
      "version>=": "1.0.1"
    },
    "catch2",
  ],
  "builtin-baseline": "9edb1b8e590cc086563301d735cae4b6e732d2d2"
}

And a GitHub Action requesting revision: master:

      - name: vcpkg
        id: vcpkg
        uses: johnwason/vcpkg-action@v5
        with:
          manifest-dir: ${{ github.workspace }}
          triplet: x64-linux
          revision: master
          token: ${{ github.token }}

Results in the following error:

error: while checking out baseline from commit '9edb1b8e590cc086563301d735cae4b6e732d2d2', failed to `git show` versions/baseline.json. This may be fixed by fetching commits with `git fetch`.
error: git failed with exit code: (128).
fatal: path 'versions/baseline.json' exists on disk, but not in '9edb1b8e590cc086563301d735cae4b6e732d2d2'

This appears to be due to the use of shallow git fetch (fetch-depth: 1 in the checkout-vcpkg step). I disabled shallow fetch in a clone of this action and verified that it resolves the issue for me.

A proper fix that better fits the intent of being optimal when using the latest release may be to add an action option to disable shallow fetch, or perhaps to automatically disable it if the revision option is provided.

  - name: checkout-vcpkg
    uses: actions/checkout@v3
    with:
      path: ${{ github.workspace }}/vcpkg
      repository: microsoft/vcpkg
      ref: '${{ steps.determine-checkout-revision.outputs.vcpkg-revision }}'
      fetch-depth: 1 # <--- PROBLEM! replace with fetch-depth: 0
johnwason commented 1 year ago

Please propose a pull request

gnu-lorien commented 10 months ago

There seems to be code here, but I don't see a pull request for it: https://github.com/seanmiddleditch/vcpkg-action

I recently ran into this problem described by https://github.com/microsoft/vcpkg/issues/25349. That fork fixed it for me.