# Note: We use --silent argument on yarn invocations to keep the output simple
# and readable through email notifications.
image: node:8

cache:
    key: 'node-modules-cyclassist'
    paths:
        - node_modules/
        - yarn.lock

stages:
    - lint  # Check code syntax and coding style
    - build  # Try to build Kresus code
    - test  # Run unit tests

# Lint and check last commit in a dedicated task
lint:
    stage: lint
    before_script:
        - yarn install
    script:
        # Lint JS code
        - yarn run --silent lint

# Build the server and client code in dev and production
build:
    stage: build
    before_script:
        - yarn install
    script:
        # Check everything builds correctly
        - yarn run --silent build
    cache:
        policy: pull

# Run tests
test:
    stage: test
    before_script:
        - yarn install
    script:
        - yarn run --silent test
    cache:
        policy: pull
