client:setup:
  image: node
  stage: setup
  only:
    refs:
      - dev
      - merge_requests
  script:
    - cd client
    - npm install
  artifacts:
    name: 'artifacts'
    untracked: true
    expire_in: 15 mins
    paths:
      - client/.npm/
      - client/node_modules/
  cache:
    key: '$CI_COMMIT_REF_SLUG'
    paths:
      - client/.npm/
      - client/node_modules/

client:linting:
  image: node:10
  stage: test
  needs: ['client:setup']
  allow_failure: true
  only:
    refs:
      - dev
      - merge_requests
    changes:
      - client/**/*
  script:
    - cd client
    - npm run lint

client:test:
  image: node:10
  stage: test
  needs: ['client:setup']
  only:
    refs:
      - dev
      - merge_requests
  script:
    - cd client
    - npm run test:coverage
  coverage: /All files\s*\|\s*([\d\.]+)/
  artifacts:
    paths:
      - client/output/coverage/jest/cobertura-coverage.xml
    expire_in: 5 min

client:report:
  image: python
  stage: report
  needs: ['client:test']
  only:
    refs:
      - merge_requests
    changes:
      - client/**/*
  script:
    - cd client
    - python coverage_report.py
  artifacts:
    reports:
      cobertura: client/output/coverage/jest/cobertura-coverage.xml
    expire_in: 1 week