gitlab-ci: Manage pacman cache
authorJan Vesely <jano.vesely@gmail.com>
Wed, 29 Apr 2020 05:08:15 +0000 (01:08 -0400)
committerJán Veselý <jano.vesely@gmail.com>
Mon, 4 May 2020 01:29:35 +0000 (01:29 +0000)
Drop unused packages from download cache.
Signed-off-by: Jan Vesely <jano.vesely@gmail.com>
.gitlab-ci.yml

index 31fbf880448daec588a9806ca3a2d9d3f31f8264..6da021f862a035d2ba4650e0c48b4454337a9ad4 100644 (file)
@@ -5,12 +5,14 @@ cache:
 .build:
   stage: build
   image: archlinux/base:latest
+  variables:
+    PACMAN_CACHE: $CI_PROJECT_DIR/_pacman_cache
   artifacts:
     when: always
     paths:
       - _build/meson-logs
   before_script:
-    - pacman -Syu --noconfirm --needed --cachedir `pwd`/_pacman_cache
+    - pacman -Syu --noconfirm --needed --cachedir $PACMAN_CACHE
         base-devel
         git
         gobject-introspection
@@ -28,6 +30,10 @@ cache:
         ${EXTRA_OPTIONS}
     - ninja -C _build
     - ninja -C _build test
+  after_script:
+    # Remove all cached packages but the latest version
+    - pacman -S --noconfirm --cachedir $PACMAN_CACHE pacman-contrib
+    - paccache -r -k1 --cachedir $PACMAN_CACHE
 
 latest-lcms:
   extends: .build