# Use the docker runner
image: node:6

before_script:
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
- echo "deb http://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
- apt-get update -y
- apt-get install yarn -y
- pwd
- which nodejs
- nodejs -v
- which npm
- npm -v
- which yarn
- yarn --version
- yarn config set cache-folder .yarn

cache:
  key: "$CI_BUILD_REF_NAME"
  paths:
  - node_modules/
  - .yarn/

# jobs sequense pipeline
stages:
- test
- build

# test job: test project use npm
test:
  tags:
  - node-6
  script:
  - yarn install
  - npm run lint
  stage: test


# build job: Use react-starter to create the react project
build:
  tags:
  - node-6
  script:
  - yarn install
  - npm link
  - which react-starter
  - react-starter --version
  - react-starter -n test
  - cd test && yarn && npm run lint && npm test && npm run build
  stage: build

# build job: Use react-starter to create the simple react project
build_simple:
  tags:
  - node-6
  script:
  - yarn install
  - npm link
  - which react-starter
  - react-starter --version
  - react-starter -n test -s
  - cd test && yarn && npm run lint && npm test && npm run build
  stage: build
