Skip to content

Commit

Permalink
.github/zephyr: simplify and fix the git describe performance hack
Browse files Browse the repository at this point in the history
Fixes the git describe/tag performance hack added in
commit 2328478 (".github/zephyr.yml: fix tags missing from `git -C
zephyr/ describe`") which worked for an amazingly long time (1.5 year)
but apparently ran its course. Git version 2.48 apparently does not like
it anymore. Replace it with something slower but simpler and safer.

Should fix build reproducibility issue thesofproject#9797, much more details there.

Also fixes commit 4bc6488 (".github/zephyr: de-hardcode the name of
the zephyr remote")

Signed-off-by: Marc Herbert <[email protected]>
  • Loading branch information
marc-hb committed Jan 28, 2025
1 parent 503ae3e commit 42403a1
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions .github/workflows/zephyr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ jobs:
time west update --narrow --fetch-opt=--filter=tree:0

- name: select zephyr revision
working-directory: ${{ github.workspace }}/workspace
run: |
cd workspace
if [ 'mnfst' = '${{ matrix.zephyr_revision }}' ]; then
rem_rev=$(git -C zephyr rev-parse HEAD)
else
Expand All @@ -170,6 +170,11 @@ jobs:
time west update --narrow --fetch-opt=--filter=tree:0
fi
# Get some tags to fix `git describe`
# Keep in sync with build-windows below
- name: Fetch tags for git describe
working-directory: ${{ github.workspace }}/workspace/zephyr
run: |
# Because we used git tricks to speed things up, we now have two git
# problems:
#
Expand All @@ -179,16 +184,19 @@ jobs:
# does not use --tags.
#
# 2. west fetches using the remote URL, not the remote name. So remote
# branches (if any) are missing from --decorate below
#
# => an "empty" and quick fetch _with_ a refspec and the remote name fixes
# both issues in no time.
cd zephyr
time git fetch --filter=tree:0 "$(git remote |head -n1)" "$rem_rev":_branch_placeholder
git branch -D _branch_placeholder
# branches are missing from --decorate below. Cosmetic but annoying;
# especially in the "zmain" case.
set -x
# Fix problem 2. Do NOT assume anything about remote names: nothing is guaranteed.
_zurl=$(west list -f '{url}' zephyr)
# Use an ugly remote name to avoid a collision
git remote add sof_zep_rem "$_zurl"
time git fetch --filter=tree:0 sof_zep_rem "$rem_rev"
# Fix problem 1. Indirectly fetches useless branches but is very quick thanks to
# the --filter
time git fetch --filter=tree:0 --tags sof_zep_rem
west list
west status
git log --oneline -n 5 --decorate --graph --no-abbrev-commit
Expand Down Expand Up @@ -327,12 +335,23 @@ jobs:
west init -l sof
west update --narrow --fetch-opt=--filter=tree:0
# Get some tags to fix `git describe`, see build-linux comments above.
cd zephyr
# Get some tags to fix `git describe` etc., see detailed build-linux comments above.
- name: Fetch tags for git describe
working-directory: ${{ github.workspace }}/workspace/zephyr
# Keep in sync with build-linux above
run: |
# Set-PSDebug -Trace 2
$_rev = "$(git rev-parse HEAD)"
git fetch --filter=tree:0 "$(west list -f '{url}' zephyr)" "${_rev}:_branch_placeholder"
git branch -D _branch_placeholder
$_zurl = "$(west list -f '{url}' zephyr)"
git remote add sof_zep_rem "${_zurl}"
# Unlike Linux above, hardcode "main" for now. Will make no difference most
# of the time but keeps this bit consistent with Linux, tested and ready to use.
git fetch --filter=tree:0 sof_zep_rem main
git fetch --filter=tree:0 --tags sof_zep_rem
west list
west status
git log --oneline -n 5 --decorate --graph --no-abbrev-commit
# Call Setup Python again to save the PIP packages in cache
- name: Setup Python
Expand Down

0 comments on commit 42403a1

Please sign in to comment.