Skip to content

Commit b2f93cd

Browse files
mvillmowclaude
andcommitted
fix: Address PR #568 review threads — container startup, caching, caps, lint boundary
- Add podman-version.env with pinned apt version (5.0.2+ds1-4ubuntu1) for Renovate-friendly version management - Source version pin in install step to prevent runner-image drift - Export GIT_COMMIT/BUILD_UID/BUILD_GID to $GITHUB_ENV so docker-compose.yml image tag and user: directive resolve correctly - Add actions/cache + podman save/load for dev image to avoid rebuilding on every CI run (keys on Containerfile/docker-compose.yml/conanfile.py hash) - Add explicit podman-compose up -d dev + readiness poll (10×2s) so build failures abort loudly instead of surfacing as confusing exec errors - Add cap_add: SYS_PTRACE and security_opt: seccomp:unconfined to dev service in docker-compose.yml for ASan/TSan sanitizer builds - Stabilize dev image tag to :latest and container_name to projectkeystone-dev - Wrap Configure CMake and Build with clang-tidy steps in podman-compose exec -T dev to maintain environment parity with make deps Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: mvillmow <4211002+mvillmow@users.noreply.github.com>
1 parent 5e02321 commit b2f93cd

4 files changed

Lines changed: 87 additions & 19 deletions

File tree

.github/actions/install-build-deps/action.yml

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ runs:
9292

9393
- name: Install Podman and docker-compose
9494
run: |
95-
sudo apt-get install -y podman podman-compose
95+
# shellcheck source=/dev/null
96+
source "${GITHUB_ACTION_PATH}/podman-version.env"
97+
sudo apt-get install -y "podman=${PODMAN_APT_VERSION}" podman-compose
9698
shell: bash
9799

98100
- name: Start Podman rootless socket
@@ -101,10 +103,56 @@ runs:
101103
echo "DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock" >> "$GITHUB_ENV"
102104
shell: bash
103105

106+
- name: Set container build environment
107+
run: |
108+
echo "GIT_COMMIT=${{ github.sha }}" >> "$GITHUB_ENV"
109+
echo "BUILD_UID=$(id -u)" >> "$GITHUB_ENV"
110+
echo "BUILD_GID=$(id -g)" >> "$GITHUB_ENV"
111+
shell: bash
112+
104113
- name: Fix workspace permissions for Podman bind mounts
105114
run: chmod -R a+rwX .
106115
shell: bash
107116

117+
- name: Restore dev container image cache
118+
id: image_cache
119+
uses: actions/cache@v5
120+
with:
121+
path: /tmp/dev-image.tar
122+
key: podman-${{ hashFiles('Containerfile', 'docker-compose.yml', 'conanfile.py') }}
123+
restore-keys: |
124+
podman-
125+
126+
- name: Load or build dev container image
127+
run: |
128+
if [ "${{ steps.image_cache.outputs.cache-hit }}" = "true" ] && podman load -i /tmp/dev-image.tar 2>/dev/null; then
129+
echo "Loaded dev image from cache"
130+
else
131+
DOCKER_HOST="$DOCKER_HOST" podman-compose build dev
132+
podman save -o /tmp/dev-image.tar projectkeystone-dev:latest
133+
fi
134+
shell: bash
135+
136+
- name: Start dev container
137+
run: |
138+
DOCKER_HOST="$DOCKER_HOST" podman-compose up -d dev
139+
shell: bash
140+
141+
- name: Wait for dev container readiness
142+
run: |
143+
for i in $(seq 1 10); do
144+
if DOCKER_HOST="$DOCKER_HOST" podman-compose exec -T dev true 2>/dev/null; then
145+
echo "Container ready"
146+
exit 0
147+
fi
148+
echo "Waiting for container... attempt $i/10"
149+
sleep 2
150+
done
151+
echo "Container failed to become ready" >&2
152+
DOCKER_HOST="$DOCKER_HOST" podman-compose logs dev >&2
153+
exit 1
154+
shell: bash
155+
108156
- name: Verify Podman works
109157
run: |
110158
podman info --format '{{.Host.Security.Rootless}}'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PODMAN_APT_VERSION=5.0.2+ds1-4ubuntu1

.github/workflows/_required.yml

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -243,32 +243,47 @@ jobs:
243243
run: make deps
244244

