Skip to content

Commit

Permalink
Merge pull request #81 from OpenLMIS/feature/CQI-9
Browse files Browse the repository at this point in the history
CQI-9: use sonarcloud instead of sonarqube
  • Loading branch information
dszafranek authored Nov 16, 2023
2 parents c79badc + f215b06 commit b9648d6
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 101 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/sonar-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: SonarCloud OpenLMIS-referencedata Pipeline
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: SonarCloud Analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu'
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build with Docker Compose
continue-on-error: true
run: |
curl -o .env -L https://raw.githubusercontent.com/OpenLMIS/openlmis-ref-distro/master/settings-sample.env
docker-compose -f docker-compose.builder.yml run builder
sudo chown -R $(whoami) ./
cp ./build/reports/jacoco/test/jacocoTestReport.xml report.xml
rm -rf ./build
- name: Analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sudo chown -R $(whoami) ./
./gradlew sonarqube --info
53 changes: 0 additions & 53 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -149,59 +149,6 @@ pipeline {
}
}
}
stage('Parallel: Sonar analysis and contract tests') {
when {
expression {
return VERSION.endsWith("SNAPSHOT")
}
}
parallel {
stage('Sonar analysis') {
agent any
environment {
PATH = "/usr/local/bin/:$PATH"
}
steps {
withSonarQubeEnv('Sonar OpenLMIS') {
withCredentials([string(credentialsId: 'SONAR_LOGIN', variable: 'SONAR_LOGIN'), string(credentialsId: 'SONAR_PASSWORD', variable: 'SONAR_PASSWORD')]) {
script {
sh(script: "./ci-sonarAnalysis.sh")

// workaround: Sonar plugin retrieves the path directly from the output
sh 'echo "Working dir: ${WORKSPACE}/build/sonar"'
}
}
}
timeout(time: 1, unit: 'HOURS') {
script {
def gate = waitForQualityGate()
if (gate.status != 'OK') {
echo 'Quality Gate FAILED'
currentBuild.result = 'UNSTABLE'
}
}
}
}
post {
unstable {
script {
notifyAfterFailure()
}
}
failure {
script {
notifyAfterFailure()
}
}
cleanup {
script {
sh "sudo rm -rf ${WORKSPACE}/{*,.*} || true"
}
}
}
}
}
}
stage('ERD generation') {
agent {
node {
Expand Down
34 changes: 11 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
plugins {
id 'org.springframework.boot' version '2.2.2.RELEASE'
id "org.flywaydb.flyway" version "6.0.8"
id "org.sonarqube" version "2.6.2"
id "org.sonarqube" version "3.3"
id "com.moowork.node" version "1.2.0"
id 'com.avast.gradle.docker-compose' version '0.8.10'
id "com.github.ben-manes.versions" version "0.20.0"
Expand Down Expand Up @@ -84,7 +84,7 @@ dependencies {
compile 'ca.uhn.hapi.fhir:hapi-fhir-client:3.7.0'
compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-r4:3.7.0'

annotationProcessor 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.22'

implementation 'org.togglz:togglz-spring-boot-starter:2.6.1.Final'
compile 'org.togglz:togglz-console:2.6.1.Final'
Expand All @@ -109,7 +109,7 @@ dependencies {
testCompile "com.github.tomakehurst:wiremock:2.22.0"
testCompile "com.github.stefanbirkner:system-rules:1.19.0"

testAnnotationProcessor 'org.projectlombok:lombok:1.18.10'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'

runtime fileTree(dir: '/extensions/', include: '*.jar')
}
Expand Down Expand Up @@ -296,28 +296,16 @@ checkstyle {
toolVersion = "8.12"
}

//Usage: gradle sonarqube
//NOTE: This plugin requires that this task be named 'sonarqube'. In fact, it is performing SonarCloud analysis.
sonarqube {
properties {
def branch = System.getenv("SONAR_BRANCH")
if (branch && branch != 'master') {
property "sonar.branch", branch
}
property "sonar.projectName", "OpenLMIS Reference Data Service"
property "sonar.projectKey", "org.sonarqube:openlmis-referencedata"
property "sonar.projectVersion", version
property "sonar.host.url", "http://sonar.openlmis.org"
property "sonar.login", System.getenv("SONAR_LOGIN")
property "sonar.password", System.getenv("SONAR_PASSWORD")
property "sonar.java.coveragePlugin", "jacoco"
//Tells SonarQube where the unit tests execution reports are
property "sonar.junit.reportsPath", "build/test-results/test"
//Tells SonarQube where the code coverage reports are
property "sonar.jacoco.reportPaths", "build/jacoco/test.exec,build/jacoco/integrationTest.exec"
properties["sonar.tests"] += sourceSets.integrationTest.java
}
properties {
property "sonar.projectKey", "OpenLMIS_openlmis-referencedata"
property "sonar.organization", "openlmis"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.java.source", "17"
property "sonar.coverage.jacoco.xmlReportPaths", "./report.xml"
}
}
project.tasks['sonarqube'].dependsOn integrationTest

pmd {
toolVersion = '5.4.0'
Expand Down
25 changes: 0 additions & 25 deletions ci-sonarAnalysis.sh

This file was deleted.

0 comments on commit b9648d6

Please sign in to comment.