coverage-report:
  stage: .post
  image: node:${NODE_VERSION}
  coverage: '/^Statements\s*:\s*([\d\.]+)%/'
  script:
    - bash tools/scripts/merge-coverage-reports.bash
    - npx nyc report --reporter text-summary | perl -pe 's/\e\[?.*?[\@-~]//g'
  allow_failure: true
  artifacts:
    expire_in: 1 week
    paths:
      - coverage
    reports:
      coverage_report:
        coverage_format: cobertura
        path: coverage/cobertura-coverage.xml
  rules:
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
      when: on_success
    - if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+/'
      when: on_success
    - if: '$CI_COMMIT_BRANCH =~ /^([0-9]+\.[0-9]+\.x|[0-9]+\.x)$/'
      when: on_success
    - when: manual
      allow_failure: true
