Skip to content

Commit

Permalink
Insufficient repository fetch-depth for action workflows (#109)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
svengreb authored Nov 21, 2021
1 parent cabd635 commit c39b2c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())),
Expand Down

0 comments on commit c39b2c4

Please sign in to comment.