The platform for continuously improving AI agents.
Cache Tesseract debs and the Playwright browser in CI (#322)
Rohit Gupta416a0f628217
diff --git a/.github/scripts/ci_apt_install.sh b/.github/scripts/ci_apt_install.shnew file mode 100644index 00000000..efe4e956--- /dev/null+++ b/.github/scripts/ci_apt_install.sh@@ -0,0 +1,27 @@+#!/usr/bin/env bash+# azure.archive.ubuntu.com sometimes serves at ~100 kB/s. A warm deb cache+# installs offline; a miss installs from apt and stores the debs for the next run.+set -euo pipefail++cache_dir=$1+shift+mkdir -p "$cache_dir"++shopt -s nullglob+debs=("$cache_dir"/*.deb)+if ((${#debs[@]})); then+ # dpkg -i downgrades by default; a cached deb must never replace a newer library.+ if sudo DEBIAN_FRONTEND=noninteractive dpkg --refuse-downgrade -i "${debs[@]}"; then+ exit 0+ fi+ echo "cached debs did not apply; installing from apt" >&2+fi++sudo DEBIAN_FRONTEND=noninteractive apt-get update+# --fix-broken repairs whatever a failed dpkg run left half-installed.+sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --fix-broken "$@"++fetched=(/var/cache/apt/archives/*.deb)+if ((${#fetched[@]})); then+ cp -n "${fetched[@]}" "$cache_dir"/+fidiff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 247f7edd..8ec178d6 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -194,8 +194,19 @@ jobs:- name: Create .env filerun: touch .env+ - name: Read the runner image version+ id: image+ run: echo "version=${ImageOS}-${ImageVersion}" >> "$GITHUB_OUTPUT"++ - name: Cache document OCR packages+ uses: actions/cache@v4+ with:+ path: ~/apt-tesseract+ # The debs hold only what this image lacked, so they belong to the image.+ key: tesseract-ocr-eng-osd-fra-spa-${{ steps.image.outputs.version }}+- name: Install document OCR runtime- run: sudo apt-get update && sudo apt-get install -y tesseract-ocr tesseract-ocr-eng tesseract-ocr-osd tesseract-ocr-fra tesseract-ocr-spa+ run: bash .github/scripts/ci_apt_install.sh ~/apt-tesseract tesseract-ocr tesseract-ocr-eng tesseract-ocr-osd tesseract-ocr-fra tesseract-ocr-spa- name: Run tests# Match local `make test`: xdist is already in the test dep group.@@ -259,13 +270,34 @@ jobs:restore-keys: |${{ runner.os }}-bun-+ - name: Read the runner image version+ id: image+ run: echo "version=${ImageOS}-${ImageVersion}" >> "$GITHUB_OUTPUT"++ - name: Cache document OCR packages+ uses: actions/cache@v4+ with:+ path: ~/apt-tesseract+ # The debs hold only what this image lacked, so they belong to the image.+ key: tesseract-ocr-eng-osd-fra-spa-${{ steps.image.outputs.version }}++ - name: Read the Playwright version+ id: playwright+ run: echo "version=$(uv run playwright --version | awk '{print $2}')" >> "$GITHUB_OUTPUT"++ - name: Cache Playwright browsers+ uses: actions/cache@v4+ with:+ path: ~/.cache/ms-playwright+ key: ${{ runner.os }}-playwright-chromium-headless-shell-${{ steps.playwright.outputs.version }}+- name: Install Console dependencies and browser for the Console journeys+ # No --with-deps: the runner image has the browser libraries, and the flag adds only font packages from apt.run: |cd frontend && bun install --frozen-lockfile- cd .. && uv run playwright install --with-deps chromium-headless-shell-- - name: Install document OCR runtime- run: sudo apt-get update && sudo apt-get install -y tesseract-ocr tesseract-ocr-eng tesseract-ocr-osd tesseract-ocr-fra tesseract-ocr-spa+ cd ..+ bash .github/scripts/ci_apt_install.sh ~/apt-tesseract tesseract-ocr tesseract-ocr-eng tesseract-ocr-osd tesseract-ocr-fra tesseract-ocr-spa+ uv run playwright install chromium-headless-shell- name: Run journeysrun: make test-journeys test_args="--junitxml=journeys.xml -o junit_duration_report=call"