245245
- name: Configure CMake with clang-tidy
246+
# `make deps` runs Conan inside the dev container, so the generated
247+
# conan_toolchain.cmake references container-internal compiler/library
248+
# paths. Configure must therefore run inside the same container or the
249+
# toolchain will not resolve — this preserves the environment-parity
250+
# goal. We reuse the Makefile's container invocation pattern
251+
# (DOCKER_HOST + podman-compose exec -T dev).
246252
run: |
247-
CONAN_TOOLCHAIN=""
248-
if [ -f build/conan-deps/conan_toolchain.cmake ]; then
249-
CONAN_TOOLCHAIN="-DCMAKE_TOOLCHAIN_FILE=build/conan-deps/conan_toolchain.cmake"
250-
fi
251-
cmake -S . -B build/x86.debug.clang-tidy \
252-
-G Ninja \
253-
-DCMAKE_BUILD_TYPE=Debug \
254-
-DENABLE_CLANG_TIDY=ON \
255-
$CONAN_TOOLCHAIN
253+
DOCKER_HOST="${DOCKER_HOST:-}" podman-compose exec -T dev bash -c '
254+
CONAN_TOOLCHAIN=""
255+
if [ -f build/conan-deps/conan_toolchain.cmake ]; then
256+
CONAN_TOOLCHAIN="-DCMAKE_TOOLCHAIN_FILE=build/conan-deps/conan_toolchain.cmake"
257+
fi
258+
cmake -S . -B build/x86.debug.clang-tidy \
259+
-G Ninja \
260+
-DCMAKE_BUILD_TYPE=Debug \
261+
-DENABLE_CLANG_TIDY=ON \
262+
$CONAN_TOOLCHAIN
263+
'
256264
257265
- name: Build with clang-tidy
266+
# Must run inside the dev container for the same reason as the configure
267+
# step: the build consumes the container-generated Conan toolchain and
268+
# uses the container's clang/clang-tidy. clang-tidy-output.txt and
269+
# clang-tidy-build.rc are written under /workspace, which is bind-mounted
270+
# back to the host so the gating step below can read them.
258271
run: |
259272
# clang-tidy build often returns non-zero when diagnostics are found.
260273
# The next step parses clang-tidy-output.txt and decides whether those
261274
# diagnostics reference real source files (vs. third-party headers).
262275
# We must capture the build output without aborting the job — but we
263276
# also must record the build rc for the next step to inspect, rather
264277
# than silently masking it with continue-on-error.
265-
set +e
266-
set -o pipefail
267-
cmake --build build/x86.debug.clang-tidy -j"$(nproc)" 2>&1 | tee clang-tidy-output.txt
268-
rc=${PIPESTATUS[0]}
269-
set -e
270-
echo "$rc" > clang-tidy-build.rc
271-
echo "clang-tidy build exited rc=$rc (gating happens in next step)"
278+
DOCKER_HOST="${DOCKER_HOST:-}" podman-compose exec -T dev bash -c '
279+
set +e
280+
set -o pipefail
281+
cmake --build build/x86.debug.clang-tidy -j"$(nproc)" 2>&1 | tee clang-tidy-output.txt
282+
rc=${PIPESTATUS[0]}
283+
set -e
284+
echo "$rc" > clang-tidy-build.rc
285+
echo "clang-tidy build exited rc=$rc (gating happens in next step)"
286+
'
272287
273288
- name: Fail on clang-tidy errors
274289
run: |

docker-compose.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,19 @@ services:
4141
args:
4242
BUILD_UID: "${BUILD_UID}"
4343
BUILD_GID: "${BUILD_GID}"
44-
image: projectkeystone-dev:${GIT_COMMIT}-dev
45-
container_name: projectkeystone-dev-${GIT_COMMIT}
44+
image: projectkeystone-dev:latest
45+
container_name: projectkeystone-dev
4646
user: "${BUILD_UID}:${BUILD_GID}" # Run as host user
4747
volumes:
4848
- .:/workspace:Z
4949
working_dir: /workspace
5050
stdin_open: true
5151
tty: true
5252
command: /bin/bash
53+
cap_add:
54+
- SYS_PTRACE
55+
security_opt:
56+
- seccomp:unconfined
5357
environment:
5458
- HOME=/workspace/.docker-home # Avoid permission issues with $HOME
5559
- GIT_COMMIT=${GIT_COMMIT}

0 commit comments

Comments
 (0)