Skip to content

Commit

Permalink
Use calculated fetch depth for versioned source checkout
Browse files Browse the repository at this point in the history
This should reduce our fetch depth in almost all cases
while still including commits required for versioning
and changelogs and release notes.

Reducing fetch depth saves a lot of time on the checkout
step present in most jobs, so every little bit helps.

Change-type: minor
Signed-off-by: Kyle Harding <[email protected]>
  • Loading branch information
klutchell committed Jul 15, 2024
1 parent 123b5c3 commit cdc9848
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 34 deletions.
66 changes: 34 additions & 32 deletions .github/workflows/flowzone.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions flowzone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
name: Checkout versioned commit
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
fetch-depth: ${{ needs.versioned_source.outputs.depth || 0 }}
submodules: "recursive"
# fallback to an invalid ref if the checkout ref is undefined
ref: "${{ needs.versioned_source.outputs.sha || '¯\_(ツ)_/¯' }}"
Expand All @@ -231,7 +231,13 @@
git fetch origin ${{ github.ref }}
git checkout FETCH_HEAD -- .github
- &describeGitState # Resolve tag, semver, sha, and description of current git working copy.
# Resolve tag, semver, sha, and description of current git working copy.
# tag is the latest tag that points to the current commit.
# semver is the semantic version of the tag.
# describe is the output of `git describe --tags --always --dirty`.
# sha is the full commit hash.
# depth is the number of commits since the second most recent tag.
- &describeGitState
name: Describe git state
id: git_describe
run: |
Expand All @@ -241,6 +247,7 @@
echo "semver=$(npx -q -y -- semver -c -l "${tag}")" ;
echo "describe=$(git describe --tags --always --dirty | cat)" ;
echo "sha=$(git rev-parse HEAD)" ;
echo "depth=$(git rev-list "$(git describe --tags --abbrev=0 "$(git rev-list --tags --skip=1 --max-count=1 2>/dev/null)")..HEAD" --count)" ;
} >> "${GITHUB_OUTPUT}"
- &createLocalRefs
Expand Down Expand Up @@ -1103,6 +1110,7 @@ jobs:
commit_sha: ${{ steps.create_commit.outputs.sha }}
author: ${{ steps.create_commit.outputs.bot }}
tag_sha: ${{ steps.create_tag.outputs.sha }}
depth: ${{ steps.git_describe.outputs.depth }}

env:
<<: *gitHubCliEnvironment
Expand Down

0 comments on commit cdc9848

Please sign in to comment.