CI: map nested Docker workspace
Container CI / release-build (push) Successful in 16m18s
Signed release / publish (push) Failing after 11s

Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-07-26 03:41:17 +03:00
1 parent 2e8e1fc0ba
commit 523355a128
4 files changed
+69 -64

No files matched your search

+5 -5
View File
@@ -31,11 +31,11 @@ services:
Leave `container.docker_host` at its generated default (`""`) so `act_runner` Leave `container.docker_host` at its generated default (`""`) so `act_runner`
passes the detected Docker endpoint to job containers. Do not set it to `-`, passes the detected Docker endpoint to job containers. Do not set it to `-`,
which explicitly prevents that endpoint from being mounted. Restart the runner which explicitly prevents that endpoint from being mounted. Restart the runner
after changing its configuration. `scripts/release.sh` detects when it is after changing its configuration. `scripts/lib/docker-daemon-path.sh` detects
running inside the job container and translates the checked-out workspace when commands run inside the job container and translates checked-out paths
through that container's Docker mount table. This is required because bind through that container's Docker mount table. The release wrapper and
mount paths passed to the socket are resolved by the runner host daemon, not control-plane tests both use it because bind mount paths passed to the socket
inside the Actions job container. are resolved by the runner host daemon, not inside the Actions job container.
The SSH checkout steps pin the current `git.faumaray.ru` RSA host key. Its The SSH checkout steps pin the current `git.faumaray.ru` RSA host key. Its
verified fingerprint is verified fingerprint is
+5 -2
View File
@@ -41,16 +41,19 @@ jobs:
scripts/release.sh --version "$CI_VERSION" scripts/release.sh --version "$CI_VERSION"
- name: Test release control-plane scripts - name: Test release control-plane scripts
shell: bash
run: | run: |
set -eu set -eu
bash scripts/tests/test-gitea-tag-verification.sh bash scripts/tests/test-gitea-tag-verification.sh
. scripts/lib/docker-daemon-path.sh
docker_workspace=$(docker_daemon_path "$PWD")
docker run --rm --network none \ docker run --rm --network none \
--volume "$PWD:/workspace:ro" \ --volume "$docker_workspace:/workspace:ro" \
--workdir /workspace \ --workdir /workspace \
echoion-release-builder:gcc-16.1.0 \ echoion-release-builder:gcc-16.1.0 \
python3 scripts/tests/test_aggregate_update_feed.py python3 scripts/tests/test_aggregate_update_feed.py
docker run --rm --network none \ docker run --rm --network none \
--volume "$PWD:/workspace:ro" \ --volume "$docker_workspace:/workspace:ro" \
--workdir /workspace \ --workdir /workspace \
echoion-release-builder:gcc-16.1.0 \ echoion-release-builder:gcc-16.1.0 \
python3 scripts/tests/test_gitea_release.py python3 scripts/tests/test_gitea_release.py
+56
View File
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
# Translate a path visible inside a containerized CI job into the source path
# understood by the Docker daemon. On a regular host this returns the input
# unchanged.
docker_daemon_path() {
local path=$1
local container_reference=${ECHOION_DOCKER_CONTAINER_ID:-}
local mount_data=
local mount_source mount_destination
local best_source='' best_destination=''
if [[ -z $container_reference ]]; then
container_reference=${JOB_CONTAINER_NAME:-${HOSTNAME:-}}
fi
if [[ -n ${ECHOION_DOCKER_CONTAINER_ID:-} ||
-f /.dockerenv || -f /run/.containerenv ]]; then
if [[ -n $container_reference ]]; then
mount_data=$(
docker inspect \
--format '{{range .Mounts}}{{printf "%s\t%s\n" .Source .Destination}}{{end}}' \
"$container_reference" 2>/dev/null || true
)
fi
fi
while IFS=$'\t' read -r mount_source mount_destination; do
[[ -n $mount_source && -n $mount_destination ]] || continue
case $path in
"$mount_destination"|"$mount_destination"/*)
if ((${#mount_destination} > ${#best_destination})); then
best_source=$mount_source
best_destination=$mount_destination
fi
;;
*)
if [[ $mount_destination == / && $path == /* ]]; then
best_source=$mount_source
best_destination=$mount_destination
fi
;;
esac
done <<<"$mount_data"
if [[ -z $best_destination ]]; then
printf '%s\n' "$path"
elif [[ $path == "$best_destination" ]]; then
printf '%s\n' "$best_source"
elif [[ $best_destination == / ]]; then
printf '%s/%s\n' "${best_source%/}" "${path#/}"
else
printf '%s/%s\n' \
"${best_source%/}" "${path#"$best_destination"/}"
fi
}
+3 -57
View File
@@ -60,6 +60,9 @@ canonical_release_version() {
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P) script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)
source_dir=$(cd -- "$script_dir/.." && pwd -P) source_dir=$(cd -- "$script_dir/.." && pwd -P)
# shellcheck source-path=SCRIPTDIR
# shellcheck source=lib/docker-daemon-path.sh
source "$script_dir/lib/docker-daemon-path.sh"
version= version=
build_dir="$source_dir/build-release" build_dir="$source_dir/build-release"
dist_dir="$source_dir/dist" dist_dir="$source_dir/dist"
@@ -205,63 +208,6 @@ container_path() {
esac esac
} }
docker_daemon_path() {
local path=$1
local container_reference=${ECHOION_DOCKER_CONTAINER_ID:-}
local mount_data=
local mount_source mount_destination
local best_source='' best_destination=''
if [[ -z $container_reference ]]; then
container_reference=${JOB_CONTAINER_NAME:-${HOSTNAME:-}}
fi
# A containerized CI job talks to the host Docker daemon through its
# socket. Bind-mount source paths are therefore interpreted in the daemon
# host namespace, not in this job container. Resolve the longest matching
# mount from the current container so nested release containers see the
# checked-out workspace instead of an empty host directory.
if [[ -n ${ECHOION_DOCKER_CONTAINER_ID:-} ||
-f /.dockerenv || -f /run/.containerenv ]]; then
if [[ -n $container_reference ]]; then
mount_data=$(
docker inspect \
--format '{{range .Mounts}}{{printf "%s\t%s\n" .Source .Destination}}{{end}}' \
"$container_reference" 2>/dev/null || true
)
fi
fi
while IFS=$'\t' read -r mount_source mount_destination; do
[[ -n $mount_source && -n $mount_destination ]] || continue
case $path in
"$mount_destination"|"$mount_destination"/*)
if ((${#mount_destination} > ${#best_destination})); then
best_source=$mount_source
best_destination=$mount_destination
fi
;;
*)
if [[ $mount_destination == / && $path == /* ]]; then
best_source=$mount_source
best_destination=$mount_destination
fi
;;
esac
done <<<"$mount_data"
if [[ -z $best_destination ]]; then
printf '%s\n' "$path"
elif [[ $path == "$best_destination" ]]; then
printf '%s\n' "$best_source"
elif [[ $best_destination == / ]]; then
printf '%s/%s\n' "${best_source%/}" "${path#/}"
else
printf '%s/%s\n' \
"${best_source%/}" "${path#"$best_destination"/}"
fi
}
if ((use_container)); then if ((use_container)); then
command -v docker >/dev/null || die "docker is required for --container" command -v docker >/dev/null || die "docker is required for --container"
container_build_dir=$(container_path "$build_dir") container_build_dir=$(container_path "$build_dir")