diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 09974b0c5e..7092ed13d4 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -1,24 +1,67 @@ name: Sonar -on: workflow_dispatch +on: + workflow_dispatch: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] jobs: - sonar: + sonar-java: + name: SonarCloud Java runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - - name: Set up JDK + with: + fetch-depth: 0 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: java-version: '17' - distribution: 'temurin' - cache: 'gradle' + distribution: 'adopt' + - name: Scan via gradle + run: >- + ./gradlew + --build-cache + -x test + -x spotlessJava + -x spotlessJavaApply + -x spotlessJavaCheck + -x spotlessCheck + -x spotlessApply + build sonar -info + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - name: Build all projects without running tests - run: ./gradlew --build-cache compileJava - - name: SonarCloud Scan + sonar-typescript: + name: SonarCloud TypeScript + runs-on: ubuntu-latest + strategy: + matrix: + subproject: ['ui-admin', 'ui-core', 'ui-participant'] + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Get branch name + id: branch-name + uses: tj-actions/branch-names@v5 + - name: Scan ${{ matrix.subproject }} via sonarcloud-github-action uses: SonarSource/sonarcloud-github-action@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + projectBaseDir: ${{ github.workspace }}/${{ matrix.subproject }} + args: > + -Dsonar.branch.target=${{ github.event.repository.default_branch }} + -Dsonar.branch.name=${{ steps.branch-name.outputs.current_branch }} + - name: Announce + run: | + gh pr comment ${{ github.event.pull_request.number }} \ + --body "SonarCloud [analyzed ${{ matrix.subproject }} on ${{ steps.branch-name.outputs.current_branch }}](https://sonarcloud.io/summary/new_code?id=broadinstitute_juniper-${{ matrix.subproject }}&branch=${{ steps.branch-name.outputs.current_branch }})" + env: + GH_TOKEN: ${{ github.token }} diff --git a/.gitignore b/.gitignore index 19ae5a13e1..af6569d321 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,9 @@ npm-debug.log* .scannerwork .sonar-token tmp/ + +# direnv +.envrc + +*.hprof + diff --git a/api-admin/build.gradle b/api-admin/build.gradle index 603a871ace..23349bfb8d 100644 --- a/api-admin/build.gradle +++ b/api-admin/build.gradle @@ -3,7 +3,6 @@ plugins { id 'de.undercouch.download' id 'com.google.cloud.tools.jib' id 'com.srcclr.gradle' - id 'org.sonarqube' id 'com.gorylenko.gradle-git-properties' version '2.3.1' } @@ -65,12 +64,3 @@ jibDockerBuild.dependsOn('copyWebApp') test { useJUnitPlatform () } - -sonarqube { - properties { - property 'sonar.projectName', 'terra-java-project-template' - property 'sonar.projectKey', 'terra-java-project-template' - property 'sonar.organization', 'broad-databiosphere' - property 'sonar.host.url', 'https://sonarcloud.io' - } -} diff --git a/api-participant/build.gradle b/api-participant/build.gradle index ea56e710c3..c4cce86100 100644 --- a/api-participant/build.gradle +++ b/api-participant/build.gradle @@ -3,7 +3,6 @@ plugins { id 'de.undercouch.download' id 'com.google.cloud.tools.jib' id 'com.srcclr.gradle' - id 'org.sonarqube' id 'com.gorylenko.gradle-git-properties' version '2.3.1' } @@ -61,12 +60,3 @@ jibDockerBuild.dependsOn('copyWebApp') test { useJUnitPlatform () } - -sonarqube { - properties { - property 'sonar.projectName', 'terra-java-project-template' - property 'sonar.projectKey', 'terra-java-project-template' - property 'sonar.organization', 'broad-databiosphere' - property 'sonar.host.url', 'https://sonarcloud.io' - } -} diff --git a/build.gradle b/build.gradle index cde2107918..34deabf251 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ plugins { id 'com.github.node-gradle.node' version '5.0.0' + id 'org.sonarqube' } apply plugin: 'base' @@ -16,3 +17,20 @@ task bundleAdminUI(type: NpmTask, dependsOn: [npmInstall, buildUICore]) { task bundleParticipantUI(type: NpmTask, dependsOn: [npmInstall, buildUICore]) { args = ['--workspace=ui-participant', 'run', 'build'] } + +sonar { + properties { + property 'sonar.projectName', "${rootProject.name}" + property 'sonar.projectKey', "broadinstitute_${rootProject.name}" + property 'sonar.organization', 'dsp-appsec' + property 'sonar.host.url', 'https://sonarcloud.io' + } +} +subprojects { + apply plugin: 'org.sonarqube' + sonar { + properties { + property 'sonar.sources', 'src/main/java,src/main/resources' + } + } +} diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 4fdbf72dd8..3f872a3763 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -18,7 +18,7 @@ dependencies { implementation 'com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.12' implementation 'io.spring.dependency-management:io.spring.dependency-management.gradle.plugin:1.0.15.RELEASE' implementation 'org.hidetake.swagger.generator:org.hidetake.swagger.generator.gradle.plugin:2.19.2' - implementation 'org.sonarqube:org.sonarqube.gradle.plugin:3.4.0.2513' + implementation 'org.sonarqube:org.sonarqube.gradle.plugin:4.2.1.3168' implementation 'org.springframework.boot:spring-boot-gradle-plugin:2.7.10' implementation 'bio.terra:terra-test-runner:0.1.5-SNAPSHOT' // This is required due to a dependency conflict between jib and srcclr. Removing it will cause jib to fail. diff --git a/core/build.gradle b/core/build.gradle index ca2ff9dfa0..40f7c6a14f 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -55,4 +55,3 @@ dependencies { test { useJUnitPlatform () } - diff --git a/populate/build.gradle b/populate/build.gradle index 958e9d0192..fa651fa441 100644 --- a/populate/build.gradle +++ b/populate/build.gradle @@ -35,4 +35,3 @@ dependencies { test { useJUnitPlatform () } - diff --git a/settings.gradle b/settings.gradle index b58c8e742f..679ceb7af6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ -rootProject.name = 'pearl' +rootProject.name = 'juniper' include('core', 'populate', 'api-admin', 'api-participant') gradle.ext.releaseVersion = '0.0.85' diff --git a/sonar-project.properties b/sonar-project.properties deleted file mode 100644 index 95c6464f6e..0000000000 --- a/sonar-project.properties +++ /dev/null @@ -1,8 +0,0 @@ -sonar.projectKey=broadinstitute_pearl -sonar.organization=dsp-appsec -sonar.projectName=pearl -sonar.sources=api-admin,api-participant,core,populate,ui-admin,ui-participant -sonar.sourceEncoding=UTF-8 -sonar.java.binaries=api-admin/build/classes,api-participant/build/classes,core/build/classes - -# TODO sonar.coverage.jacoco.xmlReportPaths \ No newline at end of file diff --git a/ui-admin/sonar-project.properties b/ui-admin/sonar-project.properties new file mode 100644 index 0000000000..2b785ca773 --- /dev/null +++ b/ui-admin/sonar-project.properties @@ -0,0 +1,3 @@ +sonar.projectKey=broadinstitute_juniper-ui-admin +sonar.organization=dsp-appsec +sonar.projectName=juniper-ui-admin diff --git a/ui-core/sonar-project.properties b/ui-core/sonar-project.properties new file mode 100644 index 0000000000..5d7498351c --- /dev/null +++ b/ui-core/sonar-project.properties @@ -0,0 +1,3 @@ +sonar.projectKey=broadinstitute_juniper-ui-core +sonar.organization=dsp-appsec +sonar.projectName=juniper-ui-core diff --git a/ui-participant/sonar-project.properties b/ui-participant/sonar-project.properties new file mode 100644 index 0000000000..1d55561464 --- /dev/null +++ b/ui-participant/sonar-project.properties @@ -0,0 +1,3 @@ +sonar.projectKey=broadinstitute_juniper-ui-participant +sonar.organization=dsp-appsec +sonar.projectName=juniper-ui-participant