Files
codebase-memory-mcp/.github/workflows/cache-warm.yml
T
Martin Vogel e3a9fa34ed ci: let apt fail over between mirrors instead of hanging
The hosted Ubuntu x64 runners read the archive through
mirror+file:/etc/apt/apt-mirrors.txt. With Acquire::Retries above 0
(including the apt default of 3), a failover from a dead first entry
of that list (connection refused, DNS failure or a stalled host) to
the next entry goes idle: apt-get fetches a few InRelease files from
the second mirror and then waits until the step timeout. With
Acquire::Retries=0 the same failover completes. Seen on noble
(apt 2.8.3) and jammy (apt 2.4.14).

Every apt step this branch hardened now picks the retry count at
runtime, applied to both update and install: 0 when the runner has the
mirror list (moving to the next mirror is the retry), 3 otherwise
(arm64 runners and any host with plain sources keep their retries).
--error-on=any, the http and https timeouts and the step timeouts are
unchanged.

Proof: the step text extracted from the edited _build.yml (update plus
install of zlib1g-dev), run under bash -e in ubuntu:24.04 and
ubuntu:22.04 containers with runner-shaped mirror lists:
- first mirror refused: exit 0 in 8 s / 9 s, every index and deb
  fetched from the second mirror
- first mirror stalled (192.0.2.1): exit 0 in 68 s / 69 s, one 30 s
  timeout each for update and install, then the second mirror
- healthy first mirror: exit 0 in 7 s / 9 s
- no mirror list, plain sources: the prefix keeps Retries=3, exit 0
  in 8 s / 7 s
- every mirror dead: update exits 100 in under 1 s, install skipped
- revert check, the previous step text with a dead first mirror
  (refused or stalled): idle with no Packages index at the 180 s cap
  on both releases

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-01 12:32:45 +01:00

125 lines
4.7 KiB
YAML

# Nightly compiler-cache warming for main's scope. GitHub cache isolation
# lets a PR restore only caches written by its own ref or the base branch —
# and nothing used to write test caches in main's scope (the test workflow
# runs on pull_request and workflow_dispatch only), so the cross-ref
# fallback restore keys in _test.yml had no warm source and every fresh PR
# built cold. This build-only job (no tests) keeps main-scoped caches at
# most a day stale; CCACHE_COMPILERCHECK=content turns staleness into
# partial misses, never wrong output. The build commands and ccache
# environment mirror scripts/test.sh's build phase exactly — a warm entry
# only hits when flags and compiler content match, so fidelity here is what
# makes the cache useful.
name: Cache warm
on:
schedule:
- cron: '17 2 * * *'
workflow_dispatch: {}
permissions:
contents: read
jobs:
warm-unix:
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, cc: gcc, cxx: g++ }
- { os: ubuntu-24.04-arm, cc: gcc, cxx: g++ }
- { os: macos-15, cc: cc, cxx: c++ }
- { os: macos-15-intel, cc: cc, cxx: c++ }
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install deps (Ubuntu)
if: startsWith(matrix.os, 'ubuntu')
timeout-minutes: 10
run: APT_RETRIES=3; [ -f /etc/apt/apt-mirrors.txt ] && APT_RETRIES=0; sudo apt-get -o Acquire::Retries=$APT_RETRIES -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30 --error-on=any update && sudo apt-get -o Acquire::Retries=$APT_RETRIES -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30 install -y zlib1g-dev ccache
- name: Install ccache (macOS)
if: startsWith(matrix.os, 'macos')
run: command -v ccache >/dev/null 2>&1 || brew install ccache
- name: Compiler cache (restore)
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ github.workspace }}/.ccache
key: ccache-test-${{ matrix.os }}-${{ matrix.cc }}-${{ github.ref }}-${{ github.sha }}
restore-keys: |
ccache-test-${{ matrix.os }}-${{ matrix.cc }}-${{ github.ref }}-
ccache-test-${{ matrix.os }}-${{ matrix.cc }}-
- name: Build (test runner + product, no tests)
run: |
source scripts/env.sh
make -j"$(getconf _NPROCESSORS_ONLN)" -f Makefile.cbm \
build/c/test-runner cbm CC=${{ matrix.cc }} CXX=${{ matrix.cxx }}
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 1500M
- name: ccache stats
run: ccache -sv || ccache -s
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
- name: Compiler cache (save)
if: always()
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ github.workspace }}/.ccache
key: ccache-test-${{ matrix.os }}-${{ matrix.cc }}-${{ github.ref }}-${{ github.sha }}
warm-windows:
runs-on: windows-latest
timeout-minutes: 90
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2
with:
msystem: CLANG64
path-type: inherit
install: >-
mingw-w64-clang-x86_64-clang
mingw-w64-clang-x86_64-compiler-rt
mingw-w64-clang-x86_64-zlib
mingw-w64-clang-x86_64-ccache
make
git
- name: Compiler cache (restore)
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ github.workspace }}/.ccache
key: ccache-test-windows-latest-CLANG64-${{ github.ref }}-${{ github.sha }}
restore-keys: |
ccache-test-windows-latest-CLANG64-${{ github.ref }}-
ccache-test-windows-latest-CLANG64-
- name: Build (test runner + product, no tests)
run: |
source scripts/env.sh
make -j"$(nproc)" -f Makefile.cbm build/c/test-runner cbm CC=clang CXX=clang++
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 1500M
- name: ccache stats
run: ccache -sv || ccache -s
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
- name: Compiler cache (save)
if: always()
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ github.workspace }}/.ccache
key: ccache-test-windows-latest-CLANG64-${{ github.ref }}-${{ github.sha }}