From 80d9af90454d3939ac741f5acdc94fa24d2bc999 Mon Sep 17 00:00:00 2001
From: Michael Kriese <michael.kriese@visualon.de>
Date: Tue, 11 Feb 2020 20:44:42 +0100
Subject: [PATCH] chore(ci): clear download cache on miss (#5451)

---
 .github/workflows/test.yml | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index ec00295afd..d2de40b8fb 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -65,16 +65,15 @@ jobs:
           pip --version
 
       - uses: actions/checkout@v2
-        with:
-          fetch-depth: 1
 
       - name: Cache Yarn packages
+        id: yarn_cache_packages
         uses: actions/cache@v1
         with:
           path: ${{ steps.init.outputs.yarn_cache }}
-          key: ${{ runner.os }}-yarn_cache-${{ hashFiles('**/yarn.lock') }}
+          key: v1-${{ runner.os }}-yarn_cache-${{ hashFiles('**/yarn.lock') }}
           restore-keys: |
-            ${{ runner.os }}-yarn_cache-
+            v1-${{ runner.os }}-yarn_cache-
 
       - name: Cache node_modules
         uses: actions/cache@v1
@@ -85,6 +84,7 @@ jobs:
             ${{ runner.os }}-${{ matrix.node-version }}-yarn-
 
       - name: Cache pip packages
+        id: pip_cache_packages
         uses: actions/cache@v1
         with:
           path: ${{ steps.init.outputs.pip_cache }}
@@ -92,6 +92,15 @@ jobs:
           restore-keys: |
             ${{ runner.os }}-${{ matrix.python-version }}-pip-
 
+      # Clear caches on cache miss, otherwise they will grow indefinitely
+      - name: Clear yarn cache
+        if: steps.yarn_cache_packages.outputs.cache-hit != 'true'
+        run: yarn cache clean
+
+      - name: Clear pip cache
+        if: steps.pip_cache_packages.outputs.cache-hit != 'true'
+        run: rm -rf ${{ steps.init.outputs.pip_cache }}
+
       - name: Installing dependencies
         shell: bash
         run: |
-- 
GitLab