Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLINTJS-36 Split out tests and analyze into separate steps #465

Merged
merged 9 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace: default
use_in_memory_disk: true

build_task:
build_body: &BUILD_BODY
<<: *ONLY_SONARSOURCE_QA
eks_container:
<<: *CONTAINER_DEFINITION
Expand All @@ -43,10 +43,25 @@
- 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:
- build
eks_container:
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