Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
ESLINTJS-36 Split out tests and analyze into separate steps (#465)
Browse files Browse the repository at this point in the history
  • Loading branch information
zglicz authored Apr 30, 2024
1 parent a4390e9 commit 7ef1a01
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
19 changes: 17 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:

Check warning on line 64 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L64

task "qa" depends on task "build", but their only_if conditions are different

Check warning on line 64 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L64

task "qa" depends on task "build", but their only_if conditions are different

Check warning on line 64 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L64

task "qa" depends on task "build", but their only_if conditions are different

Check warning on line 64 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L64

task "qa" depends on task "build", but their only_if conditions are different

Check warning on line 64 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L64

task "qa" depends on task "build", but their only_if conditions are different

Check warning on line 64 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L64

task "qa" depends on task "build", but their only_if conditions are different
depends_on:
Expand Down
1 change: 0 additions & 1 deletion .cirrus/nodejs.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 0 additions & 11 deletions scripts/analyze_and_publish.sh → scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 8 additions & 10 deletions scripts/test-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7ef1a01

Please sign in to comment.