@@ -1,4 +1,22 @@ | |||
load("github.com/SonarSource/cirrus-modules@v2", "load_features") | |||
load("cirrus", "env", "fs", "yaml") | |||
def main(ctx): | |||
return load_features(ctx) | |||
if env.get("CIRRUS_REPO_FULL_NAME") == 'SonarSource/sonar-enterprise': | |||
features = yaml.dumps(load_features(ctx, only_if=dict())) | |||
doc = fs.read("private/.cirrus.yml") | |||
else: | |||
if env.get("CIRRUS_USER_PERMISSION") in ["write", "admin"]: | |||
features = yaml.dumps(load_features(ctx, features=["build_number"])) | |||
else: | |||
# workaround for BUILD-4413 (build number on public CI) | |||
features = yaml.dumps( | |||
{ | |||
'env': { | |||
'CI_BUILD_NUMBER': env.get("CIRRUS_PR", "1") | |||
}, | |||
} | |||
) | |||
doc = fs.read(".cirrus/.cirrus.yml") | |||
return features + doc |
@@ -0,0 +1,183 @@ | |||
only_if: $CIRRUS_TAG == "" && ($CIRRUS_PR != "" || $CIRRUS_BRANCH == $CIRRUS_DEFAULT_BRANCH || $CIRRUS_BRANCH =~ "branch-.*" || $CIRRUS_BUILD_SOURCE == 'api' ) | |||
skip: $CIRRUS_BRANCH == "public_master" || $CIRRUS_BRANCH =~ "dogfood/.*" | |||
env: | |||
CIRRUS_SHELL: bash | |||
CIRRUS_CLONE_DEPTH: 0 | |||
GRADLE_USER_HOME: ${CIRRUS_WORKING_DIR}/.gradle | |||
FETCH_DEPTH: --depth=1 | |||
default_artifact_template: &DEFAULT_ARTIFACTS_TEMPLATE | |||
on_failure: | |||
jest_junit_cleanup_script: > | |||
find . -type f -wholename "**/build/test-results/test-jest/junit.xml" -exec | |||
xmlstarlet edit --inplace --delete '//testsuite[@errors=0 and @failures=0]' {} \; | |||
junit_artifacts: | |||
path: "**/build/test-results/**/*.xml" | |||
type: "text/xml" | |||
format: junit | |||
reports_artifacts: | |||
path: "**/build/reports/**/*" | |||
screenshots_artifacts: | |||
path: "**/build/screenshots/**/*" | |||
log_artifacts: | |||
path: "**/build/**/*.log" | |||
default_template: &DEFAULT_TEMPLATE | |||
clone_script: | | |||
git init | |||
git remote add origin https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git | |||
git fetch origin $CIRRUS_CHANGE_IN_REPO $FETCH_DEPTH | |||
git reset --hard $CIRRUS_CHANGE_IN_REPO | |||
gradle_cache_template: &GRADLE_CACHE_TEMPLATE | |||
gradle_cache: | |||
folder: ${GRADLE_USER_HOME}/caches | |||
fingerprint_script: find -type f \( -name "*.gradle*" -or -name "gradle*.properties" \) | sort | xargs cat | |||
populate_script: mkdir -p ${GRADLE_USER_HOME}/caches | |||
cleanup_gradle_cache_script_template: &CLEANUP_GRADLE_CACHE_SCRIPT | |||
cleanup_gradle_script: | | |||
rm -rf "${GRADLE_USER_HOME}"/caches/7.*/ | |||
rm -rf "${GRADLE_USER_HOME}"/daemon/ | |||
rm -rf "${GRADLE_USER_HOME}"/caches/transforms-* | |||
rm -rf "${GRADLE_USER_HOME}"/caches/journal-* | |||
/usr/bin/find "${GRADLE_USER_HOME}"/caches/ -name "*.lock" -type f -delete | |||
yarn_cache_template: &YARN_CACHE_TEMPLATE | |||
yarn_cache: | |||
folder: "~/.yarn/berry/cache" | |||
fingerprint_script: cat server/sonar-web/yarn.lock | |||
jar_cache_template: &JAR_CACHE_TEMPLATE | |||
jar_cache: | |||
folder: "**/build/libs/*.jar" | |||
fingerprint_key: jar-cache_$CIRRUS_BUILD_ID | |||
eslint_report_cache_template: &ESLINT_REPORT_CACHE_TEMPLATE | |||
eslint_report_cache: | |||
folders: | |||
- server/sonar-web/eslint-report/ | |||
- server/sonar-web/design-system/eslint-report/ | |||
fingerprint_script: echo $CIRRUS_BUILD_ID | |||
jest_report_cache_template: &JEST_REPORT_CACHE_TEMPLATE | |||
jest_report_cache: | |||
folders: | |||
- server/sonar-web/coverage/ | |||
- server/sonar-web/design-system/coverage/ | |||
fingerprint_script: echo $CIRRUS_BUILD_ID | |||
junit_report_cache_template: &JUNIT_REPORT_CACHE_TEMPLATE | |||
junit_report_cache: | |||
folders: | |||
- "**/reports/jacoco" | |||
- "**/test-results/test" | |||
fingerprint_script: echo $CIRRUS_BUILD_ID | |||
cache_dependencies_task: | |||
container: | |||
dockerfile: .cirrus/Dockerfile | |||
cpu: 2 | |||
memory: 4Gb | |||
<<: *DEFAULT_TEMPLATE | |||
<<: *GRADLE_CACHE_TEMPLATE | |||
script: | |||
- .cirrus/cirrus-cache-dependencies.sh | |||
<<: *CLEANUP_GRADLE_CACHE_SCRIPT | |||
<<: *DEFAULT_ARTIFACTS_TEMPLATE | |||
build_task: | |||
depends_on: cache_dependencies | |||
container: | |||
dockerfile: .cirrus/Dockerfile | |||
cpu: 8 | |||
memory: 8Gb | |||
<<: *DEFAULT_TEMPLATE | |||
<<: *GRADLE_CACHE_TEMPLATE | |||
<<: *YARN_CACHE_TEMPLATE | |||
<<: *JAR_CACHE_TEMPLATE | |||
build_script: .cirrus/cirrus-build.sh | |||
<<: *CLEANUP_GRADLE_CACHE_SCRIPT | |||
<<: *DEFAULT_ARTIFACTS_TEMPLATE | |||
yarn_lint_task: | |||
depends_on: cache_dependencies | |||
container: | |||
dockerfile: .cirrus/Dockerfile | |||
cpu: 3 | |||
memory: 4Gb | |||
<<: *DEFAULT_TEMPLATE | |||
<<: *GRADLE_CACHE_TEMPLATE | |||
<<: *YARN_CACHE_TEMPLATE | |||
<<: *ESLINT_REPORT_CACHE_TEMPLATE | |||
script: | |||
- .cirrus/cirrus-yarn-lint-report.sh | |||
<<: *CLEANUP_GRADLE_CACHE_SCRIPT | |||
<<: *DEFAULT_ARTIFACTS_TEMPLATE | |||
yarn_check_task: | |||
depends_on: cache_dependencies | |||
container: | |||
dockerfile: .cirrus/Dockerfile | |||
cpu: 3 | |||
memory: 4Gb | |||
<<: *DEFAULT_TEMPLATE | |||
<<: *GRADLE_CACHE_TEMPLATE | |||
<<: *YARN_CACHE_TEMPLATE | |||
script: | | |||
source .cirrus/cirrus-env | |||
./gradlew yarn_check-ci | |||
<<: *CLEANUP_GRADLE_CACHE_SCRIPT | |||
<<: *DEFAULT_ARTIFACTS_TEMPLATE | |||
yarn_validate_task: | |||
depends_on: cache_dependencies | |||
container: | |||
dockerfile: .cirrus/Dockerfile | |||
cpu: 8 | |||
memory: 15Gb | |||
<<: *DEFAULT_TEMPLATE | |||
<<: *GRADLE_CACHE_TEMPLATE | |||
<<: *YARN_CACHE_TEMPLATE | |||
<<: *JEST_REPORT_CACHE_TEMPLATE | |||
script: | |||
- .cirrus/cirrus-yarn-validate-ci.sh | |||
<<: *CLEANUP_GRADLE_CACHE_SCRIPT | |||
<<: *DEFAULT_ARTIFACTS_TEMPLATE | |||
junit_task: | |||
depends_on: cache_dependencies | |||
container: | |||
dockerfile: .cirrus/Dockerfile | |||
cpu: 8 | |||
memory: 10Gb | |||
<<: *DEFAULT_TEMPLATE | |||
<<: *GRADLE_CACHE_TEMPLATE | |||
<<: *JUNIT_REPORT_CACHE_TEMPLATE | |||
script: | |||
- .cirrus/cirrus-junit.sh | |||
<<: *CLEANUP_GRADLE_CACHE_SCRIPT | |||
<<: *DEFAULT_ARTIFACTS_TEMPLATE | |||
sq_analysis_task: | |||
depends_on: | |||
- yarn_lint | |||
- yarn_validate | |||
- junit | |||
container: | |||
dockerfile: .cirrus/Dockerfile | |||
cpu: 7.5 | |||
memory: 15Gb | |||
env: | |||
SONAR_HOST_URL: https://next.sonarqube.com/sonarqube | |||
SONAR_TOKEN: ENCRYPTED[!b6fd814826c51e64ee61b0b6f3ae621551f6413383f7170f73580e2e141ac78c4b134b506f6288c74faa0dd564c05a29!] | |||
<<: *GRADLE_CACHE_TEMPLATE | |||
<<: *YARN_CACHE_TEMPLATE | |||
<<: *JEST_REPORT_CACHE_TEMPLATE | |||
<<: *ESLINT_REPORT_CACHE_TEMPLATE | |||
<<: *JUNIT_REPORT_CACHE_TEMPLATE | |||
script: | |||
- .cirrus/cirrus-sq-analysis.sh | |||
<<: *CLEANUP_GRADLE_CACHE_SCRIPT | |||
<<: *DEFAULT_ARTIFACTS_TEMPLATE |
@@ -0,0 +1,51 @@ | |||
ARG JDK_VERSION=17 | |||
FROM eclipse-temurin:${JDK_VERSION}-jdk-jammy | |||
ENV DEBIAN_FRONTEND=noninteractive | |||
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | |||
RUN set -o errexit -o nounset \ | |||
&& groupadd --system --gid 1000 sonarsource \ | |||
&& useradd --system --gid sonarsource --uid 1000 --shell /bin/bash --create-home sonarsource | |||
RUN echo 'Acquire::AllowReleaseInfoChange::Suite "true";' > /etc/apt/apt.conf.d/allow_release_info_change.conf | |||
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=863199#23 | |||
RUN mkdir -p /usr/share/man/man1 \ | |||
&& apt-get update \ | |||
&& apt-get -y install --no-install-recommends \ | |||
lsb-release \ | |||
ca-certificates \ | |||
curl \ | |||
wget \ | |||
gnupg \ | |||
&& apt-get clean \ | |||
&& rm -rf /var/lib/apt/lists/* | |||
ARG NODE_MAJOR=18 | |||
RUN DISTRO="$(lsb_release -s -c)" \ | |||
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ | |||
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" >> /etc/apt/sources.list.d/nodesource.list \ | |||
&& curl -sSL https://packages.atlassian.com/api/gpg/key/public | gpg --dearmor -o /etc/apt/keyrings/atlassian.gpg \ | |||
&& echo "deb [signed-by=/etc/apt/keyrings/atlassian.gpg] https://packages.atlassian.com/debian/atlassian-sdk-deb/ stable contrib" >> /etc/apt/sources.list.d/atlassian-sdk.list \ | |||
&& curl -sSL https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor -o /etc/apt/keyrings/adoptium-archive-keyring.gpg \ | |||
&& echo "deb [signed-by=/etc/apt/keyrings/adoptium-archive-keyring.gpg] https://packages.adoptium.net/artifactory/deb $DISTRO main" >> /etc/apt/sources.list.d/adoptopenjdk.list \ | |||
&& apt-get update \ | |||
&& apt-get -y install --no-install-recommends \ | |||
git \ | |||
unzip \ | |||
nodejs="$NODE_MAJOR".* \ | |||
jq \ | |||
expect \ | |||
atlassian-plugin-sdk \ | |||
temurin-8-jdk \ | |||
xmlstarlet \ | |||
&& apt-get clean \ | |||
&& rm -rf /var/lib/apt/lists/* \ | |||
&& npm install -g yarn | |||
# Avoiding JVM Delays Caused by Random Number Generation (https://docs.oracle.com/cd/E13209_01/wlcp/wlss30/configwlss/jvmrand.html) | |||
RUN sed -i 's|securerandom.source=file:/dev/random|securerandom.source=file:/dev/urandom|g' "$JAVA_HOME/conf/security/java.security" | |||
USER sonarsource | |||
WORKDIR /home/sonarsource |
@@ -0,0 +1,20 @@ | |||
#!/bin/bash | |||
set -euo pipefail | |||
source .cirrus/cirrus-env | |||
./gradlew build \ | |||
-DbuildNumber="$BUILD_NUMBER" \ | |||
-x test \ | |||
--parallel --console plain --build-cache | |||
pushToCirrusCiCache() { | |||
cd "${1}" | |||
zipfile=$(ls -- *.zip) | |||
echo "Uploading $zipfile to CirrusCI cache" | |||
curl -s -X POST --data-binary @"$zipfile" "http://$CIRRUS_HTTP_CACHE_HOST/$zipfile" | |||
echo "$zipfile successfully uploaded to CirrusCI cache" | |||
} | |||
export -f pushToCirrusCiCache | |||
pushToCirrusCiCache sonar-application/build/distributions |
@@ -0,0 +1,13 @@ | |||
#!/bin/bash | |||
set -euo pipefail | |||
source .cirrus/cirrus-env | |||
if [ -d "${GRADLE_USER_HOME?}/caches" ]; then | |||
echo "gradle dependency cache already exists, bypassing dependencies loading" | |||
else | |||
./gradlew cacheDependencies \ | |||
--parallel --console plain --build-cache --info | |||
./gradlew cacheDependencies \ | |||
--parallel --console plain --build-cache -Pqa --info | |||
fi |
@@ -0,0 +1,11 @@ | |||
#!/bin/bash | |||
set -uo pipefail | |||
export GIT_SHA1=${CIRRUS_CHANGE_IN_REPO?} | |||
export GITHUB_BASE_BRANCH=${CIRRUS_BASE_BRANCH:-} | |||
export GITHUB_BRANCH=${CIRRUS_BRANCH?} | |||
export GITHUB_REPO=${CIRRUS_REPO_FULL_NAME?} | |||
export BUILD_NUMBER=${CI_BUILD_NUMBER?} | |||
export PULL_REQUEST=${CIRRUS_PR:-false} | |||
export PULL_REQUEST_SHA=${CIRRUS_BASE_SHA:-} | |||
export PIPELINE_ID=${CIRRUS_BUILD_ID?} |
@@ -0,0 +1,7 @@ | |||
#!/bin/bash | |||
set -euo pipefail | |||
source .cirrus/cirrus-env | |||
./gradlew cleanTest test jacocoTestReport \ | |||
--parallel --configure-on-demand --console plain -Pqa |
@@ -0,0 +1,22 @@ | |||
#!/bin/bash | |||
set -euo pipefail | |||
source .cirrus/cirrus-env | |||
: "${SONAR_HOST_URL?}" "${SONAR_TOKEN?}" | |||
git fetch --unshallow || true | |||
if [ -n "${GITHUB_BASE_BRANCH:-}" ]; then | |||
git fetch origin "${GITHUB_BASE_BRANCH}" | |||
fi | |||
./gradlew sonar \ | |||
-DbuildNumber="$BUILD_NUMBER" \ | |||
-Dsonar.projectKey=sonarqube \ | |||
-Dsonar.host.url="$SONAR_HOST_URL" \ | |||
-Dsonar.token="$SONAR_TOKEN" \ | |||
-Dsonar.analysis.buildNumber="$BUILD_NUMBER" \ | |||
-Dsonar.analysis.pipeline="$PIPELINE_ID" \ | |||
-Dsonar.analysis.repository="$GITHUB_REPO" \ | |||
-Dsonar.analysis.sha1="$GIT_SHA1" \ | |||
--parallel --configure-on-demand --console plain -Pqa |
@@ -0,0 +1,7 @@ | |||
#!/bin/bash | |||
set -euo pipefail | |||
source .cirrus/cirrus-env | |||
./gradlew yarn_lint-report-ci \ | |||
--parallel --configure-on-demand --console plain -Pqa |
@@ -0,0 +1,7 @@ | |||
#!/bin/bash | |||
set -euo pipefail | |||
source .cirrus/cirrus-env | |||
./gradlew yarn_validate-ci \ | |||
--parallel --configure-on-demand --console plain -Pqa |
@@ -1,2 +1,3 @@ | |||
* | |||
!docker | |||
!private/docker |
@@ -1,42 +0,0 @@ | |||
sudo: required | |||
install: true | |||
script: ./travis.sh | |||
dist: jammy | |||
jdk: openjdk17 | |||
branches: | |||
except: | |||
- /^dogfood\/.*$/ | |||
- public_master | |||
matrix: | |||
fast_finish: true | |||
cache: | |||
directories: | |||
- $HOME/.sonar | |||
- $HOME/jvm | |||
- $HOME/.gradle/caches/ | |||
- $HOME/.gradle/wrapper/ | |||
before_cache: | |||
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock | |||
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/ | |||
- rm -fr $HOME/.gradle/caches/*/fileHashes/ | |||
- rm -fr $HOME/.gradle/caches/*/scripts/ | |||
before_install: | |||
- nvm install 18 | |||
- nvm use 18 | |||
notifications: | |||
email: false | |||
webhooks: | |||
- secure: "jxB1WXSY7zyW7un8mNtFuasV1ucEA5J3FvrlcOHVlaQaMPYV2/YjJNHdH4R0xzkmxy3D5pch2WZo4+sNB+8F3bQOCLQgYWVo0PrF635+6Bnah3tY7LX958WBuu3LPX9tlH+vRssi9gwj2SsqL0JAW+t1AbvHQsEhIfIudEc2VtxA2gHaKeNnvzbpCIs865k8OXkA7a2udlW0yIjri7VO9KJai2hAiKRIBojmrye8fY7Hin/4rA2yBwMMo8JmxIqLXqJOF0EYRyTnFVCxuRFvnDrgSP9pOLt4GQx37k2YPOzwxohziZ1xABMH2Hxx9tq/ynrqACJI0VlktKzCmNoeeSDknnd2erRvBH/n3i54RSP2GXbaB5XUt4l9i9/D4YqPSihrfnSRHk0ct8rcDGRW8nhCVJtsRX0w1Pde05YMshtHJCJXlmx5f6VJWbhBXjIjCbkN2k7guIGoK7cMsOQ5tPOadqYQ4JsXuD4/m2qH1uYvKQE+pplS9zGSBZFTi9Br3QfB5W1rsj4hLubUOd01kQiOIYAnHDfLVicbq3SSIT+H9YZQ80qxcx/ibDnLfhrX02jmswdfzc/hX7OdUh4l8QNS7LyxVe9y/0p5+9iQ0F62AZD6SBXGsZNtufqBruNX7qwT2vJ2tuDOP+zW0gnvNvLMnENw8JH2K2j4lv04pRw=" | |||
slack: | |||
secure: PCekbN71ZmuOt82JUFmlhzxlx3wrXucSIpvxxWdZn9lfsPYQAtXCoOESaHjIVIpggsC5HSAic3HiedsWbuDk/XojmPrDCrfjgYG2wiuSuQlAa60WvzTPqXdRmUXyMQgItaAQbRfZP7kN9No/v8TZDfg5kT3i9ewy0bsfExpjAuo= | |||
on_start: always | |||
after_failure: | |||
- source ./.travis/setup_environment.sh | |||
- notify_burgr "build" "build" "$TRAVIS_JOB_WEB_URL" "$(cat /tmp/build_start_time)" "$(date --utc +%FT%TZ)" "failed" || true |
@@ -1,29 +0,0 @@ | |||
#!/bin/bash | |||
set +x | |||
VERSION="\[RELEASE\]" | |||
HTTP_CODE=$(\ | |||
curl \ | |||
--write-out '%{http_code}' \ | |||
--location \ | |||
--remote-name \ | |||
--user "$ARTIFACTORY_PRIVATE_USERNAME:$ARTIFACTORY_API_KEY" \ | |||
"$ARTIFACTORY_URL/sonarsource-private-releases/com/sonarsource/iris/iris/$VERSION/iris-$VERSION-jar-with-dependencies.jar"\ | |||
) | |||
if [ "$HTTP_CODE" != "200" ]; then | |||
echo "Download $VERSION failed -> $HTTP_CODE" | |||
exit 1 | |||
else | |||
echo "Downloaded $VERSION" | |||
fi | |||
java \ | |||
-Diris.source.projectKey=org.sonarsource.sonarqube:sonarqube-private \ | |||
-Diris.source.url=https://next.sonarqube.com/sonarqube \ | |||
-Diris.source.token=$NEXT_TOKEN \ | |||
-Diris.destination.projectKey=sonarqube \ | |||
-Diris.destination.url=https://next.sonarqube.com/sonarqube \ | |||
-Diris.destination.token=$NEXT_TOKEN \ | |||
-Diris.maxcountposts=50 \ | |||
-jar iris-\[RELEASE\]-jar-with-dependencies.jar |
@@ -1,21 +0,0 @@ | |||
#!/bin/bash | |||
# Sets up the environment to be able to send notifications to burgr | |||
# use generic environments to remove coupling with Travis ; see setup_promote_environment | |||
export GITHUB_REPO=${TRAVIS_REPO_SLUG} | |||
export BUILD_NUMBER=$TRAVIS_BUILD_NUMBER | |||
export PIPELINE_ID=${BUILD_NUMBER} | |||
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then | |||
export GIT_SHA1=${TRAVIS_COMMIT} # $CIRRUS_CHANGE_IN_REPO | |||
export GIT_BRANCH=$TRAVIS_BRANCH | |||
export STAGE_TYPE="branch" | |||
export STAGE_ID=${GIT_BRANCH} | |||
else | |||
export GIT_SHA1=${TRAVIS_PULL_REQUEST_SHA} | |||
export GIT_BRANCH=$TRAVIS_PULL_REQUEST_BRANCH | |||
export PULL_REQUEST_BASE_BRANCH=$TRAVIS_BRANCH | |||
export PULL_REQUEST_NUMBER=$TRAVIS_PULL_REQUEST | |||
export STAGE_TYPE="pr_number" | |||
export STAGE_ID=${PULL_REQUEST_NUMBER} | |||
fi | |||
echo "======= SHA1 is ${GIT_SHA1} on branch '${GIT_BRANCH}'. Burgr stage '${STAGE_TYPE} with stage ID '${STAGE_ID} =======" |
@@ -1,22 +0,0 @@ | |||
#!/bin/bash | |||
set -euo pipefail | |||
RED='\033[0;31m' | |||
NC='\033[0m' # No Color | |||
printf "${RED}SETUP RAMDISK${NC}\n" | |||
printf "${RED}disk size before build${NC}\n" | |||
df -h | |||
du -sh $HOME | |||
du -sh $TRAVIS_BUILD_DIR | |||
printf "${RED}move original TRAVIS_BUILD_DIR${NC}\n" | |||
sudo mv $TRAVIS_BUILD_DIR $TRAVIS_BUILD_DIR.ori | |||
printf "${RED}create ramdisk mount point${NC}\n" | |||
sudo mkdir -p $TRAVIS_BUILD_DIR | |||
printf "${RED}create ramdisk${NC}\n" | |||
sudo mount -t tmpfs -o size=8192m tmps $TRAVIS_BUILD_DIR | |||
printf "${RED}copy TRAVIS_BUILD_DIR to ramdisk${NC}\n" | |||
time sudo cp -R $TRAVIS_BUILD_DIR.ori/. $TRAVIS_BUILD_DIR | |||
printf "${RED}give permissions to travis on its TRAVIS_BUILD_DIR in ramdisk${NC}\n" | |||
sudo chown -R travis:travis $TRAVIS_BUILD_DIR | |||
@@ -1,4 +1,4 @@ | |||
# SonarQube [![Build Status](https://app.travis-ci.com/SonarSource/sonarqube.svg?branch=master)](https://app.travis-ci.com/SonarSource/sonarqube) [![Quality Gate Status](https://next.sonarqube.com/sonarqube/api/project_badges/measure?project=sonarqube&metric=alert_status&token=d95182127dd5583f57578d769b511660601a8547)](https://next.sonarqube.com/sonarqube/dashboard?id=sonarqube) | |||
# SonarQube [![Build Status](https://api.cirrus-ci.com/github/SonarSource/sonarqube.svg?branch=master)](https://cirrus-ci.com/github/SonarSource/sonarqube) [![Quality Gate Status](https://next.sonarqube.com/sonarqube/api/project_badges/measure?project=sonarqube&metric=alert_status&token=d95182127dd5583f57578d769b511660601a8547)](https://next.sonarqube.com/sonarqube/dashboard?id=sonarqube) | |||
## Continuous Inspection | |||
@@ -1,93 +0,0 @@ | |||
#!/usr/bin/env bash | |||
set -euo pipefail | |||
./.travis/setup_ramdisk.sh | |||
# | |||
# Configure Maven settings and install some script utilities | |||
# | |||
configureTravis() { | |||
mkdir -p ~/.local | |||
curl -sSL https://github.com/SonarSource/travis-utils/tarball/v62 | tar zx --strip-components 1 -C ~/.local | |||
# shellcheck disable=SC1090 | |||
source ~/.local/bin/install | |||
} | |||
configureTravis | |||
# | |||
# Travis fails on timeout when build does not print logs | |||
# during 10 minutes. This aims to bypass this | |||
# behavior when building the slow sonar-server sub-project. | |||
# | |||
keep_alive() { | |||
while true; do | |||
echo -en "\a" | |||
sleep 60 | |||
done | |||
} | |||
keep_alive & | |||
# When a pull request is open on the branch, then the job related | |||
# to the branch does not need to be executed and should be canceled. | |||
# It does not book slaves for nothing. | |||
# @TravisCI please provide the feature natively, like at AppVeyor or CircleCI ;-) | |||
cancel_branch_build_with_pr || if [[ $? -eq 1 ]]; then exit 0; fi | |||
# Used by Next | |||
INITIAL_VERSION=$(grep version gradle.properties | awk -F= '{print $2}') | |||
export INITIAL_VERSION | |||
source ./.travis/setup_environment.sh | |||
# Analyse SonarQube on NEXT | |||
export SONAR_HOST_URL=https://next.sonarqube.com/sonarqube | |||
# Fetch all commit history so that SonarQube has exact blame information | |||
# for issue auto-assignment | |||
# This command can fail with "fatal: --unshallow on a complete repository does not make sense" | |||
# if there are not enough commits in the Git repository (even if Travis executed git clone --depth 50). | |||
# For this reason errors are ignored with "|| true" | |||
git fetch --unshallow || true | |||
BUILD_START_DATETIME=$(date --utc +%FT%TZ) | |||
echo "$BUILD_START_DATETIME" > /tmp/build_start_time | |||
./gradlew build --warn --console plain | |||
# exclude external pull requests | |||
if [[ -n "${NEXT_TOKEN-}" ]]; then | |||
sonar_params=(-Dsonar.projectKey=sonarqube | |||
-Dsonar.host.url="$SONAR_HOST_URL" | |||
-Dsonar.token="$NEXT_TOKEN" | |||
-Dsonar.analysis.buildNumber="$BUILD_NUMBER" | |||
-Dsonar.analysis.pipeline="$BUILD_NUMBER" | |||
-Dsonar.analysis.sha1="$GIT_SHA1" | |||
-Dsonar.analysis.repository="$TRAVIS_REPO_SLUG") | |||
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then | |||
echo '======= Analyze pull request' | |||
./gradlew jacocoTestReport yarn_validate-ci sonarqube --warn --console plain \ | |||
"${sonar_params[@]}" \ | |||
-Dsonar.analysis.prNumber="$PULL_REQUEST_NUMBER" \ | |||
-Dsonar.pullrequest.branch="$GIT_BRANCH" \ | |||
-Dsonar.pullrequest.base="$PULL_REQUEST_BASE_BRANCH" \ | |||
-Dsonar.pullrequest.key="$PULL_REQUEST_NUMBER" | |||
elif [ "${TRAVIS_BRANCH}" == "master" ]; then | |||
echo '======= Analyze master' | |||
./gradlew jacocoTestReport yarn_validate-ci sonarqube --warn --console plain \ | |||
"${sonar_params[@]}" \ | |||
-Dsonar.projectVersion="$INITIAL_VERSION" | |||
else | |||
echo '======= Analyze branch' | |||
./gradlew jacocoTestReport yarn_validate-ci sonarqube --warn --console plain \ | |||
"${sonar_params[@]}" \ | |||
-Dsonar.branch.name="$GIT_BRANCH" \ | |||
-Dsonar.projectVersion="$INITIAL_VERSION" | |||
fi | |||
# Wait for 5mins, hopefully the report will be processed. | |||
sleep 5m | |||
./.travis/run_iris.sh | |||
BUILD_END_DATETIME=$(date --utc +%FT%TZ) | |||
notify_burgr "build" "build" "$TRAVIS_JOB_WEB_URL" "$BUILD_START_DATETIME" "$BUILD_END_DATETIME" || true | |||
fi |