From 84546bce16884067f505c98142820ef3169d615d Mon Sep 17 00:00:00 2001 From: Antoine Vigneau Date: Tue, 30 Jan 2024 10:56:18 +0100 Subject: [PATCH] [PATCH] BUILD-3755 Don't trigger a public build for the LTS branch --- .cirrus.star | 10 +++- .travis.yml | 44 -------------- .travis/run_iris.sh | 29 --------- .travis/setup_environment.sh | 21 ------- .travis/setup_ramdisk.sh | 22 ------- .cirrus.yml => private/.cirrus.yml | 0 travis.sh | 95 ------------------------------ 7 files changed, 9 insertions(+), 212 deletions(-) delete mode 100644 .travis.yml delete mode 100755 .travis/run_iris.sh delete mode 100755 .travis/setup_environment.sh delete mode 100755 .travis/setup_ramdisk.sh rename .cirrus.yml => private/.cirrus.yml (100%) delete mode 100755 travis.sh diff --git a/.cirrus.star b/.cirrus.star index 28b17b70fc3..501a4bfc50c 100644 --- a/.cirrus.star +++ b/.cirrus.star @@ -1,4 +1,12 @@ 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") + return features + doc + + # On SonarSource/sonarqube repo, we don't trigger any Cirrus build + return [] diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a94642be156..00000000000 --- a/.travis.yml +++ /dev/null @@ -1,44 +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 16 - - nvm use 16 - -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 - -# This is a temporary change as Travis is currently executing this body even -# when the job run successfully (support ticket #44617). -# The changes should be reverted once we have a proper solution. -after_failure: - - '[[ $TRAVIS_TEST_RESULT = 1 ]] && source ./.travis/setup_environment.sh && notify_burgr "build" "build" "$TRAVIS_JOB_WEB_URL" "$(cat /tmp/build_start_time)" "$(date --utc +%FT%TZ)" "failed" || true' diff --git a/.travis/run_iris.sh b/.travis/run_iris.sh deleted file mode 100755 index d08dec56483..00000000000 --- a/.travis/run_iris.sh +++ /dev/null @@ -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 diff --git a/.travis/setup_environment.sh b/.travis/setup_environment.sh deleted file mode 100755 index 2f11f417551..00000000000 --- a/.travis/setup_environment.sh +++ /dev/null @@ -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} =======" diff --git a/.travis/setup_ramdisk.sh b/.travis/setup_ramdisk.sh deleted file mode 100755 index 75e2492d9cd..00000000000 --- a/.travis/setup_ramdisk.sh +++ /dev/null @@ -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 - diff --git a/.cirrus.yml b/private/.cirrus.yml similarity index 100% rename from .cirrus.yml rename to private/.cirrus.yml diff --git a/travis.sh b/travis.sh deleted file mode 100755 index a0fff3b6b5c..00000000000 --- a/travis.sh +++ /dev/null @@ -1,95 +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 --console plain - -# exclude external pull requests -if [[ -n "${NEXT_TOKEN-}" ]]; then - sonar_params=(-Dsonar.projectKey=sonarqube - -Dsonar.host.url="$SONAR_HOST_URL" - -Dsonar.login="$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 :server:sonar-web:yarn_validate-ci sonarqube --info --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" \ - -Dsonar.pullrequest.provider=github \ - -Dsonar.pullrequest.github.repository="$TRAVIS_REPO_SLUG" - elif [ "${TRAVIS_BRANCH}" == "master" ]; then - echo '======= Analyze master' - ./gradlew jacocoTestReport :server:sonar-web:yarn_validate-ci sonarqube --info --console plain \ - "${sonar_params[@]}" \ - -Dsonar.projectVersion="$INITIAL_VERSION" - else - echo '======= Analyze branch' - ./gradlew jacocoTestReport :server:sonar-web:yarn_validate-ci sonarqube --info --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 -- 2.39.5