ci: bake cached toolchain into Podman agent and fix nested Buildah [CI]

This commit is contained in:
justme committed 2026-10-10 05:44:21 -07:00
1 parent 2e1dbcf4ce
commit 1975253beb
18 files changed
+215 -29

No files matched your search

+24 -9
View File
@@ -97,6 +97,8 @@ fi
export HOME="$base_home"
export BUILDAH_HOME="$base_home"
source "$root/ci/buildah-env.sh"
moshiro_setup_buildah "$base_home"
export REGISTRY_AUTH_FILE="$work/$component-auth.json"
context="$work/$component"
local_image="localhost/moshiro-$component:dev-$arch-check"
@@ -106,15 +108,28 @@ node_rid="linux-musl-x64"
# Buildah store. Keeping NuGet inside image layers avoids a shared writable
# package mount being corrupted by canceled or parallel builds.
builder_image="localhost/moshiro-dotnet10-nativeaot-aotanywhere:ci"
builder_context="$work/nativeaot-builder"
mkdir -p "$builder_context/backend"
install -m 0644 "$root/global.json" "$builder_context/global.json"
install -m 0644 "$root/Directory.Packages.props" "$builder_context/Directory.Packages.props"
install -m 0644 "$root/backend/Directory.Build.props" "$builder_context/backend/Directory.Build.props"
install -m 0644 "$root/backend/BannedSymbols.txt" "$builder_context/backend/BannedSymbols.txt"
run_bounded 30m buildah bud --layers --network host --tls-verify=true --arch amd64 \
-f "$root/packaging/container/NativeAot.Builder.Containerfile" \
-t "$builder_image" "$builder_context"
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)"
if [[ "$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
run_bounded 10m 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"
run_bounded 30m buildah bud --layers --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
# A stable timestamp lets a retry of the same commit reuse the publish layer.
commit_epoch="$(git -C "$root" show -s --format=%ct "$CI_COMMIT_SHA")"