ci(release-image): Skip setup steps when using persistent BuildKit

When BUILDKIT_ENDPOINT is set, the build happens on a remote BuildKit instance,
making several runner setup steps unnecessary:

- Rust toolchain installation (not needed for remote builds)
- QEMU setup (cross-platform emulation handled by BuildKit)
- All caching steps (Rust registry, cargo target, apt cache/lib)
- Cache injection step (BuildKit manages its own cache)
- Timelord timestamp caching (not needed with persistent build cache)

Also added output to git SHA and timestamp steps to show their values.

This should significantly reduce build time when using persistent BuildKit
by eliminating ~7 setup steps per matrix job.
This commit is contained in:
Tom Foster 2025-09-07 17:49:52 +01:00
commit 15f8ad8201

View file

@ -101,6 +101,7 @@ jobs:
with: with:
persist-credentials: false persist-credentials: false
- name: Install rust - name: Install rust
if: ${{ env.BUILDKIT_ENDPOINT == '' }}
id: rust-toolchain id: rust-toolchain
uses: ./.forgejo/actions/rust-toolchain uses: ./.forgejo/actions/rust-toolchain
@ -111,6 +112,7 @@ jobs:
driver: ${{ env.BUILDKIT_ENDPOINT != '' && 'remote' || 'docker-container' }} driver: ${{ env.BUILDKIT_ENDPOINT != '' && 'remote' || 'docker-container' }}
endpoint: ${{ env.BUILDKIT_ENDPOINT || '' }} endpoint: ${{ env.BUILDKIT_ENDPOINT || '' }}
- name: Set up QEMU - name: Set up QEMU
if: ${{ env.BUILDKIT_ENDPOINT == '' }}
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Login to builtin registry - name: Login to builtin registry
@ -144,11 +146,13 @@ jobs:
run: echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV run: echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
- uses: ./.forgejo/actions/timelord - uses: ./.forgejo/actions/timelord
if: ${{ env.BUILDKIT_ENDPOINT == '' }}
with: with:
key: timelord-v0 key: timelord-v0
path: . path: .
- name: Cache Rust registry - name: Cache Rust registry
if: ${{ env.BUILDKIT_ENDPOINT == '' }}
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: | path: |
@ -158,6 +162,7 @@ jobs:
.cargo/registry/src .cargo/registry/src
key: rust-registry-image-${{hashFiles('**/Cargo.lock') }} key: rust-registry-image-${{hashFiles('**/Cargo.lock') }}
- name: Cache cargo target - name: Cache cargo target
if: ${{ env.BUILDKIT_ENDPOINT == '' }}
id: cache-cargo-target id: cache-cargo-target
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
@ -165,6 +170,7 @@ jobs:
cargo-target-${{ matrix.target_cpu }}-${{ matrix.slug }}-${{ matrix.profile }} cargo-target-${{ matrix.target_cpu }}-${{ matrix.slug }}-${{ matrix.profile }}
key: cargo-target-${{ matrix.target_cpu }}-${{ matrix.slug }}-${{ matrix.profile }}-${{hashFiles('**/Cargo.lock') }}-${{steps.rust-toolchain.outputs.rustc_version}} key: cargo-target-${{ matrix.target_cpu }}-${{ matrix.slug }}-${{ matrix.profile }}-${{hashFiles('**/Cargo.lock') }}-${{steps.rust-toolchain.outputs.rustc_version}}
- name: Cache apt cache - name: Cache apt cache
if: ${{ env.BUILDKIT_ENDPOINT == '' }}
id: cache-apt id: cache-apt
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
@ -172,6 +178,7 @@ jobs:
var-cache-apt-${{ matrix.slug }} var-cache-apt-${{ matrix.slug }}
key: var-cache-apt-${{ matrix.slug }} key: var-cache-apt-${{ matrix.slug }}
- name: Cache apt lib - name: Cache apt lib
if: ${{ env.BUILDKIT_ENDPOINT == '' }}
id: cache-apt-lib id: cache-apt-lib
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
@ -179,6 +186,7 @@ jobs:
var-lib-apt-${{ matrix.slug }} var-lib-apt-${{ matrix.slug }}
key: var-lib-apt-${{ matrix.slug }} key: var-lib-apt-${{ matrix.slug }}
- name: inject cache into docker - name: inject cache into docker
if: ${{ env.BUILDKIT_ENDPOINT == '' }}
uses: https://github.com/reproducible-containers/buildkit-cache-dance@v3.3.0 uses: https://github.com/reproducible-containers/buildkit-cache-dance@v3.3.0
with: with:
cache-map: | cache-map: |