Author SHA1 Message Date
Aego CI e05d336d2c Test cache restore with matching compression
isolated-cache-transport-probe / restore (push) Successful in 1m33s
2026-11-15 19:17:21 +03:00
Aego CI 477620470d Test isolated CI cache transport
isolated-cache-transport-probe / save (push) Successful in 2m59s
isolated-cache-transport-probe / restore (push) Failing after 3m15s
2026-11-15 19:00:39 +03:00
12 changed files with 930 additions and 0 deletions
+95
View File
@@ -0,0 +1,95 @@
name: isolated-cache-transport-probe
on:
push:
branches: [ci/cache-restore-84d4886d3967beffa21e]
workflow_dispatch:
permissions:
contents: read
jobs:
restore:
if: github.server_url != 'https://github.com'
runs-on: ubuntu-24.04
timeout-minutes: 20
container:
image: sha256:3fbc899075feac5abe75f2f473d5dcb5ab2e1768f55b90a2bc83dcd4c62338f3
options: --memory=3g --memory-swap=3g --cpus=2 --shm-size=1g
defaults:
run:
shell: bash
env:
AEGO_CI_PREPARED: '1'
GOTELEMETRY: 'off'
PYTHONDONTWRITEBYTECODE: '1'
steps:
- name: Install probe compression in disposable container
run: |
set -euo pipefail
apt-get update
apt-get install -y --no-install-recommends zstd=1.5.5+dfsg2-2build1.1
command -v zstdmt
- name: Require a fresh restore directory
run: |
set -eu
dir="$RUNNER_TEMP/aego-cache-probe-ce586c48237f0282cf71"
test -n "$RUNNER_TEMP" && test ! -e "$dir" && test ! -L "$dir"
- name: Restore synthetic cache
id: restored
uses: actions/cache/restore@v4
with:
path: ${{ runner.temp }}/aego-cache-probe-ce586c48237f0282cf71
key: aego-probe-ce586c48237f0282cf71
fail-on-cache-miss: true
- name: Verify restored content
env:
EXACT_HIT: ${{ steps.restored.outputs.cache-hit }}
run: |
set -eu
test "$EXACT_HIT" = true
file="$RUNNER_TEMP/aego-cache-probe-ce586c48237f0282cf71/value.txt"
test -f "$file" && test ! -L "$file"
test "$(cat "$file")" = 'aego-cache-synthetic-f2df9f37f3bce8282aef3d771631a4edb531565e735babd0'
printf '%s\n' 'Synthetic cache restored and verified; this is not full CI.'
- uses: actions/checkout@v4
- name: Verify prepared workspace
run: |
set -eu
export GOTELEMETRY=off PYTHONDONTWRITEBYTECODE=1
python3 -B tools/ci/prepare_ci_workspace.py --root "$PWD"
python3 -B tools/ci/env/preflight.py --root "$PWD"
python3 -B tools/ci/prepared_web_deps.py --root "$PWD"
python3 -B tools/ci/staticcheck_runner.py v0.8.2 -- -version
make bootstrap
test ! -e "$RUNNER_TEMP/aego-cache-key-output"
touch "$RUNNER_TEMP/aego-cache-key-output"
GITHUB_OUTPUT="$RUNNER_TEMP/aego-cache-key-output" python3 -B tools/ci/go_cache_key.py
grep -Eq '^fingerprint=[0-9a-f]{64}$' "$RUNNER_TEMP/aego-cache-key-output"
- name: Headed browser environment
run: |
set -eu
timeout --kill-after=5s 180s xvfb-run -a -s '-screen 0 1440x1050x24' \
/opt/aego/python/bin/python -u -B /opt/aego/ci-env/browser_smoke.py
- name: Native GL readback
run: |
set -euo pipefail
export GOTOOLCHAIN=local GOPROXY=off GOSUMDB=off GOTELEMETRY=off
export SDL_VIDEODRIVER=offscreen SDL_VIDEO_DRIVER=offscreen SDL_AUDIO_DRIVER=dummy SDL_AUDIODRIVER=dummy
export LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVER=llvmpipe MESA_GL_VERSION_OVERRIDE=3.3 MESA_GLSL_VERSION_OVERRIDE=330
go test -count=1 -json -tags aego_gltest -run '^TestReadPixelsOrientation$' ./tests/gl/ | tee "$RUNNER_TEMP/aego-native-gl.jsonl"
python3 -B - "$RUNNER_TEMP/aego-native-gl.jsonl" <<'PY'
import json, sys
with open(sys.argv[1], encoding='utf-8') as stream:
events = [json.loads(line) for line in stream]
actions = [item['Action'] for item in events if item.get('Test') == 'TestReadPixelsOrientation']
if actions.count('run') != 1 or actions.count('pass') != 1 or any(x in actions for x in ('skip', 'fail')):
raise SystemExit('native GL test did not run and pass: ' + repr(actions))
print('Native GL test ran and passed without skips')
PY
test ! -e "$RUNNER_TEMP/aego-cache-save-output"
touch "$RUNNER_TEMP/aego-cache-save-output"
GITHUB_OUTPUT="$RUNNER_TEMP/aego-cache-save-output" GO_BUILD_CACHE_PATH="$(go env GOCACHE)" \
GO_MODULE_CACHE_PATH="$(go env GOMODCACHE)" python3 -B tools/ci/go_cache_save.py
grep -qx 'save=yes' "$RUNNER_TEMP/aego-cache-save-output"
test -z "$(git status --porcelain --untracked-files=all)"
+2
View File
@@ -17,6 +17,8 @@ tools/genicons/genicons
/tests/golden/testdata/actual-*
tools/websmoke/node_modules/
# Prepared CI uses a link to the same generated dependency directory.
tools/websmoke/node_modules
/tools/websmoke/__pycache__/
tools/websmoke/golden/actual-*.png
+54
View File
@@ -0,0 +1,54 @@
# Build only from a reviewed, minimal context; see tools/ci/env/README.md.
FROM golang@sha256:5cf287a799e6b94384bad13d16b14904c531f51ba65792237e122ce42b392f61 AS go_toolchain
FROM node@sha256:01d566e8d94d8c619591d78652babfccd3c6992a3dffa9ed5ab39e11cf6c70e9 AS node_toolchain
FROM mcr.microsoft.com/playwright/python@sha256:330d401ae23c905896a0c26c66c36fc971b621519e7b11b435a8328d7bf6e031
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV DEBIAN_FRONTEND=noninteractive \
GOTOOLCHAIN=local \
PLAYWRIGHT_BROWSERS_PATH=/ms-playwright \
PATH=/opt/aego/bin:/usr/local/go/bin:/opt/aego/node/bin:$PATH \
SDL_AUDIO_DRIVER=dummy \
SDL_AUDIODRIVER=dummy
# Browser libraries and revisions come from the pinned Playwright image.
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential cmake ninja-build pkg-config openssl curl ca-certificates \
python3-venv xvfb xauth xdotool sudo xz-utils patch \
fonts-dejavu-core fonts-liberation nsis squashfs-tools \
libgl1-mesa-dev libegl1-mesa-dev libgles2-mesa-dev \
libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libxtst-dev libxkbcommon-dev \
libwayland-dev wayland-protocols libdecor-0-dev \
libasound2-dev libpulse-dev libdrm-dev libgbm-dev libudev-dev libdbus-1-dev libibus-1.0-dev \
glslang-tools=15.1.0-2~ubuntu0.24.04.2 && \
rm -rf /var/lib/apt/lists/*
COPY --from=go_toolchain /usr/local/go /usr/local/go
COPY --from=node_toolchain /usr/local/bin/node /opt/aego/node/bin/node
COPY --from=node_toolchain /usr/local/lib/node_modules/npm /opt/aego/node/lib/node_modules/npm
RUN ln -s ../lib/node_modules/npm/bin/npm-cli.js /opt/aego/node/bin/npm && \
ln -s ../lib/node_modules/npm/bin/npx-cli.js /opt/aego/node/bin/npx
COPY tools/ci/env/requirements.txt /opt/aego/ci-env/requirements.txt
RUN python3 -m venv /opt/aego/python && \
/opt/aego/python/bin/pip install --no-cache-dir --require-hashes -r /opt/aego/ci-env/requirements.txt
RUN mkdir -p /opt/aego/bin && GOBIN=/opt/aego/bin go install honnef.co/go/tools/cmd/staticcheck@v0.8.2
# Keep SDL inputs separate from application source and from the Node lock layer.
COPY third_party/sdl/version.txt /opt/aego/seed/third_party/sdl/version.txt
COPY tools/bootstrap-native.sh /opt/aego/seed/tools/bootstrap-native.sh
RUN cd /opt/aego/seed && GOOS=linux GOARCH=amd64 bash tools/bootstrap-native.sh && \
mkdir -p /opt/aego/native && cp -a .cache/native/linux_amd64 /opt/aego/native/ && \
rm -rf /opt/aego/seed/.cache
COPY tools/websmoke/package.json tools/websmoke/package-lock.json /opt/aego/websmoke/
RUN cd /opt/aego/websmoke && npm ci --no-audit --no-fund
COPY tools/ci/env/Dockerfile tools/ci/env/lock.json tools/ci/env/preflight.py tools/ci/env/browser_smoke.py /opt/aego/ci-env/
RUN python3 -B /opt/aego/ci-env/preflight.py --image-only && \
timeout --kill-after=10s 180s xvfb-run -a -s '-screen 0 1440x1050x24' \
/opt/aego/python/bin/python -u -B /opt/aego/ci-env/browser_smoke.py
WORKDIR /workspace
CMD ["bash"]
+31
View File
@@ -0,0 +1,31 @@
"""Smoke the image's two real browser executables using an isolated display."""
from playwright.sync_api import sync_playwright
def main():
print('browser smoke: starting Playwright driver', flush=True)
with sync_playwright() as playwright:
for name in ('chromium', 'firefox'):
print(name + ': launching', flush=True)
browser_type = getattr(playwright, name)
options = {'headless': False, 'timeout': 30000}
if name == 'chromium':
options['args'] = ['--no-sandbox']
browser = browser_type.launch(**options)
try:
print(name + ': rendering', flush=True)
page = browser.new_page()
page.set_default_timeout(30000)
page.set_content('<title>Aego CI environment</title><p>ready</p>', timeout=30000)
if page.title() != 'Aego CI environment' or page.locator('p').inner_text() != 'ready':
raise RuntimeError(name + ' did not render the smoke page')
print(name + ': browser smoke passed', flush=True)
finally:
print(name + ': closing', flush=True)
browser.close()
print('browser smoke: driver closed', flush=True)
if __name__ == '__main__':
main()
+31
View File
@@ -0,0 +1,31 @@
{
"schema": 1,
"platform": "linux/amd64",
"base_image": "mcr.microsoft.com/playwright/python@sha256:330d401ae23c905896a0c26c66c36fc971b621519e7b11b435a8328d7bf6e031",
"go_image": "golang@sha256:5cf287a799e6b94384bad13d16b14904c531f51ba65792237e122ce42b392f61",
"node_image": "node@sha256:01d566e8d94d8c619591d78652babfccd3c6992a3dffa9ed5ab39e11cf6c70e9",
"tools": {
"go": "go1.27.2",
"node": "v24.22.2",
"npm": "11.19.1",
"python": "3.12",
"playwright": "1.64.1",
"pyee": "14.0.0",
"greenlet": "3.5.6",
"typing-extensions": "4.16.0",
"sdl": "3.2.24",
"glslang": "15.1.0",
"glslang_apt": "15.1.0-2~ubuntu0.24.04.2",
"staticcheck": "v0.8.2"
},
"inputs": {
"third_party/sdl/version.txt": "960cbf708fe41790fa779f7855787edaa668733490ae0d36f95ffc13adcd9bc0",
"tools/bootstrap-native.sh": "15e1d2ce94b202c2749c435d59f643ca2b65fe98e78721df56c34c6bbccc0feb",
"tools/websmoke/package.json": "9b18d33742f7910d102461aa5fa71a00c7620735eff8f61ca1cb93311cf06f57",
"tools/websmoke/package-lock.json": "7bd9077253747fbf7c37b03ee55417424aee9d70f69178bddbb7cf8087cc6e49",
"tools/ci/env/Dockerfile": "85a49c2077409ce50b1cc9cb45e9f1c9e98e2fe83c3a3f695826caf5e5a68eb4",
"tools/ci/env/requirements.txt": "1e5241a3542bf595bc535d99138407f142b09f3240639c9354bf209653179639",
"tools/ci/env/preflight.py": "83f13da0952b0afc28b20dcc5433aa963c132df4cec7a58f497f4748573e0a2c",
"tools/ci/env/browser_smoke.py": "b84e7af01a64384276365195f4a45d0a1f954f2a5abbab84f57b7ba9c1046527"
}
}
+262
View File
File diff suppressed because it is too large Load Diff
+8
View File
@@ -0,0 +1,8 @@
playwright==1.64.1 \
--hash=sha256:577b8d88778c245cfbd145ae17cf53044f084b1b46c55c69081d4069d56057e2
pyee==14.0.0 \
--hash=sha256:3ac2d3229a9677f7de2c33d7f52fe25b638a46b19c413fea2edc8c6d0a644e4d
greenlet==3.5.6 \
--hash=sha256:975736b002ed080d124cf81a79cb7e05cb26d6b3f5c7a7b651c0fcce70353aa1
typing-extensions==4.16.0 \
--hash=sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8
File diff suppressed because it is too large Load Diff
+68
View File
@@ -0,0 +1,68 @@
#!/usr/bin/env python3
"""Bound optional Go-cache uploads without removing any existing cache."""
import os
from pathlib import Path
import shutil
import stat
import sys
MAX_BYTES = 3 * 1024**3
MIN_FREE_BYTES = 50 * 1024**3
def assess(paths, max_bytes=MAX_BYTES, min_free=MIN_FREE_BYTES):
roots = []
for value in paths:
path = Path(value)
if not path.is_absolute() or path == Path(path.anchor) or path.is_symlink():
raise ValueError('unsafe cache path')
if path.exists() and not path.is_dir():
raise ValueError('cache path is not a directory')
roots.append(path.resolve(strict=False))
if len(roots) != 2 or roots[0] == roots[1] or roots[0] in roots[1].parents or roots[1] in roots[0].parents:
raise ValueError('cache paths overlap')
if not roots[0].is_dir():
return False, 0, 'build cache is missing'
size = 0
for root in roots:
if not root.exists():
continue
if shutil.disk_usage(root).free < min_free:
return False, size, 'insufficient free storage'
for directory, dirs, files in os.walk(root, followlinks=False):
for name in dirs + files:
path = Path(directory) / name
info = path.lstat()
if stat.S_ISREG(info.st_mode):
size += info.st_size
if size > max_bytes:
return False, size, 'cache exceeds upload bound'
elif not stat.S_ISDIR(info.st_mode):
raise ValueError('cache contains a link or special file')
return True, size, 'within upload bound'
def main():
try:
output = Path(os.environ['GITHUB_OUTPUT'])
if not output.is_absolute() or output.is_symlink() or not output.is_file():
raise ValueError('GITHUB_OUTPUT must be an existing regular file')
max_bytes = int(os.environ.get('GO_CACHE_MAX_BYTES', MAX_BYTES))
min_free = int(os.environ.get('GO_CACHE_MIN_FREE_BYTES', MIN_FREE_BYTES))
if not 0 < max_bytes <= MAX_BYTES or not 2 * 1024**3 <= min_free <= MIN_FREE_BYTES:
raise ValueError('invalid cache size or free-space bound')
allowed, size, reason = assess((os.environ['GO_BUILD_CACHE_PATH'], os.environ['GO_MODULE_CACHE_PATH']),
max_bytes=max_bytes, min_free=min_free)
with output.open('a', encoding='utf-8') as stream:
stream.write('save=' + ('yes' if allowed else 'no') + '\nbytes=' + str(size) + '\n')
print('Optional Go cache: ' + reason + ' (' + str(size) + ' bytes checked)')
return 0
except (OSError, ValueError, KeyError) as error:
print('Go cache upload skipped: ' + str(error), file=sys.stderr)
return 1
if __name__ == '__main__':
raise SystemExit(main())
File diff suppressed because it is too large Load Diff
+76
View File
@@ -0,0 +1,76 @@
#!/usr/bin/env python3
"""Verify prepared Node dependencies without installing or changing them."""
import argparse
import json
from pathlib import Path
import subprocess
import sys
from prepare_ci_workspace import PREFLIGHT
IMAGE = Path('/opt/aego')
PACKAGES = ('playwright-core', 'pixelmatch', 'pngjs')
def verify(root, image=IMAGE):
root = root.resolve(strict=True)
image = image.resolve(strict=True)
source_lock = root / 'tools/ci/env/lock.json'
image_lock = image / 'ci-env/lock.json'
if source_lock.is_symlink() or image_lock.is_symlink() or source_lock.read_bytes() != image_lock.read_bytes():
raise ValueError('checkout and prepared image locks differ')
lock = json.loads(image_lock.read_bytes())
if lock.get('schema') != 1 or lock.get('platform') != 'linux/amd64':
raise ValueError('unsupported prepared image lock')
PREFLIGHT.check_input_set(root, lock)
PREFLIGHT.check_input_set(image, lock, image=True)
modules = image / 'websmoke/node_modules'
link = root / 'tools/websmoke/node_modules'
if modules.is_symlink() or not modules.is_dir():
raise ValueError('prepared Node dependencies are missing')
if not link.is_symlink() or link.resolve(strict=True) != modules.resolve(strict=True):
raise ValueError('workspace does not use the prepared Node dependency tree')
package_lock = json.loads((root / 'tools/websmoke/package-lock.json').read_bytes())
expected = {name: package_lock['packages']['node_modules/' + name]['version'] for name in PACKAGES}
script = '''const names=['playwright-core','pixelmatch','pngjs'];
(async () => {
const versions={}, paths={};
for (const name of names) {
versions[name]=require(name+'/package.json').version;
paths[name]=require.resolve(name);
await import(name);
}
console.log(JSON.stringify({node:process.version,versions,paths}));
})().catch(error => { console.error(error); process.exitCode=1; });'''
result = subprocess.run(['node', '-e', script], cwd=root / 'tools/websmoke',
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, timeout=30)
if result.returncode:
raise ValueError('prepared Node dependency import failed: ' + result.stderr.strip()[:500])
resolved = json.loads(result.stdout)
if resolved.get('node') != lock['tools']['node'] or resolved.get('versions') != expected:
raise ValueError('Node version or prepared package versions differ from the lock')
base = modules.resolve(strict=True)
for name in PACKAGES:
path = Path(resolved['paths'][name]).resolve(strict=True)
if base not in path.parents:
raise ValueError('Node resolved a package outside the prepared dependency tree: ' + name)
return {'status': 'PASS', 'node': resolved['node'], 'packages': expected,
'note': 'prepared Node dependency verification only; no installation was performed'}
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--root', type=Path, required=True)
args = parser.parse_args()
try:
print(json.dumps(verify(args.root), indent=2))
except (OSError, ValueError, KeyError, TypeError, subprocess.SubprocessError) as error:
print('prepared Node dependency verification failed: ' + str(error), file=sys.stderr)
return 1
return 0
if __name__ == '__main__':
raise SystemExit(main())
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env python3
"""Use the verified image Staticcheck or preserve the local go-run behavior."""
import json
import os
from pathlib import Path
import subprocess
import sys
from prepare_ci_workspace import PREFLIGHT
IMAGE = Path('/opt/aego')
def select_command(root, image, version, args, mode):
if mode == '0':
return ['go', 'run', 'honnef.co/go/tools/cmd/staticcheck@' + version, *args]
if mode != '1':
raise ValueError('invalid AEGO_CI_PREPARED value')
root = root.resolve(strict=True)
image = image.resolve(strict=True)
source_lock = root / 'tools/ci/env/lock.json'
image_lock = image / 'ci-env/lock.json'
if source_lock.is_symlink() or image_lock.is_symlink() or source_lock.read_bytes() != image_lock.read_bytes():
raise ValueError('checkout and prepared image locks differ')
lock = json.loads(image_lock.read_bytes())
if lock.get('schema') != 1 or lock.get('platform') != 'linux/amd64':
raise ValueError('unsupported prepared image lock')
if version != lock['tools']['staticcheck']:
raise ValueError('requested Staticcheck version differs from prepared image')
PREFLIGHT.check_input_set(root, lock)
PREFLIGHT.check_input_set(image, lock, image=True)
binary = image / 'bin/staticcheck'
if binary.is_symlink() or not binary.is_file() or not os.access(binary, os.X_OK):
raise ValueError('prepared Staticcheck binary is missing or not executable')
# Verify Go, Staticcheck build metadata and the other pinned tool versions.
PREFLIGHT.check_tools(lock)
return [str(binary), *args]
def main():
if len(sys.argv) < 3 or sys.argv[2] != '--':
raise SystemExit('usage: staticcheck_runner.py VERSION -- [staticcheck arguments]')
try:
argv = select_command(Path.cwd(), IMAGE, sys.argv[1], sys.argv[3:], os.environ.get('AEGO_CI_PREPARED', '0'))
os.execvp(argv[0], argv)
except (OSError, ValueError, KeyError, TypeError, subprocess.SubprocessError) as error:
print('Staticcheck preparation failed: ' + str(error), file=sys.stderr)
return 1
if __name__ == '__main__':
raise SystemExit(main())