mirror of
https://github.com/authelia/authelia.git
synced 2026-10-28 09:34:52 +08:00
Every agent shares one Docker daemon, and the coverage build used the same `authelia:dist` tag that every suite's `pre-command` loads, retags and removes. When another build's suites loaded their image between this build's `docker build` and the `docker save` in `pre-artifact`, the tag was gone (`reference does not exist`) or pointed at the other build's image. Since `pre-artifact` had no `pipefail`, the failed save uploaded an empty archive, the job passed and every suite in the build failed on load. The coverage image is now built under a per-job tag through a new `--tag` flag on `authelia-scripts docker build`. `pre-artifact` takes `authelia:dist` only to save the archive, inside the same lock the suites hold around their load, and `pre-exit` removes the per-job tag. With every write to `authelia:dist` under that lock, suites can no longer pick up another build's image between their load and retag either. `pre-artifact` now fails the job when the save fails, and skips the save when the build itself failed or was cancelled. Signed-off-by: Amir Zarrinkafsh <3339418+nightah@users.noreply.github.com>
27 lines
787 B
Bash
Executable File
27 lines
787 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# SPDX-FileCopyrightText: 2026 Authelia
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
set +u
|
|
|
|
DOCKER_IMAGE=authelia:dist
|
|
|
|
if [[ "${BUILDKITE_LABEL}" == ":hammer_and_wrench: Unit Test" ]]; then
|
|
echo "--- :docker: Saving artifacts for :buildkite: :docker: :github: releases"
|
|
mv goreleaser/* ./
|
|
rm -rf goreleaser
|
|
fi
|
|
|
|
if [[ "${BUILDKITE_LABEL}" == ":docker: Build Image [coverage]" ]] && [[ "${BUILDKITE_COMMAND_EXIT_STATUS}" == 0 ]]; then
|
|
set -o pipefail
|
|
(
|
|
flock 9
|
|
docker tag "authelia:dist-${BUILDKITE_JOB_ID}" "${DOCKER_IMAGE}" && docker save "${DOCKER_IMAGE}" | zstdmt -T0 -12 > "authelia-image-coverage.tar.zst"
|
|
rc=$?
|
|
docker rmi "${DOCKER_IMAGE}" > /dev/null 2>&1
|
|
exit "${rc}"
|
|
) 9> /buildkite/.cache/authelia-image-load.lock || exit 1
|
|
fi
|