.github/scripts/podman_ci_config.sh22 of 22 statements covered (100.00%).
coveredmissednever traced by Bash (not counted)A line ending in … continues the statement above it and shares its fate.
| 1 | #!/usr/bin/env bash | |
| 2 | # ============================================================================= | |
| 3 | # podman_ci_config.sh — write ~/.config/containers/containers.conf for CI | |
| 4 | # ============================================================================= | |
| 5 | # | |
| 6 | # Rootless podman on a GitHub runner has no systemd user session, so the OCI | |
| 7 | # runtime must be configured to avoid sd-bus calls. Two configurations work, and | |
| 8 | # each fails in a way the other survives — so integration:dev-alias:podman tries | |
| 9 | # one, then the other, instead of depending on whichever runtime pairing the | |
| 10 | # runner image happened to ship. | |
| 11 | # | |
| 12 | # crun cgroup_manager=cgroupfs + cgroups=disabled. This is the long-standing | |
| 13 | # configuration. It breaks when the runner's apt podman is newer than its | |
| 14 | # crun: podman emits an OCI spec version crun does not recognize and | |
| 15 | # every container fails to start at the first RUN with | |
| 16 | # "unknown version specified". That is deterministic inside a given | |
| 17 | # runner, so retrying the build cannot clear it — the same commit passes | |
| 18 | # or fails depending on which image version the job landed on. | |
| 19 | # | |
| 20 | # runc cgroup_manager=cgroupfs, cgroups left at the default. runc ships on | |
| 21 | # GitHub's Ubuntu images (Docker depends on it) and is unaffected by the | |
| 22 | # crun version skew. It cannot be combined with cgroups=disabled: | |
| 23 | # podman rejects that pairing outright with | |
| 24 | # "requested OCI runtime runc is not compatible with NoCgroups", which is | |
| 25 | # why this is a whole alternative configuration rather than a one-line | |
| 26 | # override. | |
| 27 | # | |
| 28 | # Usage: podman_ci_config.sh <crun|runc> | |
| 29 | # ============================================================================= | |
| 30 | ||
| 31 | 16 | set -euo pipefail |
| 32 | ||
| 33 | 15 | runtime="${1:?usage: podman_ci_config.sh <crun|runc>}" |
| 34 | 15 | config_dir="${HOME}/.config/containers" |
| 35 | 15 | config="${config_dir}/containers.conf" |
| 36 | ||
| 37 | 15 | mkdir -p "${config_dir}" |
| 38 | ||
| 39 | 15 | case "${runtime}" in |
| 40 | crun) | |
| 41 | 7 | cat > "${config}" <<'CONF' |
| 42 | [engine] | |
| 43 | cgroup_manager = "cgroupfs" | |
| 44 | events_logger = "file" | |
| 45 | ||
| 46 | [containers] | |
| 47 | cgroups = "disabled" | |
| 48 | CONF | |
| 49 | 7 | ;; |
| 50 | 7 | runc) |
| 51 | 6 | if ! command -v runc >/dev/null 2>&1; then |
| 52 | 1 | echo "podman_ci_config: runc is not installed; cannot use this configuration" >&2 |
| 53 | 1 | exit 1 |
| 54 | 7 | fi |
| 55 | 7 | # cgroups is deliberately left at the default: runc refuses to run when it |
| 56 | 7 | # is "disabled". |
| 57 | 7 | cat > "${config}" <<'CONF' |
| 58 | [engine] | |
| 59 | cgroup_manager = "cgroupfs" | |
| 60 | events_logger = "file" | |
| 61 | runtime = "runc" | |
| 62 | ||
| 63 | [containers] | |
| 64 | CONF | |
| 65 | ;; | |
| 66 | *) | |
| 67 | 2 | echo "podman_ci_config: unknown runtime '${runtime}' (expected crun or runc)" >&2 |
| 68 | 2 | exit 2 |
| 69 | ;; | |
| 70 | esac | |
| 71 | ||
| 72 | 12 | echo "--- containers.conf (${runtime}) ---" |
| 73 | 12 | cat "${config}" |
| 74 | 12 | if command -v "${runtime}" >/dev/null 2>&1; then |
| 75 | 24 | "${runtime}" --version | head -1 |
| 76 | fi |