From fdf31252e61ca7efe99af41bb4780353cc2253dd Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 16 Oct 2026 14:31:18 -0700 Subject: [PATCH] Cache packages in Linux CI Compilers are installed from third-party archives that periodically return 50x or throttle to a crawl, which fails the build. Keep the downloaded packages and restore them on the next run so that both apt and the legacy wget-based installs work from disk instead of refetching. apt, unlike apt-get, discards downloaded packages after installing them unless the binary-specific Keep-Downloaded-Packages is set. The cache is written once per key; bump the -v1 suffix to refresh it after the package versions change. --- .github/workflows/linux.yml | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 22ee33a6..56bb4abe 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -86,13 +86,27 @@ jobs: steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + # Packages are installed from third-party archives that periodically + # return 50x or throttle, which otherwise fails the build. The key covers + # everything that determines the package set; bump the -v1 suffix to + # discard the cached packages. + - name: Cache packages + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ~/apt-cache + key: pkg-${{matrix.os || 'ubuntu-22.04'}}-${{matrix.cxx}}-${{matrix.install}}-v1 + + - name: Create package cache directory + run: mkdir -p ~/apt-cache + - name: Install GCC 4.9 run: | sudo apt update sudo apt install libatomic1 libc6-dev libgomp1 libitm1 libmpc3 + cd ~/apt-cache # https://launchpad.net/ubuntu/xenial/amd64/g++-4.9/4.9.3-13ubuntu2 # launchpad periodically returns 50x errors, so retry to avoid flaky CI. - wget --no-verbose --tries=5 --waitretry=10 \ + wget --no-verbose --no-clobber --tries=5 --waitretry=10 \ --retry-connrefused --retry-on-http-error=502,503,504 \ http://launchpadlibrarian.net/230069137/libmpfr4_3.1.3-2_amd64.deb \ http://launchpadlibrarian.net/253728424/libasan1_4.9.3-13ubuntu2_amd64.deb \ @@ -123,9 +137,10 @@ jobs: run: | sudo apt update sudo apt install libtinfo5 + cd ~/apt-cache # https://code.launchpad.net/ubuntu/xenial/amd64/clang-3.6/1:3.6.2-3ubuntu2 # launchpad periodically returns 50x errors, so retry to avoid flaky CI. - wget --no-verbose --tries=5 --waitretry=10 \ + wget --no-verbose --no-clobber --tries=5 --waitretry=10 \ --retry-connrefused --retry-on-http-error=502,503,504 \ http://launchpadlibrarian.net/230019046/libffi6_3.2.1-4_amd64.deb \ http://launchpadlibrarian.net/445346109/libasan2_5.4.0-6ubuntu1~16.04.12_amd64.deb \ @@ -186,9 +201,15 @@ jobs: - name: Create build environment run: | + # apt (unlike apt-get) defaults to discarding downloaded packages, so + # the binary-specific setting is required to populate the cache. + printf 'Binary::apt::APT::Keep-Downloaded-Packages "true";\n' | \ + sudo tee /etc/apt/apt.conf.d/99keep-packages + sudo cp -n ~/apt-cache/*.deb /var/cache/apt/archives || true sudo apt update ${{matrix.install}} sudo apt install locales-all + cp -n /var/cache/apt/archives/*.deb ~/apt-cache || true cmake -E make_directory ${{runner.workspace}}/build - name: Select matching C compiler