From c39b2c4233b1e14c5b971131db1368c4e3670d2f Mon Sep 17 00:00:00 2001 From: Sven Greb Date: Sun, 21 Nov 2021 11:16:40 +0100 Subject: [PATCH] Insufficient repository fetch-depth for action workflows (#109) The GitHub action workflows [1] using the `actions/checkout` action [2] to fetch the repository that triggered the workflow. However, by default only the history of the latest commit was fetched which resulted in errors when wand tried to extract repository metadata information like the amount of commits ahead of the latest commit. As an example this can be seen when running the `bootstrap` command in the `test` job of the `ci-go` workflow [5] which failed with an `object not found` error because the history only contains a single commit. To fix this problem `action/checkout` provides an option to fetch all history for all tags and branches [3] which is now used to prevent errors like this in the pipeline. [1]: https://github.com/svengreb/wand/tree/9caf10f9d3b0c97e1f6c18b29c175e71764b0ece/.github/workflows [2]: https://github.com/actions/checkout [3]: https://github.com/actions/checkout#Fetch-all-history-for-all-tags-and-branches [4]: https://github.com/svengreb/wand/blob/cabd635c4ec73680b1776e7c536feca16643b00b/magefile.go#L136 [5]: https://github.com/svengreb/wand/runs/4275275079?check_suite_focus=true Closes GH-108 --- .github/workflows/ci-go.yaml | 5 +++++ magefile.go | 1 + 2 files changed, 6 insertions(+) diff --git a/.github/workflows/ci-go.yaml b/.github/workflows/ci-go.yaml index cdcbe5c..396f02a 100644 --- a/.github/workflows/ci-go.yaml +++ b/.github/workflows/ci-go.yaml @@ -50,6 +50,11 @@ jobs: echo "Workflow Actor: $GITHUB_ACTOR" - name: Checkout repository uses: actions/checkout@v2 + with: + # Ensure to fetch all history for all tags and branches for other steps, e.g. when bootstrapping the tools, + # otherwise this can result in errors when trying to query for repository metadata like the tag. + # See https://github.com/actions/checkout#Fetch-all-history-for-all-tags-and-branches for more details. + fetch-depth: 0 - name: Install Go 1.17 uses: actions/setup-go@v2 with: diff --git a/magefile.go b/magefile.go index 30f6c73..2525c9b 100644 --- a/magefile.go +++ b/magefile.go @@ -110,6 +110,7 @@ func init() { wandProj.WithName(projectSupport.Name), wandProj.WithDisplayName(projectSupport.DisplayName), wandProj.WithVCSKind(wandProjVCS.KindGit), + wandProj.WithDefaultVersion(projectSupport.ReleaseVersion), ), elder.WithGoRunnerOptions( taskGo.WithRunnerEnv(osSupport.EnvSliceToMap(os.Environ())),