[PATCH 1/1] Github Actions: cache util-linux tarball

David Timber <[email protected]>
Newsgroups dev.linux.lists.exfat
Message-ID <[email protected]>
To minimise the chance of CI pipeline run failures, cache the util-linux
tarball in Github Actions cache so that the tarball is not downloaded
every time the CI is run.

The connection to the CDN usually fail because:

  - Cloud VMs usually have low IP reputation due to scraping activities
  - Shared tenancy makes the connection unstable

Signed-off-by: David Timber <[email protected]>
---
 .github/workflows/c-cpp.yml | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml
index d332f04..10975b7 100644
--- a/.github/workflows/c-cpp.yml
+++ b/.github/workflows/c-cpp.yml
@@ -33,6 +33,7 @@ env:
     1T 2T 3T 4T 6T 8T 16T 32T 44T 64T
   TEST_MAGIC: dd01aeee-bab0-babe-babe-deadcafebeef
 
+  UTIL_LINUX_TARBALL: util-linux-2.42.tar.xz
   UTIL_LINUX_SRC: https://www.kernel.org/pub/linux/utils/util-linux/v2.42/util-linux-2.42.tar.xz
   # xfstests generic/740 equiv
   FOREIGN_FS: |
@@ -188,12 +189,29 @@ jobs:
         sudo apt-get install -y linux-modules-extra-$(uname -r)
         export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
         export PATH=/usr/local/lib:$PATH
+
+    - name: Retrieve util-linux tarball from cache
+      uses: actions/cache/restore@v6
+      id: restore-util-linux-tarball
+      with:
+        path: ${{ env.UTIL_LINUX_TARBALL }}
+        key: tarball-${{ env.UTIL_LINUX_TARBALL }}
+    - name: Download util-linux tarball
+      if: steps.restore-util-linux-tarball.outputs.cache-hit != 'true'
+      run: curl -L -o "$UTIL_LINUX_TARBALL" "$UTIL_LINUX_SRC"
+    - name: Save util-linux tarball from cache
+      uses: actions/cache/save@v6
+      if: steps.restore-util-linux-tarball.outputs.cache-hit != 'true'
+      with:
+        path: ${{ env.UTIL_LINUX_TARBALL }}
+        key: tarball-${{ env.UTIL_LINUX_TARBALL }}
+
     - name: Build libblkid
       shell: bash
       run: |
         set -e
-        curl "$UTIL_LINUX_SRC" | xzcat | tar xf -
-        pushd util-linux-*
+        tar xf "${{ env.UTIL_LINUX_TARBALL }}"
+        pushd util-linux-*/
 
         ./configure --host=${{ matrix.host }} --prefix=/usr/${{ matrix.host }}/local \
           --disable-shared --enable-static --disable-all-programs --enable-libblkid
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.