From 7ef1a012bc3596912ea49b11110ea5599122b87c Mon Sep 17 00:00:00 2001 From: zglicz Date: Tue, 30 Apr 2024 12:11:11 +0200 Subject: [PATCH] ESLINTJS-36 Split out tests and analyze into separate steps (#465) --- .cirrus.yml | 19 +++++++++++++++++-- .cirrus/nodejs.Dockerfile | 1 - .../{analyze_and_publish.sh => publish.sh} | 11 ----------- scripts/test-ci.sh | 18 ++++++++---------- sonar-project.properties | 2 +- 5 files changed, 26 insertions(+), 25 deletions(-) rename scripts/{analyze_and_publish.sh => publish.sh} (71%) diff --git a/.cirrus.yml b/.cirrus.yml index e66b3886..bf74c09d 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -24,7 +24,7 @@ container_definition: &CONTAINER_DEFINITION namespace: default use_in_memory_disk: true -build_task: +build_body: &BUILD_BODY <<: *ONLY_SONARSOURCE_QA eks_container: <<: *CONTAINER_DEFINITION @@ -43,8 +43,23 @@ build_task: - jfrog rt npm-ci - npm run check-format - npm run build + +build_task: + <<: *BUILD_BODY + +test_and_analyze_task: + depends_on: + - build + <<: *BUILD_BODY + test_script: - ./scripts/test-ci.sh - - ./scripts/analyze_and_publish.sh + +publish_task: + depends_on: + - build + <<: *BUILD_BODY + publish_script: + - ./scripts/publish.sh qa_task: depends_on: diff --git a/.cirrus/nodejs.Dockerfile b/.cirrus/nodejs.Dockerfile index 2baf4579..583473d3 100644 --- a/.cirrus/nodejs.Dockerfile +++ b/.cirrus/nodejs.Dockerfile @@ -17,4 +17,3 @@ RUN curl "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar- USER sonarsource ENV PATH "/opt/sonar-scanner/bin:${PATH}" -ENV SONARCLOUD_ANALYSIS true diff --git a/scripts/analyze_and_publish.sh b/scripts/publish.sh similarity index 71% rename from scripts/analyze_and_publish.sh rename to scripts/publish.sh index 1db7902d..859e47a9 100755 --- a/scripts/analyze_and_publish.sh +++ b/scripts/publish.sh @@ -1,22 +1,11 @@ #!/bin/bash -# analyze only on one axis of node versions, variable is set in dockerfile -if [ ! "${SONARCLOUD_ANALYSIS:-}" == "true" ]; then - echo 'Analysis and publish ignored' - exit 0 -fi - set -euo pipefail export VERSION=$(grep version package.json | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g') source cirrus-env BUILD npm version --no-git-tag-version --allow-same-version $VERSION-$BUILD_NUMBER -sonar-scanner \ - -Dsonar.organization=sonarsource \ - -Dsonar.host.url=https://sonarcloud.io \ - -DbuildNumber=$BUILD_NUMBER - #upload to repox QA repository jfrog rt npm-publish --build-name=eslint-plugin-sonarjs --build-number=$BUILD_NUMBER #publish buildinfo diff --git a/scripts/test-ci.sh b/scripts/test-ci.sh index 2000843e..0acddf47 100755 --- a/scripts/test-ci.sh +++ b/scripts/test-ci.sh @@ -2,13 +2,11 @@ set -euo pipefail -# run tests with coverage and reports only for nodejs 12 -# this is required for sonarcloud analysis -# variable is set in dockerfile -if [ "${SONARCLOUD_ANALYSIS:-}" == "true" ]; then - echo 'Running tests with coverage and reporter' - npm run test -- --runInBand --coverage --testResultsProcessor jest-sonar-reporter -else - echo 'Running tests' - npm run test -fi +source cirrus-env BUILD + +echo 'Running tests with coverage and reporter' +npm run test -- --runInBand --coverage --testResultsProcessor jest-sonar-reporter +sonar-scanner \ + -Dsonar.organization=sonarsource \ + -Dsonar.host.url=https://sonarcloud.io \ + -DbuildNumber=$BUILD_NUMBER diff --git a/sonar-project.properties b/sonar-project.properties index dff3d364..6753e066 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -2,7 +2,7 @@ sonar.projectKey=eslint-plugin-sonarjs sonar.projectName=eslint-plugin-sonarjs sonar.projectDescription=SonarJS rules for ESLint -sonar.projectVersion=0.25.0 +sonar.projectVersion=0.26.0 sonar.links.homepage=https://github.com/SonarSource/eslint-plugin-sonarjs sonar.links.ci=https://travis-ci.org/SonarSource/eslint-plugin-sonarjs