ci: run the Lint and Build fast path without network

When the pins match the ci image every tool is baked in, so a runtime
download is a bake-in defect; failing the job makes it visible.

Assisted-by: Claude Code
This commit is contained in:
Defame1297 committed 2026-11-26 22:17:42 +00:00
1 parent 1afce962a0
commit f7fde63f7d
5 files changed
+27 -13

No files matched your search

+5
View File
@@ -57,6 +57,11 @@ issue.
`.pre-commit-config.yaml` takes the slow path, which installs the pinned tools and collections. `.pre-commit-config.yaml` takes the slow path, which installs the pinned tools and collections.
*Why:* a pull request is tested on its own pins, and an unchanged one starts in seconds. *Why:* a pull request is tested on its own pins, and an unchanged one starts in seconds.
*Held:* control: the "Check the baked tooling against the pins" step. *Held:* control: the "Check the baked tooling against the pins" step.
- **On the fast path the tool steps run in a network namespace without network** (`unshare -rn`
through `$OFFLINE`), except "Test the repository scripts", whose fake registry needs loopback;
the slow path keeps network. *Why:* a runtime download is a bake-in defect and must fail the
job, not silently slow it. *Held:* control: the `$OFFLINE` prefix set by the "Check the baked
tooling against the pins" step.
- **Triggers:** both run on pull requests to `main` and on manual dispatch; Build also runs on - **Triggers:** both run on pull requests to `main` and on manual dispatch; Build also runs on
`v*` tags, where it checks the tag against `galaxy.yml`. *Why:* the tag is what consumers `v*` tags, where it checks the tag against `galaxy.yml`. *Why:* the tag is what consumers
install. *Held:* review. install. *Held:* review.
+8 -5
View File
@@ -60,6 +60,9 @@ jobs:
run: | run: |
if sha256sum --quiet -c /opt/ci-pins.sha256; then if sha256sum --quiet -c /opt/ci-pins.sha256; then
echo "The pin files match the ci image; using the baked tools." 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)."
else else
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \ echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \
"extensions/molecule/requirements.yml or .pre-commit-config.yaml differ from the ci image;" \ "extensions/molecule/requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
@@ -79,7 +82,7 @@ jobs:
echo "::error::$TAG is a lightweight tag; releases must be annotated (git tag -a)" echo "::error::$TAG is a lightweight tag; releases must be annotated (git tag -a)"
exit 1 exit 1
fi fi
version="$(python3 -c 'import sys, yaml; print(yaml.safe_load(open("galaxy.yml"))["version"])')" version="$($OFFLINE python3 -c 'import sys, yaml; print(yaml.safe_load(open("galaxy.yml"))["version"])')"
if [ "$TAG" != "v$version" ]; then if [ "$TAG" != "v$version" ]; then
echo "::error::tag $TAG does not match galaxy.yml version $version (expected v$version)" echo "::error::tag $TAG does not match galaxy.yml version $version (expected v$version)"
exit 1 exit 1
@@ -106,7 +109,7 @@ jobs:
run: | run: |
export PATH="/opt/venv/bin:$PATH" export PATH="/opt/venv/bin:$PATH"
mkdir -p /tmp/dist mkdir -p /tmp/dist
ansible-galaxy collection build --force --output-path /tmp/dist . $OFFLINE ansible-galaxy collection build --force --output-path /tmp/dist .
ls -l /tmp/dist ls -l /tmp/dist
sha256sum /tmp/dist/*.tar.gz sha256sum /tmp/dist/*.tar.gz
@@ -119,7 +122,7 @@ jobs:
echo "::error::expected exactly one tarball in /tmp/dist, found $# match(es): $*" echo "::error::expected exactly one tarball in /tmp/dist, found $# match(es): $*"
exit 1 exit 1
fi fi
python3 scripts/check_tarball.py "$1" $OFFLINE python3 scripts/check_tarball.py "$1"
# galaxy-importer without ansible-test and without Docker. The importer reads its # galaxy-importer without ansible-test and without Docker. The importer reads its
# configuration from this file. # configuration from this file.
@@ -138,7 +141,7 @@ jobs:
exit 1 exit 1
fi fi
GALAXY_IMPORTER_CONFIG=/tmp/galaxy-importer.cfg \ GALAXY_IMPORTER_CONFIG=/tmp/galaxy-importer.cfg \
python3 -m galaxy_importer.main "$1" $OFFLINE python3 -m galaxy_importer.main "$1"
# Sanity tests need the collection at ansible_collections/<namespace>/<name>. # Sanity tests need the collection at ansible_collections/<namespace>/<name>.
- name: Run ansible-test sanity - name: Run ansible-test sanity
@@ -159,4 +162,4 @@ jobs:
{ cat tests/sanity/ignore-common.txt; if [ -f "$ignore" ]; then cat "$ignore"; fi; } > /tmp/ignore.new { cat tests/sanity/ignore-common.txt; if [ -f "$ignore" ]; then cat "$ignore"; fi; } > /tmp/ignore.new
mv /tmp/ignore.new "$ignore" mv /tmp/ignore.new "$ignore"
echo "Sanity ignore list for ansible-core ${core}: $(wc -l < "$ignore") lines" echo "Sanity ignore list for ansible-core ${core}: $(wc -l < "$ignore") lines"
ansible-test sanity --requirements --color no $OFFLINE ansible-test sanity --requirements --color no
+9 -5
View File
@@ -59,6 +59,9 @@ jobs:
run: | run: |
if sha256sum --quiet -c /opt/ci-pins.sha256; then if sha256sum --quiet -c /opt/ci-pins.sha256; then
echo "The pin files match the ci image; using the baked tools." 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)."
else else
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \ echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \
"extensions/molecule/requirements.yml or .pre-commit-config.yaml differ from the ci image;" \ "extensions/molecule/requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
@@ -71,7 +74,7 @@ jobs:
- name: Run pre-commit on all files - name: Run pre-commit on all files
run: | run: |
export PATH="/opt/venv/bin:$PATH" export PATH="/opt/venv/bin:$PATH"
pre-commit run --all-files --show-diff-on-failure $OFFLINE pre-commit run --all-files --show-diff-on-failure
# Image pins (scripts/check_image_versions.py): a pin in a workflow must name an # Image pins (scripts/check_image_versions.py): a pin in a workflow must name an
# image of the matrix. Not a pre-commit hook: a change to .pre-commit-config.yaml # image of the matrix. Not a pre-commit hook: a change to .pre-commit-config.yaml
@@ -79,7 +82,7 @@ jobs:
- name: Check image pins - name: Check image pins
run: | run: |
export PATH="/opt/venv/bin:$PATH" export PATH="/opt/venv/bin:$PATH"
python3 scripts/check_image_versions.py pins $OFFLINE python3 scripts/check_image_versions.py pins
# A pull request from a renovate/ branch may only move version, tag, digest and pin # A pull request from a renovate/ branch may only move version, tag, digest and pin
# lines (scripts/check_bot_pr_diff.py), so the bot's automerge cannot change workflow # lines (scripts/check_bot_pr_diff.py), so the bot's automerge cannot change workflow
@@ -106,8 +109,9 @@ jobs:
else else
echo "::notice::$BASE_REF has no scripts/check_bot_pr_diff.py yet; running the pull request's copy" echo "::notice::$BASE_REF has no scripts/check_bot_pr_diff.py yet; running the pull request's copy"
fi fi
python3 -E -s "$guard" "$HEAD_REF" "$BASE_REF" $OFFLINE python3 -E -s "$guard" "$HEAD_REF" "$BASE_REF"
# Online: a new network namespace has loopback down, and the image has no ip to bring it up for the fake registry.
- name: Test the repository scripts - name: Test the repository scripts
run: | run: |
export PATH="/opt/venv/bin:$PATH" export PATH="/opt/venv/bin:$PATH"
@@ -125,7 +129,7 @@ jobs:
echo "gitleaks binary not found in the pre-commit cache" >&2 echo "gitleaks binary not found in the pre-commit cache" >&2
exit 1 exit 1
fi fi
"$GITLEAKS" git --verbose --redact --log-opts="origin/main..$SHA" $OFFLINE "$GITLEAKS" git --verbose --redact --log-opts="origin/main..$SHA"
# commit-msg stage hooks do not run under --all-files, so each commit's message is given to # commit-msg stage hooks do not run under --all-files, so each commit's message is given to
# every commit-msg hook (Conventional Commits, refuse-agent-trailers); --no-verify skips them locally. # every commit-msg hook (Conventional Commits, refuse-agent-trailers); --no-verify skips them locally.
@@ -139,5 +143,5 @@ jobs:
for sha in $(git rev-list --no-merges "origin/main..$SHA"); do for sha in $(git rev-list --no-merges "origin/main..$SHA"); do
git log -1 --format=%B "$sha" > "$MSG_FILE" git log -1 --format=%B "$sha" > "$MSG_FILE"
echo "Checking $sha" echo "Checking $sha"
pre-commit run --hook-stage commit-msg --commit-msg-filename "$MSG_FILE" $OFFLINE pre-commit run --hook-stage commit-msg --commit-msg-filename "$MSG_FILE"
done done
+2 -1
View File
@@ -66,7 +66,8 @@ Read `.gitea/workflows/molecule.yml` for the full command.
`/opt/ci-pins.sha256` lists the five pin files by their checkout-relative path, so `sha256sum -c` runs in the checkout root. When `/opt/ci-pins.sha256` lists the five pin files by their checkout-relative path, so `sha256sum -c` runs in the checkout root. When
the checkout's `requirements-dev.txt`, `requirements-dev.lock`, `requirements.yml`, `extensions/molecule/requirements.yml` and `.pre-commit-config.yaml` match, the baked tools and the checkout's `requirements-dev.txt`, `requirements-dev.lock`, `requirements.yml`, `extensions/molecule/requirements.yml` and `.pre-commit-config.yaml` match, the baked tools and
collections are used as they are. When a pull request changes a pin the check fails and the job installs the pinned collections are used as they are, and Lint and Build run their tools without network, so a tool that
downloads at run time fails the job. When a pull request changes a pin the check fails and the job installs the pinned
tools and collections itself for that run tools and collections itself for that run
(slower, same result), until the image is rebuilt from `main`. `lint.yml`, `build.yml`, `molecule.yml` and `gitea-release-key.yml` (slower, same result), until the image is rebuilt from `main`. `lint.yml`, `build.yml`, `molecule.yml` and `gitea-release-key.yml`
are the real consumers. are the real consumers.
+3 -2
View File
@@ -61,8 +61,9 @@ it to this repository's organisation in the Gitea registry as `<version>` and `l
- **Bake in:** every tool, collection, hook environment and package a CI job uses is in its - **Bake in:** every tool, collection, hook environment and package a CI job uses is in its
image; a job downloads at run time only on the slow path (a pull request that changes a pin image; a job downloads at run time only on the slow path (a pull request that changes a pin
file). *Why:* a run that downloads is slower and depends on the network. *Held:* review until file). *Why:* a run that downloads is slower and depends on the network. *Held:* control: on
the network-off check (#168) lands. the fast path the Lint and Build tool steps run without network, so a download fails the job;
review for the script tests, which keep network, and for Molecule.
- **Recorded speed:** a speed optimisation that adds machinery states its measured saving where - **Recorded speed:** a speed optimisation that adds machinery states its measured saving where
it lives (a comment next to it). *Why:* machinery is kept only for a saving someone can check. it lives (a comment next to it). *Why:* machinery is kept only for a saving someone can check.
*Held:* review. *Held:* review.