Skip to content

Commit

Permalink
Merge pull request #46 from DataDog/lloeki/fix-parent-caching
Browse files Browse the repository at this point in the history
Fix parent caching
  • Loading branch information
lloeki authored Nov 28, 2024
2 parents e988fb7 + 9296fc7 commit d515e1a
Showing 1 changed file with 49 additions and 32 deletions.
81 changes: 49 additions & 32 deletions .github/workflows/build-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
fetch-depth: 2

# First, build image for x86_64 as it will fail fast
#
Expand All @@ -240,8 +241,9 @@ jobs:
if: ${{ contains(matrix.arch, 'x86_64') }}
run: |
cache_from=()
parents="$(git rev-list --parents -n 1 ${{ github.sha }})"
for sha in $parents; do
parents=( $(git rev-list --parents -n 1 ${{ github.sha }}) )
for sha in "${parents[@]}"; do
echo "${sha}"
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-g${sha})
done
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }})
Expand All @@ -250,8 +252,9 @@ jobs:
if: ${{ contains(matrix.arch, 'x86_64') }}
run: |
cache_from=()
parents="$(git rev-list --parents -n 1 ${{ github.sha }})"
for sha in $parents; do
parents=( $(git rev-list --parents -n 1 ${{ github.sha }}) )
for sha in "${parents[@]}"; do
echo "${sha}"
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-g${sha})
done
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }})
Expand All @@ -271,8 +274,9 @@ jobs:
if: ${{ contains(matrix.arch, 'x86_64') }}
run: |
cache_from=()
parents="$(git rev-list --parents -n 1 ${{ github.sha }})"
for sha in $parents; do
parents=( $(git rev-list --parents -n 1 ${{ github.sha }}) )
for sha in "${parents[@]}"; do
echo "${sha}"
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-g${sha})
done
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }})
Expand All @@ -281,8 +285,9 @@ jobs:
if: ${{ contains(matrix.arch, 'x86_64') && matrix.libc == 'musl' }}
run: |
cache_from=()
parents="$(git rev-list --parents -n 1 ${{ github.sha }})"
for sha in $parents; do
parents=( $(git rev-list --parents -n 1 ${{ github.sha }}) )
for sha in "${parents[@]}"; do
echo "${sha}"
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-gcc-g${sha})
done
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-gcc)
Expand All @@ -302,8 +307,9 @@ jobs:
if: ${{ contains(matrix.arch, 'aarch64') }}
run: |
cache_from=()
parents="$(git rev-list --parents -n 1 ${{ github.sha }})"
for sha in $parents; do
parents=( $(git rev-list --parents -n 1 ${{ github.sha }}) )
for sha in "${parents[@]}"; do
echo "${sha}"
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-g${sha})
done
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }})
Expand All @@ -312,8 +318,9 @@ jobs:
if: ${{ contains(matrix.arch, 'aarch64') }}
run: |
cache_from=()
parents="$(git rev-list --parents -n 1 ${{ github.sha }})"
for sha in $parents; do
parents=( $(git rev-list --parents -n 1 ${{ github.sha }}) )
for sha in "${parents[@]}"; do
echo "${sha}"
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-g${sha})
done
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }})
Expand All @@ -333,8 +340,9 @@ jobs:
if: ${{ contains(matrix.arch, 'aarch64') }}
run: |
cache_from=()
parents="$(git rev-list --parents -n 1 ${{ github.sha }})"
for sha in $parents; do
parents=( $(git rev-list --parents -n 1 ${{ github.sha }}) )
for sha in "${parents[@]}"; do
echo "${sha}"
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-g${sha})
done
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }})
Expand All @@ -343,8 +351,9 @@ jobs:
if: ${{ contains(matrix.arch, 'aarch64') && matrix.libc == 'musl' }}
run: |
cache_from=()
parents="$(git rev-list --parents -n 1 ${{ github.sha }})"
for sha in $parents; do
parents=( $(git rev-list --parents -n 1 ${{ github.sha }}) )
for sha in "${parents[@]}"; do
echo "${sha}"
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-gcc-g${sha})
done
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-gcc)
Expand All @@ -360,17 +369,19 @@ jobs:
- name: Push CI run image (${{ join(matrix.arch, ', ') }})
run: |
cache_from=()
parents="$(git rev-list --parents -n 1 ${{ github.sha }})"
for sha in $parents; do
parents=( $(git rev-list --parents -n 1 ${{ github.sha }}) )
for sha in "${parents[@]}"; do
echo "${sha}"
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-g${sha})
done
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }})
docker buildx build ${{ steps.vars.outputs.SRC }} "${cache_from[@]}" --output=type=image,push=true --build-arg BUILDKIT_INLINE_CACHE=1 --platform ${{ steps.vars.outputs.DOCKER_PLATFORMS }} -f ${{ steps.vars.outputs.DOCKERFILE }} --tag ${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.TAG }}
- name: Push commit image (${{ join(matrix.arch, ', ') }})
run: |
cache_from=()
parents="$(git rev-list --parents -n 1 ${{ github.sha }})"
for sha in $parents; do
parents=( $(git rev-list --parents -n 1 ${{ github.sha }}) )
for sha in "${parents[@]}"; do
echo "${sha}"
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-g${sha})
done
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }})
Expand All @@ -379,8 +390,9 @@ jobs:
if: ${{ inputs.push }}
run: |
cache_from=()
parents="$(git rev-list --parents -n 1 ${{ github.sha }})"
for sha in $parents; do
parents=( $(git rev-list --parents -n 1 ${{ github.sha }}) )
for sha in "${parents[@]}"; do
echo "${sha}"
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-g${sha})
done
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }})
Expand All @@ -391,8 +403,9 @@ jobs:
if: ${{ inputs.push && matrix.libc == 'gnu' }}
run: |
cache_from=()
parents="$(git rev-list --parents -n 1 ${{ github.sha }})"
for sha in $parents; do
parents=( $(git rev-list --parents -n 1 ${{ github.sha }}) )
for sha in "${parents[@]}"; do
echo "${sha}"
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-g${sha})
done
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }})
Expand All @@ -403,8 +416,9 @@ jobs:
if: ${{ matrix.libc == 'gnu' || matrix.libc == 'centos' }}
run: |
cache_from=()
parents="$(git rev-list --parents -n 1 ${{ github.sha }})"
for sha in $parents; do
parents=( $(git rev-list --parents -n 1 ${{ github.sha }}) )
for sha in "${parents[@]}"; do
echo "${sha}"
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-gcc-g${sha})
done
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-gcc)
Expand All @@ -413,8 +427,9 @@ jobs:
if: ${{ inputs.push && (matrix.libc == 'gnu' || matrix.libc == 'centos') }}
run: |
cache_from=()
parents="$(git rev-list --parents -n 1 ${{ github.sha }})"
for sha in $parents; do
parents=( $(git rev-list --parents -n 1 ${{ github.sha }}) )
for sha in "${parents[@]}"; do
echo "${sha}"
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-gcc-g${sha})
done
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-gcc)
Expand All @@ -429,8 +444,9 @@ jobs:
if: ${{ matrix.libc == 'musl' }}
run: |
cache_from=()
parents="$(git rev-list --parents -n 1 ${{ github.sha }})"
for sha in $parents; do
parents=( $(git rev-list --parents -n 1 ${{ github.sha }}) )
for sha in "${parents[@]}"; do
echo "${sha}"
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-gcc-g${sha})
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-g${sha})
done
Expand All @@ -441,8 +457,9 @@ jobs:
if: ${{ inputs.push && matrix.libc == 'musl' }}
run: |
cache_from=()
parents="$(git rev-list --parents -n 1 ${{ github.sha }})"
for sha in $parents; do
parents=( $(git rev-list --parents -n 1 ${{ github.sha }}) )
for sha in "${parents[@]}"; do
echo "${sha}"
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-gcc-g${sha})
cache_from+=(--cache-from=type=registry,ref=${{ steps.vars.outputs.IMAGE }}:${{ steps.vars.outputs.RELEASE_TAG }}-g${sha})
done
Expand Down

0 comments on commit d515e1a

Please sign in to comment.