From 67d0f4db547604ca2ce7fb55a21f74d4b20a4b49 Mon Sep 17 00:00:00 2001
From: Daniel Rainer <daniel.m.rainer@student.uibk.ac.at>
Date: Fri, 4 Mar 2022 17:19:31 +0100
Subject: [PATCH] Refine caching for npm

---
 .gitlab-ci.yml | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index bae7ac646..d008f1893 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -4,11 +4,6 @@ cache:
   - key: '$CI_COMMIT_REF_NAME'
     paths:
       - .maven/
-  - key:
-      files:
-        - package-lock.json
-    paths:
-      - node_modules/
 
 stages:
   - setup
@@ -28,6 +23,13 @@ npm-install:
   stage: setup
   script:
     - npm install
+  cache:
+    key:
+      files:
+        - package-lock.json
+    paths:
+      - node_modules/
+    policy: pull-push
 
 checkstyle:
   stage: lint
@@ -41,6 +43,13 @@ prettier:
     - npm run prettier:check
   allow_failure: true
   needs: [npm-install]
+  cache:
+    key:
+      files:
+        - package-lock.json
+    paths:
+      - node_modules/
+    policy: pull
 
 eslint:
   stage: lint
@@ -50,6 +59,13 @@ eslint:
     - "! grep -qE '✖ [0-9]+ problem' lint.log"
   allow_failure: true
   needs: [npm-install]
+  cache:
+    key:
+      files:
+        - package-lock.json
+    paths:
+      - node_modules/
+    policy: pull
 
 maven-compile:
   stage: build
@@ -102,6 +118,13 @@ frontend-test:
     expire_in: 1 day
   allow_failure: true
   needs: [npm-install]
+  cache:
+    key:
+      files:
+        - package-lock.json
+    paths:
+      - node_modules/
+    policy: pull
 
 sonar-analyze:
   stage: analyze
-- 
GitLab