+.only-default: &only-default
+ only:
+ - branches
+ - merge_requests
+ - tags
+ - refs
+
image: node:14
+variables:
+ SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
+
stages:
- lint
- test
+ - quality
before_script:
- npm install
+cache:
+ key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
+ paths:
+ - node_modules/
+ - .nyc_output/
+
lint:
+ <<: *only-default
stage: lint
script:
- npm run lint
test:
+ <<: *only-default
stage: test
script:
- npm test
+
+quality:
+ stage: quality
+ needs:
+ -test
+ image:
+ name: sonarsource/sonar-scanner-cli:latest
+ entrypoint: [""]
+ cache:
+ key: "${CI_JOB_NAME}"
+ paths:
+ - .sonar/cache
+ script:
+ - npm run coverage
+ - sonar-scanner
+ only:
+ - merge_requests
+ - master