From 690bc47fd3f96155078dda738585e77c0abf9619 Mon Sep 17 00:00:00 2001
From: Eliot Berriot <contact@eliotberriot.com>
Date: Sat, 23 Jun 2018 16:51:31 +0200
Subject: [PATCH] See #327: review app for the front \o/

---
 .gitlab-ci.yml              | 42 +++++++++++++++++++++++++++++++++++++
 front/config/prod.env.js    |  4 +++-
 front/src/store/instance.js |  2 +-
 3 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 206bb50cc4..4005c8911d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -7,11 +7,53 @@ variables:
 
 
 stages:
+  - review
   - lint
   - test
   - build
   - deploy
 
+review:
+  stage: review
+  image: node:9
+  when: manual
+  allow_failure: true
+  before_script:
+    - cd front
+  script:
+    - yarn install
+    # this is to ensure we don't have any errors in the output,
+    # cf https://code.eliotberriot.com/funkwhale/funkwhale/issues/169
+    - INSTANCE_URL=$REVIEW_INSTANCE_URL yarn run build | tee /dev/stderr | (! grep -i 'ERROR in')
+    - mkdir -p /static/$CI_BUILD_REF_SLUG
+    - cp -r dist/* /static/$CI_BUILD_REF_SLUG
+  cache:
+    key: "$CI_PROJECT_ID__front_dependencies"
+    paths:
+      - front/node_modules
+      - front/yarn.lock
+  environment:
+    name: review/$CI_BUILD_REF_NAME
+    url: http://$CI_BUILD_REF_SLUG.$REVIEW_DOMAIN
+    on_stop: stop_review
+  only:
+    - branches@funkwhale/funkwhale
+  tags:
+    - funkwhale-review
+
+stop_review:
+  stage: review
+  script:
+    - rm -rf /static/$CI_BUILD_REF_SLUG/
+  variables:
+    GIT_STRATEGY: none
+  when: manual
+  environment:
+    name: review/$CI_BUILD_REF_NAME
+    action: stop
+  tags:
+    - funkwhale-review
+
 black:
   image: python:3.6
   stage: lint
diff --git a/front/config/prod.env.js b/front/config/prod.env.js
index 773d263d31..40cf489734 100644
--- a/front/config/prod.env.js
+++ b/front/config/prod.env.js
@@ -1,3 +1,5 @@
+let url = process.env.INSTANCE_URL || '/'
 module.exports = {
-  NODE_ENV: '"production"'
+  NODE_ENV: '"production"',
+  INSTANCE_URL: `"${url}"`
 }
diff --git a/front/src/store/instance.js b/front/src/store/instance.js
index ba069ac4cc..555bd82391 100644
--- a/front/src/store/instance.js
+++ b/front/src/store/instance.js
@@ -6,7 +6,7 @@ export default {
   namespaced: true,
   state: {
     maxEvents: 200,
-    instanceUrl: '/',
+    instanceUrl: process.env.INSTANCE_URL,
     events: [],
     settings: {
       instance: {
-- 
GitLab