image: node:lts

stages:
  - 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:
    - npm ci

test:unit:
  stage: test
  needs: ["npm:install"]
  script:
    - npm ci
    - npm run test:unit

#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
