image: node:latest

cache:
  paths:
  - node_modules/

before_script:
  - node -v
  - npm -v
  - npm install --ignore-scripts --no-optional

stages:
  - lint
  - bundle
  - test
  - performance
  - deploy

lint:
  stage: lint
  script:
   - npm run eslint

bundle:
  stage: bundle
  script:
   - npm run build
  only:
   - master
   - develop

test:
  stage: test
  script:
   - npm test
  only:
   - master
   - develop

performance:
  stage: performance
  script:
   - npm run perf
  only:
  - master
  - develop

pages:
  stage: deploy
  script:
  - cd dashboard && npm install --ignore-scripts --no-optional && npm rebuild node-sass && npm run build && cd ..
  - mkdir .public
  - cp -r dashboard/build/fonts .public
  - cp dashboard/build/dashboard.* .public
  - cp dashboard/build/index.html .public
  - mv .public public
  artifacts:
    paths:
    - public
  only:
  - master
