ci: cut the fast-path network by environment, not unshare
Build / build (pull_request) Successful in 34s
Molecule / molecule (pull_request) Successful in 16s
Lint / lint (pull_request) Successful in 1m38s

The runner's job container refuses unshare, even with a user namespace, so the
fast path sets PIP_NO_INDEX and a dead proxy instead; a raw socket is not caught.

Assisted-by: Claude Code
This commit is contained in:
Defame1297 committed 2026-11-26 22:48:51 +00:00
1 parent 7c148e858d
commit 4d5042a31f
5 files changed
+35 -28

No files matched your search

+10 -8
View File
@@ -60,9 +60,11 @@ jobs:
run: |
if sha256sum --quiet -c /opt/ci-pins.sha256; then
echo "The pin files match the ci image; using the baked tools."
# -r adds a user namespace: a job container lacks CAP_SYS_ADMIN for a plain unshare -n.
echo "OFFLINE=unshare -rn --" >> "$GITHUB_ENV"
echo "::notice::The tool steps run without network; a download fails the job (bake it into images/ci)."
# A job container may not unshare, so the network is cut by environment: pip, curl,
# git over HTTPS and Python's urllib fail; a raw socket is not caught.
printf '%s\n' PIP_NO_INDEX=1 http_proxy=http://127.0.0.1:9 https_proxy=http://127.0.0.1:9 \
HTTP_PROXY=http://127.0.0.1:9 HTTPS_PROXY=http://127.0.0.1:9 no_proxy= NO_PROXY= >> "$GITHUB_ENV"
echo "::notice::Later steps run with a dead proxy; a download fails the job (bake it into images/ci)."
else
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \
"extensions/molecule/requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
@@ -82,7 +84,7 @@ jobs:
echo "::error::$TAG is a lightweight tag; releases must be annotated (git tag -a)"
exit 1
fi
version="$($OFFLINE python3 -c 'import sys, yaml; print(yaml.safe_load(open("galaxy.yml"))["version"])')"
version="$(python3 -c 'import sys, yaml; print(yaml.safe_load(open("galaxy.yml"))["version"])')"
if [ "$TAG" != "v$version" ]; then
echo "::error::tag $TAG does not match galaxy.yml version $version (expected v$version)"
exit 1
@@ -109,7 +111,7 @@ jobs:
run: |
export PATH="/opt/venv/bin:$PATH"
mkdir -p /tmp/dist
$OFFLINE ansible-galaxy collection build --force --output-path /tmp/dist .
ansible-galaxy collection build --force --output-path /tmp/dist .
ls -l /tmp/dist
sha256sum /tmp/dist/*.tar.gz
@@ -122,7 +124,7 @@ jobs:
echo "::error::expected exactly one tarball in /tmp/dist, found $# match(es): $*"
exit 1
fi
$OFFLINE python3 scripts/check_tarball.py "$1"
python3 scripts/check_tarball.py "$1"
# galaxy-importer without ansible-test and without Docker. The importer reads its
# configuration from this file.
@@ -141,7 +143,7 @@ jobs:
exit 1
fi
GALAXY_IMPORTER_CONFIG=/tmp/galaxy-importer.cfg \
$OFFLINE python3 -m galaxy_importer.main "$1"
python3 -m galaxy_importer.main "$1"
# Sanity tests need the collection at ansible_collections/<namespace>/<name>.
- name: Run ansible-test sanity
@@ -162,4 +164,4 @@ jobs:
{ cat tests/sanity/ignore-common.txt; if [ -f "$ignore" ]; then cat "$ignore"; fi; } > /tmp/ignore.new
mv /tmp/ignore.new "$ignore"
echo "Sanity ignore list for ansible-core ${core}: $(wc -l < "$ignore") lines"
$OFFLINE ansible-test sanity --requirements --color no
ansible-test sanity --requirements --color no