Compare commits

...
Author SHA1 Message Date
Richard Zink f8b85beb70 Release v202611-00077 2026-11-20 20:34:17 +01:00
Richard ZinkandClaude Sonnet 5.5 3623896464 Changelog: base image entry belongs to the next release
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 20:34:16 +01:00
Richard ZinkandClaude Sonnet 5.5 d0e7cea117 Test runner: shared base image for acceptance containers, log installed apt packages
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 20:33:59 +01:00
9 changed files with 55 additions and 9 deletions

No files matched your search

+1 -1
View File
@@ -38,4 +38,4 @@ CODECRAFT_LOG_FORMAT=
# Optional limits per environment and the image used when .factory/setup.json names none:
#RUNNER_MEMORY=2g
#RUNNER_CPUS=2
#RUNNER_DEFAULT_IMAGE=node:22-bookworm
#RUNNER_DEFAULT_IMAGE=git.familie-zink.org/zink/codecraft-testbase:latest
+7
View File
@@ -3,6 +3,13 @@
All notable changes to CodeCraft. Versions follow [Semantic Versioning](https://semver.org/);
until 1.0, minor versions may contain breaking changes.
## [v202611-00077] – 2026-11-20
### Added
- **Shared base image for acceptance containers** (`git.familie-zink.org/zink/codecraft-testbase`, built from `docker/testbase/Dockerfile` by the release script): Node 24, Python 3, gcc/g++/make/cmake, Chromium with Playwright and common tools (git, curl, e2fsprogs, xz, zsh, sudo, jq, …). It is the runner's default image (`RUNNER_DEFAULT_IMAGE`), so setups that installed these again and again start faster; plain `node:24-bookworm` is the fallback if it cannot be pulled. Projects with their own `image` or `dockerfile` are unchanged.
- The runner also logs the apt packages an environment's setup installed (`apt installed: …`), to see what the base image still lacks.
## [v202611-00076] – 2026-11-20
### Changed
+6 -2
View File
@@ -11,7 +11,7 @@
</p>
<p align="center">
<img alt="Version v202611-00076" src="https://img.shields.io/badge/version-v202611--00076-d69e2e?style=flat-square">
<img alt="Version v202611-00077" src="https://img.shields.io/badge/version-v202611--00077-d69e2e?style=flat-square">
<img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-689d6a?style=flat-square">
<img alt="Rust backend" src="https://img.shields.io/badge/backend-Rust-b7410e?style=flat-square&logo=rust">
<img alt="React PWA" src="https://img.shields.io/badge/frontend-React%20PWA-2d81ff?style=flat-square&logo=react">
@@ -391,7 +391,11 @@ directories, and copied into a fresh container only while that key matches – s
inherits changes from an earlier one, and editing a listed source rebuilds it. `"cache": false`
disables caching; `DELETE /v1/cache/<project>` on the runner clears one project.
`image` defaults to `RUNNER_DEFAULT_IMAGE`; `"dockerfile": "path"` builds the image from the
`image` defaults to `RUNNER_DEFAULT_IMAGE`, by default the shared base image
`codecraft-testbase` (Node 24, Python 3, gcc/cmake, Chromium with Playwright and common tools; see
`docker/testbase/Dockerfile`; plain Node 24 is the fallback when it cannot be pulled). The runner logs
per environment the start time, the seed hit/miss and the apt packages the setup installed.
The image can be changed per project with `"image"`; `"dockerfile": "path"` builds the image from the
repository instead; helper services are reachable by their name. Containers run without extra
capabilities, with memory/CPU/process limits (`RUNNER_MEMORY`, `RUNNER_CPUS`), and cannot see the
host. Without the runner, or without a `setup.json`, nothing changes. Note that the runner holds
+1 -1
View File
@@ -75,7 +75,7 @@ services:
RUNNER_FACTORY_DIR: /factory
RUNNER_MEMORY: ${RUNNER_MEMORY:-2g}
RUNNER_CPUS: ${RUNNER_CPUS:-2}
RUNNER_DEFAULT_IMAGE: ${RUNNER_DEFAULT_IMAGE:-node:22-bookworm}
RUNNER_DEFAULT_IMAGE: ${RUNNER_DEFAULT_IMAGE:-git.familie-zink.org/zink/codecraft-testbase:latest}
HOME: /tmp
volumes:
- /var/run/docker.sock:/var/run/docker.sock
+1 -1
View File
@@ -71,7 +71,7 @@ services:
RUNNER_FACTORY_DIR: /factory
RUNNER_MEMORY: ${RUNNER_MEMORY:-2g}
RUNNER_CPUS: ${RUNNER_CPUS:-2}
RUNNER_DEFAULT_IMAGE: ${RUNNER_DEFAULT_IMAGE:-node:22-bookworm}
RUNNER_DEFAULT_IMAGE: ${RUNNER_DEFAULT_IMAGE:-git.familie-zink.org/zink/codecraft-testbase:latest}
HOME: /tmp
volumes:
- /var/run/docker.sock:/var/run/docker.sock
+14
View File
@@ -0,0 +1,14 @@
# Base image of the factory's throw-away acceptance containers (used when .factory/setup.json names no image).
# Node 24, Python 3, a C/C++ toolchain, the Chromium that Playwright needs, and the small tools
# that acceptance setups installed again and again (see the runner log "apt installed: ...").
FROM node:24-bookworm
ENV DEBIAN_FRONTEND=noninteractive PIP_BREAK_SYSTEM_PACKAGES=1 PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential cmake pkg-config git curl wget ca-certificates unzip xz-utils zip \
e2fsprogs util-linux zsh sudo nano procps iproute2 netcat-openbsd jq sqlite3 \
python3 python3-pip python3-venv \
&& rm -rf /var/lib/apt/lists/* \
&& npm install -g playwright \
&& playwright install --with-deps chromium \
&& rm -rf /var/lib/apt/lists/* /root/.npm \
&& chmod -R a+rX /ms-playwright
+4
View File
@@ -94,6 +94,10 @@ if (( image )); then
run docker buildx build --builder "$BUILDER" --platform "$PLATFORMS" \
--build-arg GIT_COMMIT="$(git rev-parse --short HEAD)" --build-arg CODECRAFT_VERSION="$version" \
"${tags[@]}" --push .
# Base image of the factory's acceptance containers (cached layers: cheap unless the Dockerfile changed).
step "Building and pushing ${REGISTRY}-testbase for $PLATFORMS"
run docker buildx build --builder "$BUILDER" --platform "$PLATFORMS" \
-t "${REGISTRY}-testbase:latest" -t "${REGISTRY}-testbase:$tag" --push docker/testbase
fi
step "Creating the Gitea release $tag"
+17 -4
View File
@@ -34,6 +34,8 @@ const CACHE_LABEL: &str = "codecraft.testrunner.cache=1";
/// What every environment container runs: link the shared directories, restore a matching seed, run
/// `install`, store a new seed (only after a successful install, so it is pristine), start the app.
const FALLBACK_IMAGE: &str = "node:24-bookworm";
const ENTRY_SCRIPT: &str = r#"cd /app
hit=0
if [ -d /cache ]; then
@@ -42,9 +44,11 @@ if [ -d /cache ]; then
if [ -n "$CC_SEED_KEY" ]; then for p in $CC_SEED_PATHS; do if [ -e "/cache/seed/$CC_SEED_KEY/$p" ]; then mkdir -p "$(dirname "$p")" && cp -a "/cache/seed/$CC_SEED_KEY/$p" "$p" && hit=1 && echo "[runner] restored $p from the cache"; fi; done; fi
fi
if [ -n "$CC_SEED_KEY" ]; then if [ "$hit" = 1 ]; then echo "[runner] seed $CC_SEED_KEY: hit"; else echo "[runner] seed $CC_SEED_KEY: miss"; fi; fi
t0=$(date +%s)
t0=$(date +%s); st=$(date -u '+%Y-%m-%d %H:%M:%S')
if [ -n "$CC_INSTALL" ]; then sh -c "$CC_INSTALL" || exit 1; fi
echo "[runner] install took $(( $(date +%s) - t0 )) s"
pk=$(awk -v s="$st" '$3=="install" && ($1" "$2)>=s {sub(/:.*/,"",$4); print $4}' /var/log/dpkg.log 2>/dev/null | sort -u | head -40 | tr '\n' ' ')
if [ -n "$pk" ]; then echo "[runner] apt installed: $pk"; fi
if [ -d /cache ] && [ -n "$CC_SEED_KEY" ] && [ ! -d "/cache/seed/$CC_SEED_KEY" ]; then
t="/cache/seed/.tmp-$$"; rm -rf "$t"; mkdir -p "$t"; ok=1
for p in $CC_SEED_PATHS; do if [ -e "$p" ]; then mkdir -p "$t/$(dirname "$p")" && cp -a "$p" "$t/$p" || ok=0; fi; done
@@ -355,7 +359,7 @@ pub async fn serve() -> Result<()> {
ports: (lo, hi),
memory: std::env::var("RUNNER_MEMORY").unwrap_or_else(|_| "2g".into()),
cpus: std::env::var("RUNNER_CPUS").unwrap_or_else(|_| "2".into()),
default_image: std::env::var("RUNNER_DEFAULT_IMAGE").unwrap_or_else(|_| "node:22-bookworm".into()),
default_image: std::env::var("RUNNER_DEFAULT_IMAGE").unwrap_or_else(|_| "git.familie-zink.org/zink/codecraft-testbase:latest".into()),
max_age: Duration::from_secs(60 * std::env::var("RUNNER_MAX_MINUTES").ok().and_then(|s| s.parse().ok()).unwrap_or(90)),
me: std::env::var("RUNNER_SELF").or_else(|_| std::env::var("HOSTNAME")).unwrap_or_default(),
envs: Mutex::new(HashMap::new()),
@@ -458,7 +462,7 @@ async fn create(r: &Arc<Runner>, id: &str, req: &StartReq, work: &Path) -> Resul
r.envs.lock().unwrap().get_mut(id).unwrap().containers.push(cname);
}
let image = if req.dockerfile.is_empty() {
if req.image.is_empty() { r.default_image.clone() } else { req.image.clone() }
if req.image.is_empty() { default_image_or_fallback(&r.default_image).await } else { req.image.clone() }
} else {
let tag = format!("cc-run-{id}");
let df = work.join(&req.dockerfile);
@@ -548,7 +552,7 @@ async fn create(r: &Arc<Runner>, id: &str, req: &StartReq, work: &Path) -> Resul
tokio::time::sleep(Duration::from_millis(700)).await;
}
// Report what the cache brought: seed hit/miss, install time, total time until the app answered.
let facts: Vec<String> = logs(&app).await.lines().filter(|l| l.starts_with("[runner] seed ") || l.starts_with("[runner] install took")).map(|l| l.trim_start_matches("[runner] ").to_string()).collect();
let facts: Vec<String> = logs(&app).await.lines().filter(|l| l.starts_with("[runner] seed ") || l.starts_with("[runner] install took") || l.starts_with("[runner] apt installed")).map(|l| l.trim_start_matches("[runner] ").to_string()).collect();
let took = began.elapsed().as_secs();
let cache = if cached { "on" } else { "off" };
tracing::info!("test env {id} ({}) ready after {took} s; cache {cache}{}{}", req.cache_id, if facts.is_empty() { "" } else { "; " }, facts.join("; "));
@@ -572,6 +576,15 @@ async fn create(r: &Arc<Runner>, id: &str, req: &StartReq, work: &Path) -> Resul
Ok(Started { id: id.to_string(), port })
}
/// The shared base image; when it can neither be found nor pulled, fall back to plain Node so runs still work.
async fn default_image_or_fallback(img: &str) -> String {
if docker(&["image", "inspect", img]).await.is_ok() || docker(&["pull", "-q", img]).await.is_ok() {
return img.to_string();
}
tracing::warn!("test runner: base image {img} is not available, using {FALLBACK_IMAGE}");
FALLBACK_IMAGE.to_string()
}
async fn logs(container: &str) -> String {
match Command::new("docker").args(["logs", "--tail", "400", container]).output().await {
Ok(o) => format!("{}{}", String::from_utf8_lossy(&o.stdout), String::from_utf8_lossy(&o.stderr)),
+4
View File
@@ -3,6 +3,10 @@
* under "unreleased"; scripts/release.sh renames the key to the release version.
*/
export const WHATS_NEW: Record<string, { en: string[]; de: string[] }> = {
"202611-00077": {
en: ["Factory test runner: shared base image (Node 24, Python, gcc, Chromium/Playwright) for acceptance containers; logs start time, cache hits and installed packages"],
de: ["Factory-Test-Runner: gemeinsames Basis-Image (Node 24, Python, gcc, Chromium/Playwright) für Abnahme-Container; protokolliert Startzeit, Cache-Treffer und installierte Pakete"],
},
"202611-00076": {
en: ["Factory test runner: logs how long an environment took to start and whether the cache seed was a hit"],
de: ["Factory-Test-Runner: protokolliert, wie lange eine Umgebung zum Start brauchte und ob der Cache-Seed getroffen hat"],