ci: share Linux restore artifacts before builds [CI]
This commit is contained in:
1 parent
a6f9759238
commit
806493567b
13 files changed
+211
-82
No files matched your search
+8
-41
@@ -24,7 +24,7 @@ moshiro_setup_buildah "$base_home"
|
||||
cleanup() {
|
||||
local status=$?
|
||||
trap - EXIT
|
||||
rm -rf "$work/context" "$work/binaries" "$work/packages" "$work/nativeaot-builder"
|
||||
rm -rf "$work/context" "$work/binaries" "$work/packages"
|
||||
flock -u 9
|
||||
if flock -n -x 9; then
|
||||
bash "$root/ci/cleanup-build-cache.sh" || echo 'warning: build cache cleanup failed' >&2
|
||||
@@ -33,45 +33,12 @@ cleanup() {
|
||||
}
|
||||
trap cleanup EXIT
|
||||
context="$work/context"
|
||||
# Serialize toolchain import/build; the native jobs use its resolved immutable ID.
|
||||
exec 7> "$base_home/.toolchain.lock"
|
||||
echo "[$rid] waiting for the shared NativeAOT toolchain lock"
|
||||
flock -w 1800 7
|
||||
echo "[$rid] acquired the toolchain lock; checking the local cache"
|
||||
builder_image="localhost/moshiro-dotnet10-nativeaot-aotanywhere:ci"
|
||||
source "$root/ci/nativeaot-toolchain.sh"
|
||||
moshiro_nativeaot_settings "$root"
|
||||
builder_cache="${MOSHIRO_RUNNER_IMAGE_CACHE:-/home/justme/woodpecker/cache/runner-image}"
|
||||
cached_key="$(cat "$builder_cache/nativeaot-builder.key" 2>/dev/null || true)"
|
||||
builder_id="$(cat "$builder_cache/nativeaot-builder.id" 2>/dev/null || true)"
|
||||
local_key="$(cat "$base_home/nativeaot-builder.key" 2>/dev/null || true)"
|
||||
local_builder_id="$(buildah images --noheading --no-trunc --format '{{.ID}}' "$builder_image" 2>/dev/null || true)"
|
||||
if [[ "$local_key" == "$MOSHIRO_NATIVEAOT_BUILDER_KEY" && "${local_builder_id#sha256:}" =~ ^[0-9a-f]{64}$ ]]; then
|
||||
echo "[$rid] reusing the toolchain already built in this store"
|
||||
elif [[ "$cached_key" == "$MOSHIRO_NATIVEAOT_BUILDER_KEY" && "$builder_id" =~ ^[0-9a-f]{64}$ && -f "$builder_cache/nativeaot-builder-$builder_id.oci" ]]; then
|
||||
local_builder_id="$(buildah images --noheading --no-trunc --format '{{.ID}}' "$builder_image" 2>/dev/null || true)"
|
||||
if [[ "${local_builder_id#sha256:}" != "$builder_id" ]]; then
|
||||
python3 "$root/ci/run-with-timeout.py" 600 buildah pull "oci-archive:$builder_cache/nativeaot-builder-$builder_id.oci"
|
||||
buildah tag "$builder_id" "$builder_image"
|
||||
fi
|
||||
echo "using cached NativeAOT toolchain $builder_id"
|
||||
else
|
||||
builder_context="$work/nativeaot-builder"
|
||||
mkdir -p "$builder_context"
|
||||
tr -d '\r' < "$root/global.json" > "$builder_context/global.json"
|
||||
touch -t 200001010000 "$builder_context/global.json"
|
||||
echo "[$rid] preparing the shared toolchain (other targets wait for this build)"
|
||||
python3 "$root/ci/run-with-timeout.py" 1800 buildah bud --layers --force-rm --network host --tls-verify=true --arch amd64 \
|
||||
--build-arg "AOTANYWHERE_VERSION=$MOSHIRO_AOTANYWHERE_VERSION" \
|
||||
--build-arg "ZIG_TOOLSET_VERSION=$MOSHIRO_ZIG_TOOLSET_VERSION" \
|
||||
-f "$root/packaging/container/NativeAot.Builder.Containerfile" \
|
||||
-t "$builder_image" "$builder_context"
|
||||
fi
|
||||
builder_image="$(buildah images --noheading --no-trunc --format '{{.ID}}' "$builder_image")"
|
||||
printf '%s\n' "$MOSHIRO_NATIVEAOT_BUILDER_KEY" > "$base_home/nativeaot-builder.key"
|
||||
echo "[$rid] toolchain ready: $builder_image; starting the native build"
|
||||
flock -u 7
|
||||
exec 7>&-
|
||||
restore_image="localhost/moshiro-agent-restore:${CI_COMMIT_SHA}-${rid}"
|
||||
restore_id="$(buildah images --noheading --no-trunc --format '{{.ID}}' "$restore_image" 2>/dev/null || true)"
|
||||
[[ "${restore_id#sha256:}" =~ ^[0-9a-f]{64}$ ]] || {
|
||||
echo "missing prepared restore image $restore_image; run restore-linux-dependencies.sh first" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
commit_epoch="$(git -C "$root" show -s --format=%ct "$CI_COMMIT_SHA")"
|
||||
built_at="$(date -u -d "@$commit_epoch" +%Y-%m-%dT%H:%M:%SZ)"
|
||||
@@ -80,7 +47,7 @@ local_image="localhost/moshiro-agent-binaries:$rid"
|
||||
# Buildah --jobs runs independent native-link stages concurrently.
|
||||
python3 "$root/ci/run-with-timeout.py" 1800 buildah bud --layers --force-rm --jobs 2 --network host \
|
||||
--tls-verify=true --ulimit nofile=65536:65536 --arch amd64 \
|
||||
--build-arg "NATIVEAOT_BUILDER_IMAGE=$builder_image" \
|
||||
--build-arg "NATIVEAOT_RESTORE_IMAGE=$restore_image" \
|
||||
--build-arg "NODE_RID=$rid" --build-arg "STATIC_MSQUIC=$static_msquic" \
|
||||
--build-arg "APP_VERSION=$MOSHIRO_VERSION" --build-arg "MOSHIRO_TAG=$MOSHIRO_TAG" \
|
||||
--build-arg "MOSHIRO_COMMIT=${CI_COMMIT_SHA:0:10}" --build-arg "MOSHIRO_BUILT_AT=$built_at" \
|
||||
|
||||
Reference in new issue
Block a user