← all scripts

.github/scripts/podman_ci_config.sh

22 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
3116set -euo pipefail
32
3315runtime="${1:?usage: podman_ci_config.sh <crun|runc>}"
3415config_dir="${HOME}/.config/containers"
3515config="${config_dir}/containers.conf"
36
3715mkdir -p "${config_dir}"
38
3915case "${runtime}" in
40 crun)
417 cat > "${config}" <<'CONF'
42[engine]
43cgroup_manager = "cgroupfs"
44events_logger = "file"
45
46[containers]
47cgroups = "disabled"
48CONF
497 ;;
507 runc)
516 if ! command -v runc >/dev/null 2>&1; then
521 echo "podman_ci_config: runc is not installed; cannot use this configuration" >&2
531 exit 1
547 fi
557 # cgroups is deliberately left at the default: runc refuses to run when it
567 # is "disabled".
577 cat > "${config}" <<'CONF'
58[engine]
59cgroup_manager = "cgroupfs"
60events_logger = "file"
61runtime = "runc"
62
63[containers]
64CONF
65 ;;
66 *)
672 echo "podman_ci_config: unknown runtime '${runtime}' (expected crun or runc)" >&2
682 exit 2
69 ;;
70esac
71
7212echo "--- containers.conf (${runtime}) ---"
7312cat "${config}"
7412if command -v "${runtime}" >/dev/null 2>&1; then
7524 "${runtime}" --version | head -1
76fi