From 883a58c944f5675b9cba5e5116849a3fd4cc612b Mon Sep 17 00:00:00 2001 From: Kevin Longe <273747162+kvlonge@users.noreply.github.com> Date: Mon, 30 Nov 2026 13:25:21 +0000 Subject: [PATCH 1/2] ci: install valgrind from a package cache, then the runner's mirror The valgrind step sent apt only to archive.ubuntu.com, so an outage on the runners' path to it failed every pull request before any check ran. The step now installs from cached packages, keyed on the runner image and the valgrind version, then from the runner's default mirror, then from archive.ubuntu.com, and fails with an infrastructure error naming all three when none works. --- .github/workflows/ci.yml | 68 ++++++++++++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3066a7dc1..88d56de13 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,22 +116,70 @@ jobs: run: uv python install 3.12 - name: Install development tools without the recorder run: uv sync --locked --no-group recorder - # The instruction-count guard in check-ci runs its workloads under callgrind. - # The runner's Azure Ubuntu mirror sometimes stops resolving, so apt uses archive.ubuntu.com - # directly. apt still checks the archive's signatures. + # The instruction-count guard in check-ci runs its workloads under callgrind, so valgrind is + # required. Its packages come from the cache below, else the runner's own mirror, else + # archive.ubuntu.com. The key holds the runner image, whose libc6 the libc6-dbg dependency + # must match, and noble's only valgrind version. A warm cache installs without the network. + - name: Name the valgrind package cache + id: valgrind-key + env: + VALGRIND_VERSION: "1:3.22.0-0ubuntu3" + run: echo "key=valgrind-debs-${ImageOS}-${ImageVersion}-${VALGRIND_VERSION}" >> "${GITHUB_OUTPUT}" + - name: Restore the valgrind packages + id: valgrind-cache + uses: actions/cache/restore@v4 + with: + path: ~/.cache/valgrind-debs + key: ${{ steps.valgrind-key.outputs.key }} - name: Install valgrind + env: + VALGRIND_VERSION: "1:3.22.0-0ubuntu3" + CACHE_HIT: ${{ steps.valgrind-cache.outputs.cache-hit }} run: | + debs="${HOME}/.cache/valgrind-debs" + apt_options=(-q -o Acquire::Retries=2 -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20) + install_debs() { + compgen -G "${debs}/*.deb" > /dev/null && sudo dpkg -i "${debs}"/*.deb && valgrind --version + } + # Downloads valgrind and the packages it needs that the image lacks, then installs them. + download_and_install() { + rm -rf "${debs}" && mkdir -p "${debs}/partial" + for attempt in 1 2; do + if sudo apt-get update "${apt_options[@]}" && + sudo apt-get install -y --download-only --no-install-recommends "${apt_options[@]}" \ + -o Dir::Cache::archives="${debs}" "valgrind=${VALGRIND_VERSION}" && + install_debs; then + sudo rm -rf "${debs}/partial" "${debs}/lock" + sudo chown -R "$(id -u):$(id -g)" "${debs}" + return 0 + fi + sleep $((attempt * 15)) + done + return 1 + } + if [[ "${CACHE_HIT}" == "true" ]] && install_debs; then + echo "valgrind source: package cache" + exit 0 + fi + if download_and_install; then + echo "valgrind source: the runner's default mirror" + exit 0 + fi { sudo grep -rlE 'mirror\+file:|azure\.archive\.ubuntu\.com' /etc/apt || true; } | xargs -r sudo sed -i -E \ -e 's#mirror\+file:/etc/apt/apt-mirrors\.txt#http://archive.ubuntu.com/ubuntu/#g' \ -e 's#https?://azure\.archive\.ubuntu\.com/ubuntu/?#http://archive.ubuntu.com/ubuntu/#g' - for attempt in 1 2 3; do - if sudo apt-get update -q -o Acquire::Retries=3 && - sudo apt-get install -y -q --no-install-recommends -o Acquire::Retries=3 valgrind; then - exit 0 - fi - sleep $((attempt * 15)) - done + if download_and_install; then + echo "valgrind source: archive.ubuntu.com" + exit 0 + fi + echo "::error title=Infrastructure::infrastructure: could not install valgrind from the package cache, the runner's default mirror or archive.ubuntu.com; the instruction-count guard needs it" exit 1 + - name: Save the valgrind packages + if: steps.valgrind-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: ~/.cache/valgrind-debs + key: ${{ steps.valgrind-key.outputs.key }} # One gate build serves every step: check-ci, the Rust tests, the Python tests and the replay. - name: Run static checks and tests run: make check-merge test-python From 1b93e0e5349b567ea5f4b3249f7af6b68cb3b6da Mon Sep 17 00:00:00 2001 From: Kevin Longe <273747162+kvlonge@users.noreply.github.com> Date: Mon, 30 Nov 2026 13:29:51 +0000 Subject: [PATCH 2/2] ci: clear root-owned partial downloads and accept an image's valgrind A download cut short by an outage leaves apt's root-owned partial directory, so the next source now clears it with sudo. A valgrind the runner image already has is used as is. The pinned version is set once, for the whole job. --- .github/workflows/ci.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88d56de13..feac96cdb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,6 +86,8 @@ jobs: REPLAY: ${{ needs.changes.outputs.replay }} # The Python tests and the replay take the module and binary from check-merge's gate build. PYTHON_MODULE_BUILD: gate-build + # Noble's only valgrind version; the instruction-count guard runs under it. + VALGRIND_VERSION: "1:3.22.0-0ubuntu3" steps: - uses: actions/checkout@v4 with: @@ -122,8 +124,6 @@ jobs: # must match, and noble's only valgrind version. A warm cache installs without the network. - name: Name the valgrind package cache id: valgrind-key - env: - VALGRIND_VERSION: "1:3.22.0-0ubuntu3" run: echo "key=valgrind-debs-${ImageOS}-${ImageVersion}-${VALGRIND_VERSION}" >> "${GITHUB_OUTPUT}" - name: Restore the valgrind packages id: valgrind-cache @@ -133,7 +133,6 @@ jobs: key: ${{ steps.valgrind-key.outputs.key }} - name: Install valgrind env: - VALGRIND_VERSION: "1:3.22.0-0ubuntu3" CACHE_HIT: ${{ steps.valgrind-cache.outputs.cache-hit }} run: | debs="${HOME}/.cache/valgrind-debs" @@ -143,7 +142,7 @@ jobs: } # Downloads valgrind and the packages it needs that the image lacks, then installs them. download_and_install() { - rm -rf "${debs}" && mkdir -p "${debs}/partial" + sudo rm -rf "${debs}" && mkdir -p "${debs}/partial" for attempt in 1 2; do if sudo apt-get update "${apt_options[@]}" && sudo apt-get install -y --download-only --no-install-recommends "${apt_options[@]}" \ @@ -157,6 +156,10 @@ jobs: done return 1 } + if valgrind --version 2> /dev/null; then + echo "valgrind source: the runner image" + exit 0 + fi if [[ "${CACHE_HIT}" == "true" ]] && install_debs; then echo "valgrind source: package cache" exit 0