Author SHA1 Message Date
Pavlo Ratushnyi d7d24c7401 test: preserve container smoke failures on cleanup 2026-10-08 00:34:59 +02:00
Pavlo Ratushnyi fb3ce6e8c5 STRA-13: isolate CLI container gate image ownership
Build the CLI container gate with a run and attempt tag plus a nonce owner label, capture and validate its immutable image ID, and pass that ID to the smoke check. Limit cleanup to the validated owned image and temporary receipt without parent pruning, preserving all other workflow gates.
2026-10-08 00:33:41 +02:00
Pavlo Ratushnyi 63a56772da test: bound CLI container startup wait 2026-10-08 00:30:54 +02:00
Pavlo Ratushnyi b848e433a3 STRA-13: align desktop CI Rust helper target
Linux / keyless-cuda-gate (pull_request) Skipped
Desktop foundation / core (ubuntu-latest) (pull_request) Successful in 2m54s
Linux / verify (pull_request) Successful in 7m2s
Linux / keyless-cuda (pull_request) Skipped
Linux / static-cuda-package (pull_request) Skipped
Linux / hosted-cuda-package (pull_request) Skipped
Linux / linux-cli-container (pull_request) Successful in 29s
Linux / linux-static-cli (pull_request) Successful in 5m16s
Linux / release-cli (pull_request) Skipped
Set the desktop job target directory to desktop-core/target so workspace Rust builds produce the helper at the existing .NET and Python consumer paths. Preserve all workflow checks and event routing.
2026-10-08 00:25:07 +02:00
3 changed files with 93 additions and 6 deletions
+2
View File
@@ -10,6 +10,8 @@ permissions:
contents: read
jobs:
core:
env:
CARGO_TARGET_DIR: ${{ github.workspace }}/desktop-core/target
strategy:
fail-fast: false
matrix:
+32 -3
View File
@@ -481,12 +481,41 @@ jobs:
command -v docker >/dev/null 2>&1 || { apt-get update -qq; DEBIAN_FRONTEND=noninteractive apt-get install -y -qq docker.io; }
docker version
- name: Build actual CLI-only scratch image
run: docker build --file deploy/Dockerfile.static-cli --tag strata-cli-check .
run: |
set -euo pipefail
owned_dir="$(mktemp -d "$RUNNER_TEMP/leleka-cli-check-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}-XXXXXX")"
image_tag="leleka-cli-check:${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}-${owned_dir##*-}"
printf '%s\n' "CLI_CHECK_DIR=$owned_dir" "CLI_CHECK_TAG=$image_tag" >> "$GITHUB_ENV"
# The nonce label makes identical builds distinct image configs on the shared daemon.
docker build --file deploy/Dockerfile.static-cli --tag "$image_tag" \
--label "io.leleka.ci.cli-check-owner=$image_tag" --iidfile "$owned_dir/image.iid" .
image="$(cat "$owned_dir/image.iid")"
[[ "$image" =~ ^sha256:[0-9a-f]{64}$ ]]
test "$(docker image inspect --format '{{ index .Config.Labels "io.leleka.ci.cli-check-owner" }}' "$image")" = "$image_tag"
- name: Check isolated CLI container startup and shutdown
run: python3 scripts/smoke-cli-container.py strata-cli-check
run: |
set -euo pipefail
image="$(cat "$CLI_CHECK_DIR/image.iid")"
[[ "$image" =~ ^sha256:[0-9a-f]{64}$ ]]
test "$(docker image inspect --format '{{ index .Config.Labels "io.leleka.ci.cli-check-owner" }}' "$image")" = "$CLI_CHECK_TAG"
python3 scripts/smoke-cli-container.py "$image"
- name: Remove test image
if: always()
run: docker image rm strata-cli-check || true
run: |
set -euo pipefail
test -n "${CLI_CHECK_DIR:-}" || exit 0
trap 'rm -f -- "$CLI_CHECK_DIR/image.iid"; rmdir -- "$CLI_CHECK_DIR"' EXIT
if test -s "$CLI_CHECK_DIR/image.iid"; then
image="$(cat "$CLI_CHECK_DIR/image.iid")"
else
# A failed build may leave the owned tag without writing an IID receipt.
image="$(docker image inspect --format '{{.Id}}' "$CLI_CHECK_TAG" 2>/dev/null || true)"
fi
test -n "$image" || exit 0
[[ "$image" =~ ^sha256:[0-9a-f]{64}$ ]]
test "$(docker image inspect --format '{{ index .Config.Labels "io.leleka.ci.cli-check-owner" }}' "$image")" = "$CLI_CHECK_TAG"
# No force or parent pruning: cleanup cannot remove other jobs' references or cache.
docker image rm --no-prune "$image"
release-cli:
permissions:
+59 -3
View File
@@ -9,12 +9,43 @@ import subprocess
from docker_smoke_http import ISOLATION, docker, prepare_probe, request
def report_best_effort(message):
try:
print(message, file=sys.stderr, flush=True)
except Exception:
pass
def diagnose_owned_container(name):
"""Emit bounded state/log diagnostics for this invocation's unique container."""
commands = (
('inspect', ('inspect', '--format', '{{json .State}}', name)),
('logs', ('logs', '--tail', '40', name)),
)
for label, args in commands:
try:
result = docker(*args, check=False, timeout=8)
output = (result.stdout or '') + (result.stderr or '')
if len(output) > 8192:
output = '[earlier output truncated]\n' + output[-8192:]
if output:
report_best_effort(
f'Owned container {label} (exit {result.returncode}):\n{output}')
else:
report_best_effort(
f'Owned container {label}: no output (exit {result.returncode})')
except Exception as error:
report_best_effort(
f'Owned container {label} diagnostics unavailable: {type(error).__name__}')
def main(image):
name = 'strata-cli-smoke-' + uuid.uuid4().hex
common = ['--name', name, *ISOLATION]
root = Path(__file__).resolve().parents[1]
prepare_probe()
primary_error = None
try:
version = docker('run', '--rm', *common, '--network', 'none', image, '--version').stdout
assert version.startswith('strata-next '), version
@@ -24,8 +55,16 @@ def main(image):
info = json.loads(docker('run', '--rm', *common, '--network', 'none', image,
'engine-info').stdout)
assert info['embedded'] is False and info['model_bundled'] is False, info
docker('run', '-d', *common, '--network', 'none',
'-e', 'STRATA_BIND=127.0.0.1:8081', image, 'serve')
try:
docker('run', '-d', *common, '--network', 'none',
'-e', 'STRATA_BIND=127.0.0.1:8081', image, 'serve', timeout=120)
except subprocess.TimeoutExpired:
try:
diagnose_owned_container(name)
except Exception as error:
report_best_effort(
f'Owned container diagnostics failed: {type(error).__name__}')
raise
deadline = time.monotonic() + 15
while True:
try:
@@ -42,8 +81,25 @@ def main(image):
assert state['ExitCode'] == 0 and not state['OOMKilled'], state
print('CLI OCI passed: actual image, exact upstream license, no embedded engine/model, '
'non-root read-only health200/ready503, graceful stop. No GPU inference qualified.')
except BaseException as error:
primary_error = error
raise
finally:
docker('rm', '-f', name, check=False)
cleanup_error = None
try:
result = docker('rm', '-f', name, check=False, timeout=10)
if result.returncode:
cleanup_error = subprocess.CalledProcessError(
result.returncode, ['docker', 'rm', '-f', name],
output=result.stdout, stderr=result.stderr)
except Exception as error:
cleanup_error = error
if cleanup_error is not None:
if primary_error is None:
raise cleanup_error
report_best_effort(
f'Owned container cleanup failed after {type(primary_error).__name__}: '
f'{type(cleanup_error).__name__}')
if __name__ == '__main__':