From 1ef0db61c38c1d14d0eecc093dcf086b096a2dbe Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 21 May 2026 18:54:22 +0200 Subject: [PATCH] .github: ubuntu: fix apt cache The previous approach flooded the repository with new caches, thus leading to unnecessary eviction of other caches. Previously had splitted restore and save, but that required using separate keys, and github doesn't report partial cache hits (prefix-only), thus no chance of skipping unnecessary cache saves. Instead now moving out populating the cache into a separate job, which is run before all those who need the cache. This also allows us skipping `apt-get update` in the individual jobs, thus saving a bit more time. Signed-off-by: Enrico Weigelt, metux IT consult --- .github/actions/ubuntu-fetch-pkg/action.yml | 15 +++ .github/actions/ubuntu-install-pkg/action.yml | 10 +- .github/scripts/ubuntu/fetch-pkg.sh | 103 ++++++++++++++++++ .github/scripts/ubuntu/install-pkg.sh | 5 - .github/workflows/build-xserver.yml | 23 ++-- 5 files changed, 133 insertions(+), 23 deletions(-) create mode 100644 .github/actions/ubuntu-fetch-pkg/action.yml create mode 100755 .github/scripts/ubuntu/fetch-pkg.sh diff --git a/.github/actions/ubuntu-fetch-pkg/action.yml b/.github/actions/ubuntu-fetch-pkg/action.yml new file mode 100644 index 0000000000..1f3526f742 --- /dev/null +++ b/.github/actions/ubuntu-fetch-pkg/action.yml @@ -0,0 +1,15 @@ +name: ubuntu fetch packages +runs: + using: "composite" + steps: + - run: sudo chmod u+s /bin/tar + shell: bash + + - uses: actions/cache@v5 + id: apt-cache-restore + with: + path: /var/cache/apt + key: ${{ runner.os }}-apt-cache-v3 + + - run: sudo .github/scripts/ubuntu/fetch-pkg.sh + shell: bash diff --git a/.github/actions/ubuntu-install-pkg/action.yml b/.github/actions/ubuntu-install-pkg/action.yml index 88a5e0822d..8fde37795e 100644 --- a/.github/actions/ubuntu-install-pkg/action.yml +++ b/.github/actions/ubuntu-install-pkg/action.yml @@ -10,16 +10,10 @@ runs: - name: apt cache pull uses: actions/cache/restore@v5 with: + fail-on-cache-miss: true path: /var/cache/apt - key: xserver-apt-cache-${{ hashFiles('.github/scripts/ubuntu/install-pkg.sh') }}-v2 - restore-keys: xserver-apt-cache- + key: ${{ runner.os }}-apt-cache-v3 - name: pkg install run: sudo .github/scripts/ubuntu/install-pkg.sh shell: bash - - - name: apt cache push - uses: actions/cache/save@v5 - with: - path: /var/cache/apt - key: xserver-apt-cache-${{ hashFiles('.github/scripts/ubuntu/install-pkg.sh') }}-v2-${{ github.run_id }} diff --git a/.github/scripts/ubuntu/fetch-pkg.sh b/.github/scripts/ubuntu/fetch-pkg.sh new file mode 100755 index 0000000000..0189eafe20 --- /dev/null +++ b/.github/scripts/ubuntu/fetch-pkg.sh @@ -0,0 +1,103 @@ +#!/bin/bash + +# NOTE: don't forget to update both fetch-pkg and install-pkg and change cache name + +set -e + +# Packages which are needed by this script, but not for the xserver build +EPHEMERAL=" + libexpat-dev + libgles2-mesa-dev + libxkbcommon-dev + x11-utils + x11-xserver-utils + xauth + xvfb +" + +apt-get update + +apt-get install -d -y \ + $EPHEMERAL \ + autoconf \ + automake \ + build-essential \ + ca-certificates \ + libaudit-dev \ + libbsd-dev \ + libcairo2-dev \ + libdbus-1-dev \ + libdrm-dev \ + libegl1-mesa-dev \ + libepoxy-dev \ + libevdev2 \ + libexpat1 \ + libffi-dev \ + libgbm-dev \ + libgcrypt-dev \ + libgl1-mesa-dev \ + libgles2 \ + libglx-mesa0 \ + libinput10 \ + libinput-dev \ + libnvidia-egl-wayland-dev \ + libpciaccess-dev \ + libpixman-1-dev \ + libspice-protocol-dev \ + libsystemd-dev \ + libtool \ + libudev-dev \ + libunwind-dev \ + libx11-dev \ + libx11-xcb-dev \ + libxau-dev \ + libxaw7-dev \ + libxcb-glx0-dev \ + libxcb-icccm4-dev \ + libxcb-image0-dev \ + libxcb-keysyms1-dev \ + libxcb-randr0-dev \ + libxcb-render-util0-dev \ + libxcb-render0-dev \ + libxcb-shape0-dev \ + libxcb-shm0-dev \ + libxcb-util0-dev \ + libxcb-xf86dri0-dev \ + libxcb-xkb-dev \ + libxcb-xv0-dev \ + libxcb1-dev \ + libxdmcp-dev \ + libxext-dev \ + libxfixes-dev \ + libxfont-dev \ + libxi-dev \ + libxinerama-dev \ + libxkbcommon0 \ + libxkbfile-dev \ + libxmu-dev \ + libxmuu-dev \ + libxpm-dev \ + libxrandr-dev \ + libxrender-dev \ + libxres-dev \ + libxshmfence-dev \ + libxt-dev \ + libxtst-dev \ + libxv-dev \ + mesa-common-dev \ + meson \ + nettle-dev \ + libpango1.0-dev \ + pkg-config \ + x11-xkb-utils \ + xfonts-utils \ + xkb-data \ + xutils-dev \ + libxaw7-dev \ + python3-mako \ + libxcvt-dev \ + git \ + sudo + +# only pull them into apt cache -- for mingw32 build +apt-get install -d -y mingw-w64-tools gcc-mingw-w64 gcc-mingw-w64-i686 libz-mingw-w64-dev diff --git a/.github/scripts/ubuntu/install-pkg.sh b/.github/scripts/ubuntu/install-pkg.sh index ed4ec7653b..69aa9ca508 100755 --- a/.github/scripts/ubuntu/install-pkg.sh +++ b/.github/scripts/ubuntu/install-pkg.sh @@ -13,8 +13,6 @@ EPHEMERAL=" xvfb " -apt-get update - apt-get install -y \ $EPHEMERAL \ autoconf \ @@ -96,6 +94,3 @@ apt-get install -y \ libxcvt-dev \ git \ sudo - -# only pull them into apt cache -- for mingw32 build -apt-get install -d -y mingw-w64-tools gcc-mingw-w64 gcc-mingw-w64-i686 libz-mingw-w64-dev diff --git a/.github/workflows/build-xserver.yml b/.github/workflows/build-xserver.yml index 2729fb8c8a..e8ee754830 100644 --- a/.github/workflows/build-xserver.yml +++ b/.github/workflows/build-xserver.yml @@ -13,6 +13,12 @@ on: pull_request: jobs: + ubuntu-fetch-pkg: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: ./.github/actions/ubuntu-fetch-pkg + xserver-build-ubuntu-no-gbm: env: MESON_ARGS: -Dprefix=/usr -Dxephyr=true -Dwerror=true -Dxcsecurity=true -Dgbm=false -Dxorg=true -Dxvfb=true -Dxnest=true -Dxfbdev=true -Dtest_xephyr_gles=false @@ -20,10 +26,13 @@ jobs: GALLIUM_DRIVER: llvmpipe PIGLIT_PLATFORM: x11_egl runs-on: ubuntu-latest + needs: ubuntu-fetch-pkg steps: - name: Check out repository code uses: actions/checkout@v4 + - uses: ./.github/actions/ubuntu-install-pkg + - name: prepare build environment run: | MACHINE=`gcc -dumpmachine` @@ -31,16 +40,6 @@ jobs: echo "PKG_CONFIG_PATH=$X11_PREFIX/share/pkgconfig:$X11_PREFIX/lib/$MACHINE/pkgconfig:$X11_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH" >> "$GITHUB_ENV" sudo chown root /bin/tar && sudo chmod u+s /bin/tar - - name: apt cache - uses: actions/cache@v4 - with: - path: /var/cache/apt - key: apt-cache-${{ hashFiles('.github/scripts/ubuntu/install-pkg.sh') }} - restore-keys: apt-cache- - - - name: pkg install - run: sudo .github/scripts/ubuntu/install-pkg.sh - - name: X11 prereq cache uses: actions/cache@v4 with: @@ -69,6 +68,7 @@ jobs: GALLIUM_DRIVER: llvmpipe PIGLIT_PLATFORM: x11_egl runs-on: ubuntu-latest + needs: ubuntu-fetch-pkg steps: - name: Check out repository code uses: actions/checkout@v6 @@ -106,6 +106,7 @@ jobs: env: MESON_ARGS: -Dprefix=/home/runner/x11 -Dxorg-sdk=true -Dxorg=false -Dxephyr=false -Dwerror=false -Dxcsecurity=false -Dxorg=true -Dxvfb=false -Dxnest=false -Dxfbdev=false runs-on: ubuntu-latest + needs: ubuntu-fetch-pkg steps: - name: Check out repository code uses: actions/checkout@v6 @@ -133,6 +134,7 @@ jobs: drivers-build-ubuntu: needs: + - ubuntu-fetch-pkg - drivers-prepare-ubuntu runs-on: ubuntu-latest strategy: @@ -220,6 +222,7 @@ jobs: runs-on: ubuntu-latest env: MESON_ARGS: -Dprefix=/home/runner/x11 --cross-file=.github/scripts/mingw32/cross-i686-w64-mingw32.txt -Dwerror=true -Dglx=false -Dlisten_tcp=true -Dxvmc=true -Dxv=true -Dxvfb=true -Dxnest=true -Dxephyr=true -Dxfbdev=false + needs: ubuntu-fetch-pkg steps: - name: Check out repository code uses: actions/checkout@v6