Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parent caching #46

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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