From 05ef66a3c462e27cf5118bcc249f948fbb506eac Mon Sep 17 00:00:00 2001
From: Erik Borgeteien Hansen <erikbhan@stud.ntnu.no>
Date: Wed, 27 Apr 2022 12:04:39 +0200
Subject: [PATCH] Update .gitlab-ci.yml file

---
 .gitlab-ci.yml | 168 ++++++++++++-------------------------------------
 1 file changed, 40 insertions(+), 128 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7abd519..09b5f52 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,139 +1,51 @@
 image: node:lts-alpine
 
 stages:
-  - install
-  - quality
   - build
-  # - deploy
-  - audit
-
-variables:
-  npm_config_cache: "$CI_PROJECT_DIR/.npm"
-
-install:
-  stage: install
-  script:
-    - npm ci
-  artifacts:
-    name: "artifacts"
-    untracked: true
-    expire_in: 60 mins
-    paths:
-      - .npm/
-      - node_modules/
-
-build:
+  - test
+#  - deploy
+
+# These folders are cached between builds
+# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
+cache:
+  key: ${CI_COMMIT_REF_SLUG}
+  paths:
+    # Default cache directory from https://classic.yarnpkg.com/en/docs/install-ci/#gitlab.
+    - node_modules/
+    # Enables git-lab CI caching. Both .cache and public must be cached, otherwise builds will fail.
+    - .cache/
+    - public/
+
+npm:install:
   stage: build
   script:
-    - CI=false npm run build
-  artifacts:
-    paths:
-      - build
-    expire_in: 60 mins
-  dependencies:
-    - install
-
-linting:
-  stage: quality
-  script:
-    - npm run lint
-  dependencies:
-    - install
+    - npm ci
 
 test:unit:
-  stage: quality
+  stage: test
+  needs: ["npm:install"]
   script:
     - npm run test:unit
-  dependencies:
-    - install
-  coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
-
-# test:e2e:
-#   stage: quality
-#   image: cypress/browsers:chrome69
-#   dependencies:
-#     - install
-#     - build
-#   script:
-#     - npm run e2e:ci
-#   artifacts:
-#     paths:
-#       - cypress/screenshots
-#       - cypress/videos
-#     expire_in: 1 day
-
-# .deploy:
-#   stage: deploy
-#   before_script:
-#     - npm install -g firebase-tools
-#     - (if [ -d "build" ]; then echo ok; else exit "no build folder, try to run pipeline again"; fi);
-#   script:
-#     - firebase deploy --token $FIREBASE_TOKEN --non-interactive --only hosting:$ENV
-#   when: manual
-
-# deploy_to_alpha:
-#   environment:
-#     name: alpha
-#     url: $ALPHA_URL
-#   extends: .deploy
-#   variables:
-#     ENV: alpha
-#   except:
-#     - develop
-#     - main
-
-# deploy_to_beta:
-#   environment:
-#     name: beta
-#     url: $BETA_URL
-#   extends: .deploy
-#   variables:
-#     ENV: beta
-#   only:
-#     - develop
-
-# deploy_to_prod:
-#   environment:
-#     name: prod
-#     url: $PROD_URL
-#   extends: .deploy
-#   variables:
-#     ENV: prod
-#   only:
-#     refs:
-#       - main
-
-.lighthouse:
-  image: markhobson/node-chrome
-  stage: audit
-  before_script:
-    - npm i -g lighthouse
-  script:
-    - lighthouse --chrome-flags="--headless --no-sandbox" $LIGHTHOUSE_TEST_URL --output html --output-path ./report.html
-  artifacts:
-    paths:
-      - ./report.html
-    expire_in: 1 week
-  when: manual
-
-# run_lighthouse_alpha:
-#   extends: .lighthouse
-#   variables:
-#     LIGHTHOUSE_TEST_URL: $ALPHA_URL
-#   except:
-#     - develop
-#     - main
-
-# run_lighthouse_beta:
-#   extends: .lighthouse
-#   variables:
-#     LIGHTHOUSE_TEST_URL: $BETA_URL
-#   only:
-#     - develop
 
-run_lighthouse_prod:
-  extends: .lighthouse
-  variables:
-    LIGHTHOUSE_TEST_URL: $PROD_URL
-  only:
-    - main
+#test:coverage:
+#  stage: test
+#  needs: ["npm:install"]
+#  script:
+#    - ./node_modules/.bin/gatsby info
+#  rules:
+#    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
+#    - if: $CI_MERGE_REQUEST_ID
+
+#pages:
+#  stage: deploy
+#  needs: 
+#    - npm:install
+#    - test:unit
+#    - test:gatsby
+#  script:
+#    - ./node_modules/.bin/gatsby build --prefix-paths
+#  artifacts:
+#    paths:
+#      - public
+#  rules:
+#    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
-- 
GitLab