image: node:latest

cache:
  paths:
    - node_modules/
    - docs/

stages:
  - test
  - publish

test:
  stage: test
  before_script:
    - npm install -g jest
    - npm install
  script:
    - jest
  artifacts:
    paths:
      - docs/test-report.html
      - docs/coverage/lcov.info

audit:
  stage: test
  script:
    - npm audit --audit-level=high

publish:
  only:
    refs:
      - tags
  stage: publish
  script:
    - npm install --production
    - npm publish
