From f1f6bef0eeb8524107c09953345c8c437591b116 Mon Sep 17 00:00:00 2001 From: TomConner Date: Thu, 20 Jul 2023 10:50:28 -0400 Subject: [PATCH 01/83] include sonar in Java CI --- .github/workflows/java-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/java-ci.yml b/.github/workflows/java-ci.yml index 96b9df3fab..218296b127 100644 --- a/.github/workflows/java-ci.yml +++ b/.github/workflows/java-ci.yml @@ -50,10 +50,10 @@ jobs: distribution: 'adopt' - name: Validate Gradle wrapper uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b - - name: Build with Gradle + - name: Build and SonarQube scan with Gradle uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 with: - arguments: build --info # if you need to see test failure full stacktraces, change this to `build --info` + arguments: build sonar --info # if you need to see test failure full stacktraces, change this to `build --info` # Need to uncomment these in follow up PR, The new Trivy and Tag workflows need to exist on the development branch # before the following steps will work From ea4937662e55177fd0e6fb5a79e93d691cf26e9b Mon Sep 17 00:00:00 2001 From: TomConner Date: Thu, 20 Jul 2023 11:06:11 -0400 Subject: [PATCH 02/83] sonar in Java CI --- .github/workflows/java-ci.yml | 3 +++ api-admin/build.gradle | 2 +- api-participant/build.gradle | 2 +- buildSrc/build.gradle | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/java-ci.yml b/.github/workflows/java-ci.yml index 218296b127..b16bbc0459 100644 --- a/.github/workflows/java-ci.yml +++ b/.github/workflows/java-ci.yml @@ -54,6 +54,9 @@ jobs: uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 with: arguments: build sonar --info # if you need to see test failure full stacktraces, change this to `build --info` + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Need to uncomment these in follow up PR, The new Trivy and Tag workflows need to exist on the development branch # before the following steps will work diff --git a/api-admin/build.gradle b/api-admin/build.gradle index 603a871ace..287727da55 100644 --- a/api-admin/build.gradle +++ b/api-admin/build.gradle @@ -66,7 +66,7 @@ test { useJUnitPlatform () } -sonarqube { +sonar { properties { property 'sonar.projectName', 'terra-java-project-template' property 'sonar.projectKey', 'terra-java-project-template' diff --git a/api-participant/build.gradle b/api-participant/build.gradle index ea56e710c3..ac447b0f31 100644 --- a/api-participant/build.gradle +++ b/api-participant/build.gradle @@ -62,7 +62,7 @@ test { useJUnitPlatform () } -sonarqube { +sonar { properties { property 'sonar.projectName', 'terra-java-project-template' property 'sonar.projectKey', 'terra-java-project-template' 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. From d0fbe58b118d0e58de3fb64af742bda0130d63e3 Mon Sep 17 00:00:00 2001 From: TomConner Date: Fri, 21 Jul 2023 13:43:51 -0400 Subject: [PATCH 03/83] separate project sonar scans --- .github/workflows/java-ci.yml | 2 +- .github/workflows/sonar.yaml | 53 +++++++++++++++++++++++++------ README.md | 29 ++++++++++++----- api-admin/build.gradle | 5 +-- api-participant/build.gradle | 5 +-- populate/build.gradle | 10 ++++++ sonar-project.properties | 8 ----- ui-admin/sonar-project.properties | 6 ++++ 8 files changed, 87 insertions(+), 31 deletions(-) delete mode 100644 sonar-project.properties create mode 100644 ui-admin/sonar-project.properties diff --git a/.github/workflows/java-ci.yml b/.github/workflows/java-ci.yml index b16bbc0459..ed790610ed 100644 --- a/.github/workflows/java-ci.yml +++ b/.github/workflows/java-ci.yml @@ -53,7 +53,7 @@ jobs: - name: Build and SonarQube scan with Gradle uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 with: - arguments: build sonar --info # if you need to see test failure full stacktraces, change this to `build --info` + arguments: build --info # if you need to see test failure full stacktraces, change this to `build --info` env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 09974b0c5e..e5a1031ca7 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -2,23 +2,56 @@ name: Sonar on: workflow_dispatch jobs: - sonar: + # sonar: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + + # - name: Set up JDK + # uses: actions/setup-java@v3 + # with: + # java-version: '17' + # distribution: 'temurin' + # cache: 'gradle' + + # - name: SonarCloud Scan (Typescript only) + # uses: SonarSource/sonarcloud-github-action@master + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + + # - name: SonarCloud Scan (Java only) + # run: ./gradlew --build-cache compileJava sonar + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + sonar-api-admin: + name: SonarCloud api-admin runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - - name: Set up JDK - uses: actions/setup-java@v3 with: - java-version: '17' - distribution: 'temurin' - cache: 'gradle' + fetch-depth: 0 + - name: Scan api-admin via gradle + run: ./gradlew --build-cache :api-admin:compileJava :api-admin:sonar + 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-ui-admin: + name: SonarCloud ui-admin + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Scan ui-admin 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: ui-admin/ diff --git a/README.md b/README.md index 1fe3ddb85d..ad0aa66f0a 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ DTOs, and populate services. the PopulateCliApp can be used to populate specifi In development, it serves at localhost:8081. Lives in `api-participant` directory ##### Study Manager UI Participant UI is a create-react-app SPA. Lives in `ui-participant` directory. Serves on localhost:3001 in development - + ## Local development @@ -47,7 +47,7 @@ run `./local-dev/run_postgres.sh start` This will start a postgres container with a schema and user configured #### IDE Setup -Open the root folder in IntelliJ. +Open the root folder in IntelliJ. * **server:** @@ -76,15 +76,15 @@ Open the root folder in IntelliJ. * set environment variable: `B2C_POLICY_NAME=B2C_1A_ddp_participant_signup_signin_dev` * set environment variable: `B2C_CHANGE_PASSWORD_POLICY_NAME=B2C_1A_ddp_participant_change_password_dev` * disable launch optimization - - + + ### Running the application #### Admin tool (study manager, population) * API (api-admin module) In intelliJ, you can either run ApiAdminApp (from the api-admin module) directly, or execute the "bootRun" gradle task. In basic development mode, this will only serve the API, not the frontend assets. -To make the application useful, you will want to populate some users and studies. After the admin API is running, +To make the application useful, you will want to populate some users and studies. After the admin API is running, from the root project directory, run ``` ./scripts/populate_portal.sh ourhealth @@ -98,7 +98,7 @@ From the command line: REACT_APP_B2C_TENANT_NAME=ddpdevb2c REACT_APP_B2C_CLIENT_ID=$(vault read -field value secret/dsp/ddp/b2c/dev/application_id) npm -w ui-admin start ``` (note that you can just run `npm -w ui-admin start` if you don't need to test B2C login functionality) -Then go to `localhost:3000` +Then go to `localhost:3000` ##### Participant API (api-participant module) In intelliJ, you can either run ApiParticipantApp (from the api-participant module) directly, or execute the "bootRun" gradle task. @@ -118,9 +118,9 @@ Then go to `sandbox.ourhealth.localhost:3001` (Notice how you need the environment name and portal name as subdomains) -### Feature Development +### Feature Development -#### Adding a new model +#### Adding a new model 1. Create the schema, models, and services 1. Create your POJO model in `core/src/main/java/bio/terra/pearl/core/model`, you will almost certainly want to extend `BaseEntity` @@ -150,3 +150,16 @@ Then go to `sandbox.ourhealth.localhost:3001` #### Adding environment variables Helm charts: https://github.com/broadinstitute/terra-helmfile/tree/master/values/app/d2p/live + + +### SonarCloud code scanning + +Because juniper contains TypeScript projects and Java projects, the scans are run independently +in each project + +Typescript UI subprojects (ui-admin, ui-core, and ui-participant) are scanned using the +SonarCloud GitHub Action. Analysis (SonarCloud +runs the scan on its own and comments back results to PRs). + +Java subprojects (core, client, api-admin, api-participant) are scanned using gradle with the +sonarqube plugin. \ No newline at end of file diff --git a/api-admin/build.gradle b/api-admin/build.gradle index 287727da55..529b310da6 100644 --- a/api-admin/build.gradle +++ b/api-admin/build.gradle @@ -68,8 +68,9 @@ test { sonar { properties { - property 'sonar.projectName', 'terra-java-project-template' - property 'sonar.projectKey', 'terra-java-project-template' + property 'sonar.projectName', 'juniper-api-admin' + property 'sonar.projectKey', 'broadinstitute_juniper-api-admin' + property 'sonar.projectBaseDir', '.' 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 ac447b0f31..25fc808d4e 100644 --- a/api-participant/build.gradle +++ b/api-participant/build.gradle @@ -64,8 +64,9 @@ test { sonar { properties { - property 'sonar.projectName', 'terra-java-project-template' - property 'sonar.projectKey', 'terra-java-project-template' + property 'sonar.projectName', 'juniper-api-participant' + property 'sonar.projectKey', 'broadinstitute_juniper-api-participant' + property 'sonar.projectBaseDir', '.' property 'sonar.organization', 'broad-databiosphere' property 'sonar.host.url', 'https://sonarcloud.io' } diff --git a/populate/build.gradle b/populate/build.gradle index 958e9d0192..a1bd2db72f 100644 --- a/populate/build.gradle +++ b/populate/build.gradle @@ -1,6 +1,7 @@ plugins { id "io.freefair.lombok" version "5.3.3.3" id 'java' + id 'org.sonarqube' } group = 'bio.terra.pearl.core' @@ -36,3 +37,12 @@ test { useJUnitPlatform () } +sonar { + properties { + property 'sonar.projectName', 'juniper-populate' + property 'sonar.projectKey', 'broadinstitute_juniper-populate' + property 'sonar.projectBaseDir', '.' + property 'sonar.organization', 'broad-databiosphere' + property 'sonar.host.url', 'https://sonarcloud.io' + } +} 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..6d4dc573ef --- /dev/null +++ b/ui-admin/sonar-project.properties @@ -0,0 +1,6 @@ +sonar.projectName=juniper-ui-admin +sonar.projectKey=broadinstitute_juniper-ui-admin +sonar.organization=dsp-appsec +sonar.sourceEncoding=UTF-8 + +# TODO sonar.coverage.jacoco.xmlReportPaths \ No newline at end of file From 2781dab8b06801b3ff6ce3da0bb6f257a276936e Mon Sep 17 00:00:00 2001 From: TomConner Date: Fri, 21 Jul 2023 14:01:35 -0400 Subject: [PATCH 04/83] sonar-project.properties at root --- .../sonar-project.properties => sonar-project.properties | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename ui-admin/sonar-project.properties => sonar-project.properties (50%) diff --git a/ui-admin/sonar-project.properties b/sonar-project.properties similarity index 50% rename from ui-admin/sonar-project.properties rename to sonar-project.properties index 6d4dc573ef..cb8e1d2a1b 100644 --- a/ui-admin/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,7 @@ -sonar.projectName=juniper-ui-admin -sonar.projectKey=broadinstitute_juniper-ui-admin +sonar.projectName=juniper-ui +sonar.projectKey=broadinstitute_juniper sonar.organization=dsp-appsec +sonar.sources=ui-admin,ui-core sonar.sourceEncoding=UTF-8 # TODO sonar.coverage.jacoco.xmlReportPaths \ No newline at end of file From 702302871e60c76529815c92d8463114de36cb28 Mon Sep 17 00:00:00 2001 From: TomConner Date: Fri, 21 Jul 2023 14:12:27 -0400 Subject: [PATCH 05/83] combine all java and combine all typescript --- .github/workflows/java-ci.yml | 14 +++++++------- .github/workflows/sonar.yaml | 16 +++++++--------- .github/workflows/ui-ci.yml | 13 +++++++------ 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/.github/workflows/java-ci.yml b/.github/workflows/java-ci.yml index ed790610ed..2244d35040 100644 --- a/.github/workflows/java-ci.yml +++ b/.github/workflows/java-ci.yml @@ -12,12 +12,13 @@ name: Java CI on: - push: - branches: [ development ] - paths-ignore: [ '*.md'] - pull_request: - branches: [ '**' ] - merge_group: + # push: + # branches: [ development ] + # paths-ignore: [ '*.md'] + # pull_request: + # branches: [ '**' ] + # merge_group: + workflow_dispatch: jobs: build: @@ -56,7 +57,6 @@ jobs: arguments: build --info # if you need to see test failure full stacktraces, change this to `build --info` env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Need to uncomment these in follow up PR, The new Trivy and Tag workflows need to exist on the development branch # before the following steps will work diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index e5a1031ca7..4f7c0ab443 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -27,31 +27,29 @@ jobs: # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - sonar-api-admin: - name: SonarCloud api-admin + sonar-java: + name: SonarCloud Java runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Scan api-admin via gradle - run: ./gradlew --build-cache :api-admin:compileJava :api-admin:sonar + - name: Scan via gradle + run: ./gradlew --build-cache compileJava sonar env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - sonar-ui-admin: - name: SonarCloud ui-admin + sonar-typescript: + name: SonarCloud TypeScript runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Scan ui-admin via sonarcloud-github-action + - name: Scan 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: ui-admin/ diff --git a/.github/workflows/ui-ci.yml b/.github/workflows/ui-ci.yml index 876acbbb55..6c45e49525 100644 --- a/.github/workflows/ui-ci.yml +++ b/.github/workflows/ui-ci.yml @@ -1,12 +1,13 @@ name: UI CI on: - push: - branches: [ development ] - paths-ignore: [ '*.md'] - pull_request: - branches: [ '**' ] - merge_group: + # push: + # branches: [ development ] + # paths-ignore: [ '*.md'] + # pull_request: + # branches: [ '**' ] + # merge_group: + workflow_dispatch: jobs: build: From 50add44b8c3e2d0520d495288db35f853e0b82b6 Mon Sep 17 00:00:00 2001 From: TomConner Date: Fri, 21 Jul 2023 14:17:18 -0400 Subject: [PATCH 06/83] sonar typescript --- .github/workflows/sonar.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 4f7c0ab443..3549fb1599 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -40,16 +40,18 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - sonar-typescript: - name: SonarCloud TypeScript + sonar-ui-admin: + name: SonarCloud ui-admin runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Scan via sonarcloud-github-action + - name: Scan ui-admin 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: ui-admin/ + From c6963e425a7ee22f981ffa1c30ffd5eeadeed99b Mon Sep 17 00:00:00 2001 From: TomConner Date: Fri, 21 Jul 2023 14:46:16 -0400 Subject: [PATCH 07/83] sonar args in workflow --- .github/workflows/sonar.yaml | 55 ++++++++++++++++++++---------------- sonar-project.properties | 7 ----- 2 files changed, 30 insertions(+), 32 deletions(-) delete mode 100644 sonar-project.properties diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 3549fb1599..eba95fb335 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -2,31 +2,6 @@ name: Sonar on: workflow_dispatch jobs: - # sonar: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - - # - name: Set up JDK - # uses: actions/setup-java@v3 - # with: - # java-version: '17' - # distribution: 'temurin' - # cache: 'gradle' - - # - name: SonarCloud Scan (Typescript only) - # uses: SonarSource/sonarcloud-github-action@master - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - - # - name: SonarCloud Scan (Java only) - # run: ./gradlew --build-cache compileJava sonar - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - sonar-java: name: SonarCloud Java runs-on: ubuntu-latest @@ -54,4 +29,34 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} with: projectBaseDir: ui-admin/ + args: > + -Dsonar.projectName=juniper-ui-admin + -Dsonar.organization=dsp-appsec + -Dsonar.projectKey=broadinstitute_juniper-ui-admin + -Dsonar.verbose=true + + # sonar: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + + # - name: Set up JDK + # uses: actions/setup-java@v3 + # with: + # java-version: '17' + # distribution: 'temurin' + # cache: 'gradle' + + # - name: SonarCloud Scan (Typescript only) + # uses: SonarSource/sonarcloud-github-action@master + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + + # - name: SonarCloud Scan (Java only) + # run: ./gradlew --build-cache compileJava sonar + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/sonar-project.properties b/sonar-project.properties deleted file mode 100644 index cb8e1d2a1b..0000000000 --- a/sonar-project.properties +++ /dev/null @@ -1,7 +0,0 @@ -sonar.projectName=juniper-ui -sonar.projectKey=broadinstitute_juniper -sonar.organization=dsp-appsec -sonar.sources=ui-admin,ui-core -sonar.sourceEncoding=UTF-8 - -# TODO sonar.coverage.jacoco.xmlReportPaths \ No newline at end of file From 64d6e2d134cf4868753c8cbd77fa17f610886a15 Mon Sep 17 00:00:00 2001 From: TomConner Date: Fri, 21 Jul 2023 14:49:14 -0400 Subject: [PATCH 08/83] sonarscanner --- .github/workflows/sonar.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index eba95fb335..6dc83c5629 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -30,9 +30,9 @@ jobs: with: projectBaseDir: ui-admin/ args: > - -Dsonar.projectName=juniper-ui-admin + -Dsonar.projectName=juniper -Dsonar.organization=dsp-appsec - -Dsonar.projectKey=broadinstitute_juniper-ui-admin + -Dsonar.projectKey=broadinstitute_juniper -Dsonar.verbose=true # sonar: From 481092837582c0b171dd8752e668f521f8b2f5a9 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 13:35:39 -0400 Subject: [PATCH 09/83] work in progress --- .gitignore | 3 +++ api-admin/build.gradle | 11 ----------- api-participant/build.gradle | 1 - build.gradle | 14 ++++++++++++++ client/build.gradle | 11 +++++++++++ core/build.gradle | 10 ++++++++++ integration/build.gradle | 11 +++++++++++ settings.gradle | 2 +- 8 files changed, 50 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 19ae5a13e1..b06543d7b0 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,6 @@ npm-debug.log* .scannerwork .sonar-token tmp/ + +# direnv +.envrc diff --git a/api-admin/build.gradle b/api-admin/build.gradle index 529b310da6..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,13 +64,3 @@ jibDockerBuild.dependsOn('copyWebApp') test { useJUnitPlatform () } - -sonar { - properties { - property 'sonar.projectName', 'juniper-api-admin' - property 'sonar.projectKey', 'broadinstitute_juniper-api-admin' - property 'sonar.projectBaseDir', '.' - 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 25fc808d4e..b4f1353c4a 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' } diff --git a/build.gradle b/build.gradle index cde2107918..f950171b13 100644 --- a/build.gradle +++ b/build.gradle @@ -16,3 +16,17 @@ task bundleAdminUI(type: NpmTask, dependsOn: [npmInstall, buildUICore]) { task bundleParticipantUI(type: NpmTask, dependsOn: [npmInstall, buildUICore]) { args = ['--workspace=ui-participant', 'run', 'build'] } + +subprojects { + apply plugin: 'org.sonarqube' + + sonar { + properties { + property 'sonar.projectName', "${rootProject.name}-${project.name}" + property 'sonar.projectKey', "broadinstitute_${rootProject.name}-${project.name}" + property 'sonar.projectBaseDir', "${projectDir}" + property 'sonar.organization', 'broad-databiosphere' + property 'sonar.host.url', 'https://sonarcloud.io' + } + } +} diff --git a/client/build.gradle b/client/build.gradle index 1ed4a117bd..c474db7905 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -6,6 +6,7 @@ plugins { id 'io.spring.dependency-management' id 'com.jfrog.artifactory' version '4.18.2' id 'org.hidetake.swagger.generator' + id 'org.sonarqube' } dependencyManagement { @@ -16,3 +17,13 @@ dependencyManagement { apply from: 'artifactory.gradle' apply from: 'swagger.gradle' + +sonar { + properties { + property 'sonar.projectName', 'juniper-client' + property 'sonar.projectKey', 'broadinstitute_juniper-client' + property 'sonar.projectBaseDir', '.' + property 'sonar.organization', 'broad-databiosphere' + property 'sonar.host.url', 'https://sonarcloud.io' + } +} diff --git a/core/build.gradle b/core/build.gradle index ca2ff9dfa0..8f449f8e5c 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -3,6 +3,7 @@ plugins { id 'java' id 'org.liquibase.gradle' version '2.1.0' id "java-test-fixtures" + id 'org.sonarqube' } group = 'bio.terra.pearl.core' @@ -56,3 +57,12 @@ test { useJUnitPlatform () } +sonar { + properties { + property 'sonar.projectName', 'juniper-core' + property 'sonar.projectKey', 'broadinstitute_juniper-core' + property 'sonar.projectBaseDir', '.' + property 'sonar.organization', 'broad-databiosphere' + property 'sonar.host.url', 'https://sonarcloud.io' + } +} diff --git a/integration/build.gradle b/integration/build.gradle index e658872b51..2c8110abea 100644 --- a/integration/build.gradle +++ b/integration/build.gradle @@ -4,6 +4,7 @@ plugins { id 'bio.terra.java-application-conventions' id 'io.spring.dependency-management' id 'bio.terra.test-runner-plugin' + id 'org.sonarqube' } dependencyManagement { @@ -29,3 +30,13 @@ dependencies { // Requires client libraries implementation project(':client') } + +sonar { + properties { + property 'sonar.projectName', 'juniper-integration' + property 'sonar.projectKey', 'broadinstitute_juniper-integration' + property 'sonar.projectBaseDir', '.' + property 'sonar.organization', 'broad-databiosphere' + property 'sonar.host.url', 'https://sonarcloud.io' + } +} 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' From dec810d3d036db47c80e5a9ad97da2e7de9291ad Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 17:15:00 -0400 Subject: [PATCH 10/83] multiproject sonar --- .gitignore | 3 +++ api-participant/build.gradle | 10 ---------- build.gradle | 5 ++--- client/build.gradle | 11 ----------- core/build.gradle | 11 ----------- integration/build.gradle | 11 ----------- populate/build.gradle | 11 ----------- 7 files changed, 5 insertions(+), 57 deletions(-) diff --git a/.gitignore b/.gitignore index b06543d7b0..af6569d321 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ tmp/ # direnv .envrc + +*.hprof + diff --git a/api-participant/build.gradle b/api-participant/build.gradle index b4f1353c4a..c4cce86100 100644 --- a/api-participant/build.gradle +++ b/api-participant/build.gradle @@ -60,13 +60,3 @@ jibDockerBuild.dependsOn('copyWebApp') test { useJUnitPlatform () } - -sonar { - properties { - property 'sonar.projectName', 'juniper-api-participant' - property 'sonar.projectKey', 'broadinstitute_juniper-api-participant' - property 'sonar.projectBaseDir', '.' - property 'sonar.organization', 'broad-databiosphere' - property 'sonar.host.url', 'https://sonarcloud.io' - } -} diff --git a/build.gradle b/build.gradle index f950171b13..af5012bec4 100644 --- a/build.gradle +++ b/build.gradle @@ -17,15 +17,14 @@ task bundleParticipantUI(type: NpmTask, dependsOn: [npmInstall, buildUICore]) { args = ['--workspace=ui-participant', 'run', 'build'] } +apply plugin: 'org.sonarqube' subprojects { - apply plugin: 'org.sonarqube' - sonar { properties { property 'sonar.projectName', "${rootProject.name}-${project.name}" property 'sonar.projectKey', "broadinstitute_${rootProject.name}-${project.name}" property 'sonar.projectBaseDir', "${projectDir}" - property 'sonar.organization', 'broad-databiosphere' + property 'sonar.organization', 'dsp-appsec' property 'sonar.host.url', 'https://sonarcloud.io' } } diff --git a/client/build.gradle b/client/build.gradle index c474db7905..1ed4a117bd 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -6,7 +6,6 @@ plugins { id 'io.spring.dependency-management' id 'com.jfrog.artifactory' version '4.18.2' id 'org.hidetake.swagger.generator' - id 'org.sonarqube' } dependencyManagement { @@ -17,13 +16,3 @@ dependencyManagement { apply from: 'artifactory.gradle' apply from: 'swagger.gradle' - -sonar { - properties { - property 'sonar.projectName', 'juniper-client' - property 'sonar.projectKey', 'broadinstitute_juniper-client' - property 'sonar.projectBaseDir', '.' - property 'sonar.organization', 'broad-databiosphere' - property 'sonar.host.url', 'https://sonarcloud.io' - } -} diff --git a/core/build.gradle b/core/build.gradle index 8f449f8e5c..40f7c6a14f 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -3,7 +3,6 @@ plugins { id 'java' id 'org.liquibase.gradle' version '2.1.0' id "java-test-fixtures" - id 'org.sonarqube' } group = 'bio.terra.pearl.core' @@ -56,13 +55,3 @@ dependencies { test { useJUnitPlatform () } - -sonar { - properties { - property 'sonar.projectName', 'juniper-core' - property 'sonar.projectKey', 'broadinstitute_juniper-core' - property 'sonar.projectBaseDir', '.' - property 'sonar.organization', 'broad-databiosphere' - property 'sonar.host.url', 'https://sonarcloud.io' - } -} diff --git a/integration/build.gradle b/integration/build.gradle index 2c8110abea..e658872b51 100644 --- a/integration/build.gradle +++ b/integration/build.gradle @@ -4,7 +4,6 @@ plugins { id 'bio.terra.java-application-conventions' id 'io.spring.dependency-management' id 'bio.terra.test-runner-plugin' - id 'org.sonarqube' } dependencyManagement { @@ -30,13 +29,3 @@ dependencies { // Requires client libraries implementation project(':client') } - -sonar { - properties { - property 'sonar.projectName', 'juniper-integration' - property 'sonar.projectKey', 'broadinstitute_juniper-integration' - property 'sonar.projectBaseDir', '.' - property 'sonar.organization', 'broad-databiosphere' - property 'sonar.host.url', 'https://sonarcloud.io' - } -} diff --git a/populate/build.gradle b/populate/build.gradle index a1bd2db72f..fa651fa441 100644 --- a/populate/build.gradle +++ b/populate/build.gradle @@ -1,7 +1,6 @@ plugins { id "io.freefair.lombok" version "5.3.3.3" id 'java' - id 'org.sonarqube' } group = 'bio.terra.pearl.core' @@ -36,13 +35,3 @@ dependencies { test { useJUnitPlatform () } - -sonar { - properties { - property 'sonar.projectName', 'juniper-populate' - property 'sonar.projectKey', 'broadinstitute_juniper-populate' - property 'sonar.projectBaseDir', '.' - property 'sonar.organization', 'broad-databiosphere' - property 'sonar.host.url', 'https://sonarcloud.io' - } -} From b6ebf5fb39a60e403cf7a0c842bff7cb1436b949 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 17:43:31 -0400 Subject: [PATCH 11/83] gradle sonar on single bound project --- .github/workflows/sonar.yaml | 48 +----------------------------------- build.gradle | 20 +++++++-------- 2 files changed, 11 insertions(+), 57 deletions(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 6dc83c5629..8c025de952 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -10,53 +10,7 @@ jobs: with: fetch-depth: 0 - name: Scan via gradle - run: ./gradlew --build-cache compileJava sonar + run: ./gradlew --build-cache compileJava sonar -info env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - sonar-ui-admin: - name: SonarCloud ui-admin - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Scan ui-admin 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: ui-admin/ - args: > - -Dsonar.projectName=juniper - -Dsonar.organization=dsp-appsec - -Dsonar.projectKey=broadinstitute_juniper - -Dsonar.verbose=true - - # sonar: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - - # - name: Set up JDK - # uses: actions/setup-java@v3 - # with: - # java-version: '17' - # distribution: 'temurin' - # cache: 'gradle' - - # - name: SonarCloud Scan (Typescript only) - # uses: SonarSource/sonarcloud-github-action@master - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - - # - name: SonarCloud Scan (Java only) - # run: ./gradlew --build-cache compileJava sonar - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - diff --git a/build.gradle b/build.gradle index af5012bec4..a8c29338d9 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' @@ -17,15 +18,14 @@ task bundleParticipantUI(type: NpmTask, dependsOn: [npmInstall, buildUICore]) { args = ['--workspace=ui-participant', 'run', 'build'] } -apply plugin: 'org.sonarqube' -subprojects { - sonar { - properties { - property 'sonar.projectName', "${rootProject.name}-${project.name}" - property 'sonar.projectKey', "broadinstitute_${rootProject.name}-${project.name}" - property 'sonar.projectBaseDir', "${projectDir}" - property 'sonar.organization', 'dsp-appsec' - property 'sonar.host.url', 'https://sonarcloud.io' - } +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' +} From 1fe02e2a7166929004d577d0665bfedb3f1be2c7 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 19:10:59 -0400 Subject: [PATCH 12/83] exclude spotless --- .github/workflows/sonar.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 8c025de952..bd3e6fe13e 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -10,7 +10,16 @@ jobs: with: fetch-depth: 0 - name: Scan via gradle - run: ./gradlew --build-cache compileJava sonar -info + 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 }} From becb8989e391498eb2ea8fdb481c07b0a60b1596 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 19:37:34 -0400 Subject: [PATCH 13/83] include resources in sonar --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index a8c29338d9..4fa3c22c7c 100644 --- a/build.gradle +++ b/build.gradle @@ -24,6 +24,7 @@ sonar { property 'sonar.projectKey', "broadinstitute_${rootProject.name}" property 'sonar.organization', 'dsp-appsec' property 'sonar.host.url', 'https://sonarcloud.io' + property 'sonar.sources', 'src/main/java,src/main/resources' } } subprojects { From 6cb22dca4f3ec0f3cd7d029d8bc04866f2753dc6 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 19:48:49 -0400 Subject: [PATCH 14/83] include resources in sonar --- build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 4fa3c22c7c..bdbcfae5b3 100644 --- a/build.gradle +++ b/build.gradle @@ -24,9 +24,11 @@ sonar { property 'sonar.projectKey', "broadinstitute_${rootProject.name}" property 'sonar.organization', 'dsp-appsec' property 'sonar.host.url', 'https://sonarcloud.io' - property 'sonar.sources', 'src/main/java,src/main/resources' } } subprojects { apply plugin: 'org.sonarqube' + sonar { + property 'sonar.sources', 'src/main/java,src/main/resources' + } } From 288039f2f6f9cc6b28ddd4d4de4f93bb8d6323c9 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 20:57:55 -0400 Subject: [PATCH 15/83] resources --- build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index bdbcfae5b3..34deabf251 100644 --- a/build.gradle +++ b/build.gradle @@ -29,6 +29,8 @@ sonar { subprojects { apply plugin: 'org.sonarqube' sonar { - property 'sonar.sources', 'src/main/java,src/main/resources' + properties { + property 'sonar.sources', 'src/main/java,src/main/resources' + } } } From b558e2c347d1ee424e3d59f1e58f14be9cedf61a Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 21:19:33 -0400 Subject: [PATCH 16/83] gha sonar --- .github/workflows/sonar.yaml | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index bd3e6fe13e..47b278d506 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -9,6 +9,23 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + - 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: Scan via gradle run: >- ./gradlew @@ -23,3 +40,28 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + + sonar-typescript: + name: SonarCloud ui-admin + runs-on: ubuntu-latest + strategy: + matrix: + subproject: ['ui-admin', 'ui-participant'] + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - 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.projectName=juniper-${{ matrix.subproject }} + -Dsonar.organization=dsp-appsec + -Dsonar.projectKey=broadinstitute_juniper-${{ matrix.subproject }} + -Dsonar.verbose=true From bbdde7129cef75529d0f800770a6c0416a9c456d Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 21:33:57 -0400 Subject: [PATCH 17/83] gha --- .github/workflows/sonar.yaml | 18 +----------------- ui-admin/sonar-project.properties | 13 +++++++++++++ ui-participant/sonar-project.properties | 13 +++++++++++++ 3 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 ui-admin/sonar-project.properties create mode 100644 ui-participant/sonar-project.properties diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 47b278d506..09d23b930d 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -14,18 +14,6 @@ jobs: with: java-version: '17' distribution: 'adopt' - - 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: Scan via gradle run: >- ./gradlew @@ -43,12 +31,11 @@ jobs: sonar-typescript: - name: SonarCloud ui-admin + name: SonarCloud TypeScript runs-on: ubuntu-latest strategy: matrix: subproject: ['ui-admin', 'ui-participant'] - steps: - uses: actions/checkout@v3 with: @@ -61,7 +48,4 @@ jobs: with: projectBaseDir: ${{ github.workspace }}/${{ matrix.subproject }} args: > - -Dsonar.projectName=juniper-${{ matrix.subproject }} - -Dsonar.organization=dsp-appsec - -Dsonar.projectKey=broadinstitute_juniper-${{ matrix.subproject }} -Dsonar.verbose=true diff --git a/ui-admin/sonar-project.properties b/ui-admin/sonar-project.properties new file mode 100644 index 0000000000..0ed872c811 --- /dev/null +++ b/ui-admin/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.projectKey=broadinstitute_juniper-ui-admin +sonar.organization=dsp-appsec + +# This is the name and version displayed in the SonarCloud UI. +sonar.projectName=juniper-ui-admin +#sonar.projectVersion=1.0 + + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 diff --git a/ui-participant/sonar-project.properties b/ui-participant/sonar-project.properties new file mode 100644 index 0000000000..d4d36496c4 --- /dev/null +++ b/ui-participant/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.projectKey=broadinstitute_juniper-ui-participant +sonar.organization=dsp-appsec + +# This is the name and version displayed in the SonarCloud UI. +sonar.projectName=juniper-ui-participant +#sonar.projectVersion=1.0 + + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 From 150f883d4a3ca295f40a3430fdbed696f6e7ad9c Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 22:10:34 -0400 Subject: [PATCH 18/83] typescript sonar specify branch --- .github/workflows/sonar.yaml | 8 +++++++- ui-admin/sonar-project.properties | 10 ---------- ui-participant/sonar-project.properties | 10 ---------- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 09d23b930d..da58be83fc 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -1,5 +1,10 @@ name: Sonar on: workflow_dispatch + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] jobs: sonar-java: @@ -48,4 +53,5 @@ jobs: with: projectBaseDir: ${{ github.workspace }}/${{ matrix.subproject }} args: > - -Dsonar.verbose=true + -Dsonar.branch.target=${{ github.event.repository.default_branch }} + -Dsonar.branch.name=${{ github.ref_name }} diff --git a/ui-admin/sonar-project.properties b/ui-admin/sonar-project.properties index 0ed872c811..2b785ca773 100644 --- a/ui-admin/sonar-project.properties +++ b/ui-admin/sonar-project.properties @@ -1,13 +1,3 @@ sonar.projectKey=broadinstitute_juniper-ui-admin sonar.organization=dsp-appsec - -# This is the name and version displayed in the SonarCloud UI. sonar.projectName=juniper-ui-admin -#sonar.projectVersion=1.0 - - -# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -#sonar.sources=. - -# Encoding of the source code. Default is default system encoding -#sonar.sourceEncoding=UTF-8 diff --git a/ui-participant/sonar-project.properties b/ui-participant/sonar-project.properties index d4d36496c4..1d55561464 100644 --- a/ui-participant/sonar-project.properties +++ b/ui-participant/sonar-project.properties @@ -1,13 +1,3 @@ sonar.projectKey=broadinstitute_juniper-ui-participant sonar.organization=dsp-appsec - -# This is the name and version displayed in the SonarCloud UI. sonar.projectName=juniper-ui-participant -#sonar.projectVersion=1.0 - - -# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -#sonar.sources=. - -# Encoding of the source code. Default is default system encoding -#sonar.sourceEncoding=UTF-8 From 5739af6a8786660061f286162cb55ad677c87d5b Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 22:13:58 -0400 Subject: [PATCH 19/83] sonar on push --- .github/workflows/sonar.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index da58be83fc..477faa7783 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -1,5 +1,6 @@ name: Sonar -on: workflow_dispatch +on: + workflow_dispatch: push: branches: - master From 67f6447957d8303aace61eedab68466448614afc Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 22:26:55 -0400 Subject: [PATCH 20/83] sonar on push --- .github/workflows/sonar.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 477faa7783..59f182d13b 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -46,6 +46,9 @@ jobs: - 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: @@ -55,4 +58,4 @@ jobs: projectBaseDir: ${{ github.workspace }}/${{ matrix.subproject }} args: > -Dsonar.branch.target=${{ github.event.repository.default_branch }} - -Dsonar.branch.name=${{ github.ref_name }} + -Dsonar.branch.name=${{ steps.branch-name.outputs.current_branch }} From a1b489d45a991f0bac2f2ccd0e4f1c9a8e88cb0c Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 22:41:49 -0400 Subject: [PATCH 21/83] sonar on push --- .github/workflows/sonar.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 59f182d13b..685f66720a 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -59,3 +59,9 @@ jobs: 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 branch: ${{ steps.branch-name.outputs.current_branch }}/" + env: + GH_TOKEN: ${{ github.token }} From a1eee5d6821d200edeab98392909816515deeca3 Mon Sep 17 00:00:00 2001 From: TomConner Date: Thu, 20 Jul 2023 11:06:11 -0400 Subject: [PATCH 22/83] sonar in Java CI Signed-off-by: Tom Conner --- .github/workflows/java-ci.yml | 3 +++ api-admin/build.gradle | 2 +- api-participant/build.gradle | 2 +- buildSrc/build.gradle | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/java-ci.yml b/.github/workflows/java-ci.yml index 218296b127..b16bbc0459 100644 --- a/.github/workflows/java-ci.yml +++ b/.github/workflows/java-ci.yml @@ -54,6 +54,9 @@ jobs: uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 with: arguments: build sonar --info # if you need to see test failure full stacktraces, change this to `build --info` + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Need to uncomment these in follow up PR, The new Trivy and Tag workflows need to exist on the development branch # before the following steps will work diff --git a/api-admin/build.gradle b/api-admin/build.gradle index 603a871ace..287727da55 100644 --- a/api-admin/build.gradle +++ b/api-admin/build.gradle @@ -66,7 +66,7 @@ test { useJUnitPlatform () } -sonarqube { +sonar { properties { property 'sonar.projectName', 'terra-java-project-template' property 'sonar.projectKey', 'terra-java-project-template' diff --git a/api-participant/build.gradle b/api-participant/build.gradle index ea56e710c3..ac447b0f31 100644 --- a/api-participant/build.gradle +++ b/api-participant/build.gradle @@ -62,7 +62,7 @@ test { useJUnitPlatform () } -sonarqube { +sonar { properties { property 'sonar.projectName', 'terra-java-project-template' property 'sonar.projectKey', 'terra-java-project-template' 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. From d3313bcdb2cb7178f768202034a2247abf1476a7 Mon Sep 17 00:00:00 2001 From: TomConner Date: Fri, 21 Jul 2023 13:43:51 -0400 Subject: [PATCH 23/83] separate project sonar scans Signed-off-by: Tom Conner --- .github/workflows/java-ci.yml | 2 +- .github/workflows/sonar.yaml | 53 +++++++++++++++++++++++++------ README.md | 29 ++++++++++++----- api-admin/build.gradle | 5 +-- api-participant/build.gradle | 5 +-- populate/build.gradle | 10 ++++++ sonar-project.properties | 8 ----- ui-admin/sonar-project.properties | 6 ++++ 8 files changed, 87 insertions(+), 31 deletions(-) delete mode 100644 sonar-project.properties create mode 100644 ui-admin/sonar-project.properties diff --git a/.github/workflows/java-ci.yml b/.github/workflows/java-ci.yml index b16bbc0459..ed790610ed 100644 --- a/.github/workflows/java-ci.yml +++ b/.github/workflows/java-ci.yml @@ -53,7 +53,7 @@ jobs: - name: Build and SonarQube scan with Gradle uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 with: - arguments: build sonar --info # if you need to see test failure full stacktraces, change this to `build --info` + arguments: build --info # if you need to see test failure full stacktraces, change this to `build --info` env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 09974b0c5e..e5a1031ca7 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -2,23 +2,56 @@ name: Sonar on: workflow_dispatch jobs: - sonar: + # sonar: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + + # - name: Set up JDK + # uses: actions/setup-java@v3 + # with: + # java-version: '17' + # distribution: 'temurin' + # cache: 'gradle' + + # - name: SonarCloud Scan (Typescript only) + # uses: SonarSource/sonarcloud-github-action@master + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + + # - name: SonarCloud Scan (Java only) + # run: ./gradlew --build-cache compileJava sonar + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + sonar-api-admin: + name: SonarCloud api-admin runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - - name: Set up JDK - uses: actions/setup-java@v3 with: - java-version: '17' - distribution: 'temurin' - cache: 'gradle' + fetch-depth: 0 + - name: Scan api-admin via gradle + run: ./gradlew --build-cache :api-admin:compileJava :api-admin:sonar + 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-ui-admin: + name: SonarCloud ui-admin + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Scan ui-admin 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: ui-admin/ diff --git a/README.md b/README.md index 1fe3ddb85d..ad0aa66f0a 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ DTOs, and populate services. the PopulateCliApp can be used to populate specifi In development, it serves at localhost:8081. Lives in `api-participant` directory ##### Study Manager UI Participant UI is a create-react-app SPA. Lives in `ui-participant` directory. Serves on localhost:3001 in development - + ## Local development @@ -47,7 +47,7 @@ run `./local-dev/run_postgres.sh start` This will start a postgres container with a schema and user configured #### IDE Setup -Open the root folder in IntelliJ. +Open the root folder in IntelliJ. * **server:** @@ -76,15 +76,15 @@ Open the root folder in IntelliJ. * set environment variable: `B2C_POLICY_NAME=B2C_1A_ddp_participant_signup_signin_dev` * set environment variable: `B2C_CHANGE_PASSWORD_POLICY_NAME=B2C_1A_ddp_participant_change_password_dev` * disable launch optimization - - + + ### Running the application #### Admin tool (study manager, population) * API (api-admin module) In intelliJ, you can either run ApiAdminApp (from the api-admin module) directly, or execute the "bootRun" gradle task. In basic development mode, this will only serve the API, not the frontend assets. -To make the application useful, you will want to populate some users and studies. After the admin API is running, +To make the application useful, you will want to populate some users and studies. After the admin API is running, from the root project directory, run ``` ./scripts/populate_portal.sh ourhealth @@ -98,7 +98,7 @@ From the command line: REACT_APP_B2C_TENANT_NAME=ddpdevb2c REACT_APP_B2C_CLIENT_ID=$(vault read -field value secret/dsp/ddp/b2c/dev/application_id) npm -w ui-admin start ``` (note that you can just run `npm -w ui-admin start` if you don't need to test B2C login functionality) -Then go to `localhost:3000` +Then go to `localhost:3000` ##### Participant API (api-participant module) In intelliJ, you can either run ApiParticipantApp (from the api-participant module) directly, or execute the "bootRun" gradle task. @@ -118,9 +118,9 @@ Then go to `sandbox.ourhealth.localhost:3001` (Notice how you need the environment name and portal name as subdomains) -### Feature Development +### Feature Development -#### Adding a new model +#### Adding a new model 1. Create the schema, models, and services 1. Create your POJO model in `core/src/main/java/bio/terra/pearl/core/model`, you will almost certainly want to extend `BaseEntity` @@ -150,3 +150,16 @@ Then go to `sandbox.ourhealth.localhost:3001` #### Adding environment variables Helm charts: https://github.com/broadinstitute/terra-helmfile/tree/master/values/app/d2p/live + + +### SonarCloud code scanning + +Because juniper contains TypeScript projects and Java projects, the scans are run independently +in each project + +Typescript UI subprojects (ui-admin, ui-core, and ui-participant) are scanned using the +SonarCloud GitHub Action. Analysis (SonarCloud +runs the scan on its own and comments back results to PRs). + +Java subprojects (core, client, api-admin, api-participant) are scanned using gradle with the +sonarqube plugin. \ No newline at end of file diff --git a/api-admin/build.gradle b/api-admin/build.gradle index 287727da55..529b310da6 100644 --- a/api-admin/build.gradle +++ b/api-admin/build.gradle @@ -68,8 +68,9 @@ test { sonar { properties { - property 'sonar.projectName', 'terra-java-project-template' - property 'sonar.projectKey', 'terra-java-project-template' + property 'sonar.projectName', 'juniper-api-admin' + property 'sonar.projectKey', 'broadinstitute_juniper-api-admin' + property 'sonar.projectBaseDir', '.' 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 ac447b0f31..25fc808d4e 100644 --- a/api-participant/build.gradle +++ b/api-participant/build.gradle @@ -64,8 +64,9 @@ test { sonar { properties { - property 'sonar.projectName', 'terra-java-project-template' - property 'sonar.projectKey', 'terra-java-project-template' + property 'sonar.projectName', 'juniper-api-participant' + property 'sonar.projectKey', 'broadinstitute_juniper-api-participant' + property 'sonar.projectBaseDir', '.' property 'sonar.organization', 'broad-databiosphere' property 'sonar.host.url', 'https://sonarcloud.io' } diff --git a/populate/build.gradle b/populate/build.gradle index 958e9d0192..a1bd2db72f 100644 --- a/populate/build.gradle +++ b/populate/build.gradle @@ -1,6 +1,7 @@ plugins { id "io.freefair.lombok" version "5.3.3.3" id 'java' + id 'org.sonarqube' } group = 'bio.terra.pearl.core' @@ -36,3 +37,12 @@ test { useJUnitPlatform () } +sonar { + properties { + property 'sonar.projectName', 'juniper-populate' + property 'sonar.projectKey', 'broadinstitute_juniper-populate' + property 'sonar.projectBaseDir', '.' + property 'sonar.organization', 'broad-databiosphere' + property 'sonar.host.url', 'https://sonarcloud.io' + } +} 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..6d4dc573ef --- /dev/null +++ b/ui-admin/sonar-project.properties @@ -0,0 +1,6 @@ +sonar.projectName=juniper-ui-admin +sonar.projectKey=broadinstitute_juniper-ui-admin +sonar.organization=dsp-appsec +sonar.sourceEncoding=UTF-8 + +# TODO sonar.coverage.jacoco.xmlReportPaths \ No newline at end of file From 6019c524728db740899c6ff5b483ff7075eece94 Mon Sep 17 00:00:00 2001 From: TomConner Date: Fri, 21 Jul 2023 14:01:35 -0400 Subject: [PATCH 24/83] sonar-project.properties at root Signed-off-by: Tom Conner --- .../sonar-project.properties => sonar-project.properties | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename ui-admin/sonar-project.properties => sonar-project.properties (50%) diff --git a/ui-admin/sonar-project.properties b/sonar-project.properties similarity index 50% rename from ui-admin/sonar-project.properties rename to sonar-project.properties index 6d4dc573ef..cb8e1d2a1b 100644 --- a/ui-admin/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,7 @@ -sonar.projectName=juniper-ui-admin -sonar.projectKey=broadinstitute_juniper-ui-admin +sonar.projectName=juniper-ui +sonar.projectKey=broadinstitute_juniper sonar.organization=dsp-appsec +sonar.sources=ui-admin,ui-core sonar.sourceEncoding=UTF-8 # TODO sonar.coverage.jacoco.xmlReportPaths \ No newline at end of file From 69126f498c25dd493f0189d57ac823e6103b9e7f Mon Sep 17 00:00:00 2001 From: TomConner Date: Fri, 21 Jul 2023 14:12:27 -0400 Subject: [PATCH 25/83] combine all java and combine all typescript Signed-off-by: Tom Conner --- .github/workflows/java-ci.yml | 14 +++++++------- .github/workflows/sonar.yaml | 16 +++++++--------- .github/workflows/ui-ci.yml | 13 +++++++------ 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/.github/workflows/java-ci.yml b/.github/workflows/java-ci.yml index ed790610ed..2244d35040 100644 --- a/.github/workflows/java-ci.yml +++ b/.github/workflows/java-ci.yml @@ -12,12 +12,13 @@ name: Java CI on: - push: - branches: [ development ] - paths-ignore: [ '*.md'] - pull_request: - branches: [ '**' ] - merge_group: + # push: + # branches: [ development ] + # paths-ignore: [ '*.md'] + # pull_request: + # branches: [ '**' ] + # merge_group: + workflow_dispatch: jobs: build: @@ -56,7 +57,6 @@ jobs: arguments: build --info # if you need to see test failure full stacktraces, change this to `build --info` env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Need to uncomment these in follow up PR, The new Trivy and Tag workflows need to exist on the development branch # before the following steps will work diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index e5a1031ca7..4f7c0ab443 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -27,31 +27,29 @@ jobs: # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - sonar-api-admin: - name: SonarCloud api-admin + sonar-java: + name: SonarCloud Java runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Scan api-admin via gradle - run: ./gradlew --build-cache :api-admin:compileJava :api-admin:sonar + - name: Scan via gradle + run: ./gradlew --build-cache compileJava sonar env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - sonar-ui-admin: - name: SonarCloud ui-admin + sonar-typescript: + name: SonarCloud TypeScript runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Scan ui-admin via sonarcloud-github-action + - name: Scan 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: ui-admin/ diff --git a/.github/workflows/ui-ci.yml b/.github/workflows/ui-ci.yml index 876acbbb55..6c45e49525 100644 --- a/.github/workflows/ui-ci.yml +++ b/.github/workflows/ui-ci.yml @@ -1,12 +1,13 @@ name: UI CI on: - push: - branches: [ development ] - paths-ignore: [ '*.md'] - pull_request: - branches: [ '**' ] - merge_group: + # push: + # branches: [ development ] + # paths-ignore: [ '*.md'] + # pull_request: + # branches: [ '**' ] + # merge_group: + workflow_dispatch: jobs: build: From 6b6cff1e8dfaf051000dcc277b3f6c1257d30ba9 Mon Sep 17 00:00:00 2001 From: TomConner Date: Fri, 21 Jul 2023 14:17:18 -0400 Subject: [PATCH 26/83] sonar typescript Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 4f7c0ab443..3549fb1599 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -40,16 +40,18 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - sonar-typescript: - name: SonarCloud TypeScript + sonar-ui-admin: + name: SonarCloud ui-admin runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Scan via sonarcloud-github-action + - name: Scan ui-admin 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: ui-admin/ + From cc8dbba2b7f0355206f6791a94110404ae4ce42f Mon Sep 17 00:00:00 2001 From: TomConner Date: Fri, 21 Jul 2023 14:46:16 -0400 Subject: [PATCH 27/83] sonar args in workflow Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 55 ++++++++++++++++++++---------------- sonar-project.properties | 7 ----- 2 files changed, 30 insertions(+), 32 deletions(-) delete mode 100644 sonar-project.properties diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 3549fb1599..eba95fb335 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -2,31 +2,6 @@ name: Sonar on: workflow_dispatch jobs: - # sonar: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - - # - name: Set up JDK - # uses: actions/setup-java@v3 - # with: - # java-version: '17' - # distribution: 'temurin' - # cache: 'gradle' - - # - name: SonarCloud Scan (Typescript only) - # uses: SonarSource/sonarcloud-github-action@master - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - - # - name: SonarCloud Scan (Java only) - # run: ./gradlew --build-cache compileJava sonar - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - sonar-java: name: SonarCloud Java runs-on: ubuntu-latest @@ -54,4 +29,34 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} with: projectBaseDir: ui-admin/ + args: > + -Dsonar.projectName=juniper-ui-admin + -Dsonar.organization=dsp-appsec + -Dsonar.projectKey=broadinstitute_juniper-ui-admin + -Dsonar.verbose=true + + # sonar: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + + # - name: Set up JDK + # uses: actions/setup-java@v3 + # with: + # java-version: '17' + # distribution: 'temurin' + # cache: 'gradle' + + # - name: SonarCloud Scan (Typescript only) + # uses: SonarSource/sonarcloud-github-action@master + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + + # - name: SonarCloud Scan (Java only) + # run: ./gradlew --build-cache compileJava sonar + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/sonar-project.properties b/sonar-project.properties deleted file mode 100644 index cb8e1d2a1b..0000000000 --- a/sonar-project.properties +++ /dev/null @@ -1,7 +0,0 @@ -sonar.projectName=juniper-ui -sonar.projectKey=broadinstitute_juniper -sonar.organization=dsp-appsec -sonar.sources=ui-admin,ui-core -sonar.sourceEncoding=UTF-8 - -# TODO sonar.coverage.jacoco.xmlReportPaths \ No newline at end of file From c0aab52651d61552eca49abfc5bba763d6eefc87 Mon Sep 17 00:00:00 2001 From: TomConner Date: Fri, 21 Jul 2023 14:49:14 -0400 Subject: [PATCH 28/83] sonarscanner Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index eba95fb335..6dc83c5629 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -30,9 +30,9 @@ jobs: with: projectBaseDir: ui-admin/ args: > - -Dsonar.projectName=juniper-ui-admin + -Dsonar.projectName=juniper -Dsonar.organization=dsp-appsec - -Dsonar.projectKey=broadinstitute_juniper-ui-admin + -Dsonar.projectKey=broadinstitute_juniper -Dsonar.verbose=true # sonar: From 3fd955923ebe9ccbf104156ab04de265e19ebdd6 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 13:35:39 -0400 Subject: [PATCH 29/83] work in progress Signed-off-by: Tom Conner --- .gitignore | 3 +++ api-admin/build.gradle | 11 ----------- api-participant/build.gradle | 1 - build.gradle | 14 ++++++++++++++ client/build.gradle | 11 +++++++++++ core/build.gradle | 10 ++++++++++ integration/build.gradle | 11 +++++++++++ settings.gradle | 2 +- 8 files changed, 50 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 19ae5a13e1..b06543d7b0 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,6 @@ npm-debug.log* .scannerwork .sonar-token tmp/ + +# direnv +.envrc diff --git a/api-admin/build.gradle b/api-admin/build.gradle index 529b310da6..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,13 +64,3 @@ jibDockerBuild.dependsOn('copyWebApp') test { useJUnitPlatform () } - -sonar { - properties { - property 'sonar.projectName', 'juniper-api-admin' - property 'sonar.projectKey', 'broadinstitute_juniper-api-admin' - property 'sonar.projectBaseDir', '.' - 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 25fc808d4e..b4f1353c4a 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' } diff --git a/build.gradle b/build.gradle index cde2107918..f950171b13 100644 --- a/build.gradle +++ b/build.gradle @@ -16,3 +16,17 @@ task bundleAdminUI(type: NpmTask, dependsOn: [npmInstall, buildUICore]) { task bundleParticipantUI(type: NpmTask, dependsOn: [npmInstall, buildUICore]) { args = ['--workspace=ui-participant', 'run', 'build'] } + +subprojects { + apply plugin: 'org.sonarqube' + + sonar { + properties { + property 'sonar.projectName', "${rootProject.name}-${project.name}" + property 'sonar.projectKey', "broadinstitute_${rootProject.name}-${project.name}" + property 'sonar.projectBaseDir', "${projectDir}" + property 'sonar.organization', 'broad-databiosphere' + property 'sonar.host.url', 'https://sonarcloud.io' + } + } +} diff --git a/client/build.gradle b/client/build.gradle index 1ed4a117bd..c474db7905 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -6,6 +6,7 @@ plugins { id 'io.spring.dependency-management' id 'com.jfrog.artifactory' version '4.18.2' id 'org.hidetake.swagger.generator' + id 'org.sonarqube' } dependencyManagement { @@ -16,3 +17,13 @@ dependencyManagement { apply from: 'artifactory.gradle' apply from: 'swagger.gradle' + +sonar { + properties { + property 'sonar.projectName', 'juniper-client' + property 'sonar.projectKey', 'broadinstitute_juniper-client' + property 'sonar.projectBaseDir', '.' + property 'sonar.organization', 'broad-databiosphere' + property 'sonar.host.url', 'https://sonarcloud.io' + } +} diff --git a/core/build.gradle b/core/build.gradle index ca2ff9dfa0..8f449f8e5c 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -3,6 +3,7 @@ plugins { id 'java' id 'org.liquibase.gradle' version '2.1.0' id "java-test-fixtures" + id 'org.sonarqube' } group = 'bio.terra.pearl.core' @@ -56,3 +57,12 @@ test { useJUnitPlatform () } +sonar { + properties { + property 'sonar.projectName', 'juniper-core' + property 'sonar.projectKey', 'broadinstitute_juniper-core' + property 'sonar.projectBaseDir', '.' + property 'sonar.organization', 'broad-databiosphere' + property 'sonar.host.url', 'https://sonarcloud.io' + } +} diff --git a/integration/build.gradle b/integration/build.gradle index e658872b51..2c8110abea 100644 --- a/integration/build.gradle +++ b/integration/build.gradle @@ -4,6 +4,7 @@ plugins { id 'bio.terra.java-application-conventions' id 'io.spring.dependency-management' id 'bio.terra.test-runner-plugin' + id 'org.sonarqube' } dependencyManagement { @@ -29,3 +30,13 @@ dependencies { // Requires client libraries implementation project(':client') } + +sonar { + properties { + property 'sonar.projectName', 'juniper-integration' + property 'sonar.projectKey', 'broadinstitute_juniper-integration' + property 'sonar.projectBaseDir', '.' + property 'sonar.organization', 'broad-databiosphere' + property 'sonar.host.url', 'https://sonarcloud.io' + } +} 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' From 24d44e675e11074697db455a3cfd5e7f3c03d765 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 17:15:00 -0400 Subject: [PATCH 30/83] multiproject sonar Signed-off-by: Tom Conner --- .gitignore | 3 +++ api-participant/build.gradle | 10 ---------- build.gradle | 5 ++--- client/build.gradle | 11 ----------- core/build.gradle | 11 ----------- integration/build.gradle | 11 ----------- populate/build.gradle | 11 ----------- 7 files changed, 5 insertions(+), 57 deletions(-) diff --git a/.gitignore b/.gitignore index b06543d7b0..af6569d321 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ tmp/ # direnv .envrc + +*.hprof + diff --git a/api-participant/build.gradle b/api-participant/build.gradle index b4f1353c4a..c4cce86100 100644 --- a/api-participant/build.gradle +++ b/api-participant/build.gradle @@ -60,13 +60,3 @@ jibDockerBuild.dependsOn('copyWebApp') test { useJUnitPlatform () } - -sonar { - properties { - property 'sonar.projectName', 'juniper-api-participant' - property 'sonar.projectKey', 'broadinstitute_juniper-api-participant' - property 'sonar.projectBaseDir', '.' - property 'sonar.organization', 'broad-databiosphere' - property 'sonar.host.url', 'https://sonarcloud.io' - } -} diff --git a/build.gradle b/build.gradle index f950171b13..af5012bec4 100644 --- a/build.gradle +++ b/build.gradle @@ -17,15 +17,14 @@ task bundleParticipantUI(type: NpmTask, dependsOn: [npmInstall, buildUICore]) { args = ['--workspace=ui-participant', 'run', 'build'] } +apply plugin: 'org.sonarqube' subprojects { - apply plugin: 'org.sonarqube' - sonar { properties { property 'sonar.projectName', "${rootProject.name}-${project.name}" property 'sonar.projectKey', "broadinstitute_${rootProject.name}-${project.name}" property 'sonar.projectBaseDir', "${projectDir}" - property 'sonar.organization', 'broad-databiosphere' + property 'sonar.organization', 'dsp-appsec' property 'sonar.host.url', 'https://sonarcloud.io' } } diff --git a/client/build.gradle b/client/build.gradle index c474db7905..1ed4a117bd 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -6,7 +6,6 @@ plugins { id 'io.spring.dependency-management' id 'com.jfrog.artifactory' version '4.18.2' id 'org.hidetake.swagger.generator' - id 'org.sonarqube' } dependencyManagement { @@ -17,13 +16,3 @@ dependencyManagement { apply from: 'artifactory.gradle' apply from: 'swagger.gradle' - -sonar { - properties { - property 'sonar.projectName', 'juniper-client' - property 'sonar.projectKey', 'broadinstitute_juniper-client' - property 'sonar.projectBaseDir', '.' - property 'sonar.organization', 'broad-databiosphere' - property 'sonar.host.url', 'https://sonarcloud.io' - } -} diff --git a/core/build.gradle b/core/build.gradle index 8f449f8e5c..40f7c6a14f 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -3,7 +3,6 @@ plugins { id 'java' id 'org.liquibase.gradle' version '2.1.0' id "java-test-fixtures" - id 'org.sonarqube' } group = 'bio.terra.pearl.core' @@ -56,13 +55,3 @@ dependencies { test { useJUnitPlatform () } - -sonar { - properties { - property 'sonar.projectName', 'juniper-core' - property 'sonar.projectKey', 'broadinstitute_juniper-core' - property 'sonar.projectBaseDir', '.' - property 'sonar.organization', 'broad-databiosphere' - property 'sonar.host.url', 'https://sonarcloud.io' - } -} diff --git a/integration/build.gradle b/integration/build.gradle index 2c8110abea..e658872b51 100644 --- a/integration/build.gradle +++ b/integration/build.gradle @@ -4,7 +4,6 @@ plugins { id 'bio.terra.java-application-conventions' id 'io.spring.dependency-management' id 'bio.terra.test-runner-plugin' - id 'org.sonarqube' } dependencyManagement { @@ -30,13 +29,3 @@ dependencies { // Requires client libraries implementation project(':client') } - -sonar { - properties { - property 'sonar.projectName', 'juniper-integration' - property 'sonar.projectKey', 'broadinstitute_juniper-integration' - property 'sonar.projectBaseDir', '.' - property 'sonar.organization', 'broad-databiosphere' - property 'sonar.host.url', 'https://sonarcloud.io' - } -} diff --git a/populate/build.gradle b/populate/build.gradle index a1bd2db72f..fa651fa441 100644 --- a/populate/build.gradle +++ b/populate/build.gradle @@ -1,7 +1,6 @@ plugins { id "io.freefair.lombok" version "5.3.3.3" id 'java' - id 'org.sonarqube' } group = 'bio.terra.pearl.core' @@ -36,13 +35,3 @@ dependencies { test { useJUnitPlatform () } - -sonar { - properties { - property 'sonar.projectName', 'juniper-populate' - property 'sonar.projectKey', 'broadinstitute_juniper-populate' - property 'sonar.projectBaseDir', '.' - property 'sonar.organization', 'broad-databiosphere' - property 'sonar.host.url', 'https://sonarcloud.io' - } -} From f8e4d1f827c6ecf2435a415785074eff6bfe031d Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 17:43:31 -0400 Subject: [PATCH 31/83] gradle sonar on single bound project Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 48 +----------------------------------- build.gradle | 20 +++++++-------- 2 files changed, 11 insertions(+), 57 deletions(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 6dc83c5629..8c025de952 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -10,53 +10,7 @@ jobs: with: fetch-depth: 0 - name: Scan via gradle - run: ./gradlew --build-cache compileJava sonar + run: ./gradlew --build-cache compileJava sonar -info env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - sonar-ui-admin: - name: SonarCloud ui-admin - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Scan ui-admin 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: ui-admin/ - args: > - -Dsonar.projectName=juniper - -Dsonar.organization=dsp-appsec - -Dsonar.projectKey=broadinstitute_juniper - -Dsonar.verbose=true - - # sonar: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - - # - name: Set up JDK - # uses: actions/setup-java@v3 - # with: - # java-version: '17' - # distribution: 'temurin' - # cache: 'gradle' - - # - name: SonarCloud Scan (Typescript only) - # uses: SonarSource/sonarcloud-github-action@master - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - - # - name: SonarCloud Scan (Java only) - # run: ./gradlew --build-cache compileJava sonar - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - diff --git a/build.gradle b/build.gradle index af5012bec4..a8c29338d9 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' @@ -17,15 +18,14 @@ task bundleParticipantUI(type: NpmTask, dependsOn: [npmInstall, buildUICore]) { args = ['--workspace=ui-participant', 'run', 'build'] } -apply plugin: 'org.sonarqube' -subprojects { - sonar { - properties { - property 'sonar.projectName', "${rootProject.name}-${project.name}" - property 'sonar.projectKey', "broadinstitute_${rootProject.name}-${project.name}" - property 'sonar.projectBaseDir', "${projectDir}" - property 'sonar.organization', 'dsp-appsec' - property 'sonar.host.url', 'https://sonarcloud.io' - } +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' +} From 25e12fec91f9218aa746eba8c729aaf8e9c61b98 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 19:10:59 -0400 Subject: [PATCH 32/83] exclude spotless Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 8c025de952..bd3e6fe13e 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -10,7 +10,16 @@ jobs: with: fetch-depth: 0 - name: Scan via gradle - run: ./gradlew --build-cache compileJava sonar -info + 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 }} From 14c05f11c904f8aa64fdadced3605b3b867d71d2 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 19:37:34 -0400 Subject: [PATCH 33/83] include resources in sonar Signed-off-by: Tom Conner --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index a8c29338d9..4fa3c22c7c 100644 --- a/build.gradle +++ b/build.gradle @@ -24,6 +24,7 @@ sonar { property 'sonar.projectKey', "broadinstitute_${rootProject.name}" property 'sonar.organization', 'dsp-appsec' property 'sonar.host.url', 'https://sonarcloud.io' + property 'sonar.sources', 'src/main/java,src/main/resources' } } subprojects { From 166fba7a7916abc49e07d39da9021b9e11a21141 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 19:48:49 -0400 Subject: [PATCH 34/83] include resources in sonar Signed-off-by: Tom Conner --- build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 4fa3c22c7c..bdbcfae5b3 100644 --- a/build.gradle +++ b/build.gradle @@ -24,9 +24,11 @@ sonar { property 'sonar.projectKey', "broadinstitute_${rootProject.name}" property 'sonar.organization', 'dsp-appsec' property 'sonar.host.url', 'https://sonarcloud.io' - property 'sonar.sources', 'src/main/java,src/main/resources' } } subprojects { apply plugin: 'org.sonarqube' + sonar { + property 'sonar.sources', 'src/main/java,src/main/resources' + } } From 11de4de2a8f56b4db2637d151ad9707b0ba49fb7 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 20:57:55 -0400 Subject: [PATCH 35/83] resources Signed-off-by: Tom Conner --- build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index bdbcfae5b3..34deabf251 100644 --- a/build.gradle +++ b/build.gradle @@ -29,6 +29,8 @@ sonar { subprojects { apply plugin: 'org.sonarqube' sonar { - property 'sonar.sources', 'src/main/java,src/main/resources' + properties { + property 'sonar.sources', 'src/main/java,src/main/resources' + } } } From bf92e878a4d9297a9ec44bf5127cb5fe9cbb431e Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 21:19:33 -0400 Subject: [PATCH 36/83] gha sonar Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index bd3e6fe13e..47b278d506 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -9,6 +9,23 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + - 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: Scan via gradle run: >- ./gradlew @@ -23,3 +40,28 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + + sonar-typescript: + name: SonarCloud ui-admin + runs-on: ubuntu-latest + strategy: + matrix: + subproject: ['ui-admin', 'ui-participant'] + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - 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.projectName=juniper-${{ matrix.subproject }} + -Dsonar.organization=dsp-appsec + -Dsonar.projectKey=broadinstitute_juniper-${{ matrix.subproject }} + -Dsonar.verbose=true From 5389f6c5a51b34c013958d01f6950670606996b7 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 21:33:57 -0400 Subject: [PATCH 37/83] gha Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 18 +----------------- ui-admin/sonar-project.properties | 13 +++++++++++++ ui-participant/sonar-project.properties | 13 +++++++++++++ 3 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 ui-admin/sonar-project.properties create mode 100644 ui-participant/sonar-project.properties diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 47b278d506..09d23b930d 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -14,18 +14,6 @@ jobs: with: java-version: '17' distribution: 'adopt' - - 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: Scan via gradle run: >- ./gradlew @@ -43,12 +31,11 @@ jobs: sonar-typescript: - name: SonarCloud ui-admin + name: SonarCloud TypeScript runs-on: ubuntu-latest strategy: matrix: subproject: ['ui-admin', 'ui-participant'] - steps: - uses: actions/checkout@v3 with: @@ -61,7 +48,4 @@ jobs: with: projectBaseDir: ${{ github.workspace }}/${{ matrix.subproject }} args: > - -Dsonar.projectName=juniper-${{ matrix.subproject }} - -Dsonar.organization=dsp-appsec - -Dsonar.projectKey=broadinstitute_juniper-${{ matrix.subproject }} -Dsonar.verbose=true diff --git a/ui-admin/sonar-project.properties b/ui-admin/sonar-project.properties new file mode 100644 index 0000000000..0ed872c811 --- /dev/null +++ b/ui-admin/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.projectKey=broadinstitute_juniper-ui-admin +sonar.organization=dsp-appsec + +# This is the name and version displayed in the SonarCloud UI. +sonar.projectName=juniper-ui-admin +#sonar.projectVersion=1.0 + + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 diff --git a/ui-participant/sonar-project.properties b/ui-participant/sonar-project.properties new file mode 100644 index 0000000000..d4d36496c4 --- /dev/null +++ b/ui-participant/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.projectKey=broadinstitute_juniper-ui-participant +sonar.organization=dsp-appsec + +# This is the name and version displayed in the SonarCloud UI. +sonar.projectName=juniper-ui-participant +#sonar.projectVersion=1.0 + + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 From ec0775cc971305a2e26a7c0b7d63c10e67130334 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 22:10:34 -0400 Subject: [PATCH 38/83] typescript sonar specify branch Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 8 +++++++- ui-admin/sonar-project.properties | 10 ---------- ui-participant/sonar-project.properties | 10 ---------- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 09d23b930d..da58be83fc 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -1,5 +1,10 @@ name: Sonar on: workflow_dispatch + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] jobs: sonar-java: @@ -48,4 +53,5 @@ jobs: with: projectBaseDir: ${{ github.workspace }}/${{ matrix.subproject }} args: > - -Dsonar.verbose=true + -Dsonar.branch.target=${{ github.event.repository.default_branch }} + -Dsonar.branch.name=${{ github.ref_name }} diff --git a/ui-admin/sonar-project.properties b/ui-admin/sonar-project.properties index 0ed872c811..2b785ca773 100644 --- a/ui-admin/sonar-project.properties +++ b/ui-admin/sonar-project.properties @@ -1,13 +1,3 @@ sonar.projectKey=broadinstitute_juniper-ui-admin sonar.organization=dsp-appsec - -# This is the name and version displayed in the SonarCloud UI. sonar.projectName=juniper-ui-admin -#sonar.projectVersion=1.0 - - -# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -#sonar.sources=. - -# Encoding of the source code. Default is default system encoding -#sonar.sourceEncoding=UTF-8 diff --git a/ui-participant/sonar-project.properties b/ui-participant/sonar-project.properties index d4d36496c4..1d55561464 100644 --- a/ui-participant/sonar-project.properties +++ b/ui-participant/sonar-project.properties @@ -1,13 +1,3 @@ sonar.projectKey=broadinstitute_juniper-ui-participant sonar.organization=dsp-appsec - -# This is the name and version displayed in the SonarCloud UI. sonar.projectName=juniper-ui-participant -#sonar.projectVersion=1.0 - - -# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -#sonar.sources=. - -# Encoding of the source code. Default is default system encoding -#sonar.sourceEncoding=UTF-8 From e240fc75f1b7be1d8296b65fac37e01828a3aa58 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 22:13:58 -0400 Subject: [PATCH 39/83] sonar on push Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index da58be83fc..477faa7783 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -1,5 +1,6 @@ name: Sonar -on: workflow_dispatch +on: + workflow_dispatch: push: branches: - master From 5d8f8b7a2701b51117314f8dfbb495971ec45d4e Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 22:26:55 -0400 Subject: [PATCH 40/83] sonar on push Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 477faa7783..59f182d13b 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -46,6 +46,9 @@ jobs: - 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: @@ -55,4 +58,4 @@ jobs: projectBaseDir: ${{ github.workspace }}/${{ matrix.subproject }} args: > -Dsonar.branch.target=${{ github.event.repository.default_branch }} - -Dsonar.branch.name=${{ github.ref_name }} + -Dsonar.branch.name=${{ steps.branch-name.outputs.current_branch }} From 63530f504416087f5429aac087daf260de69e616 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 22:41:49 -0400 Subject: [PATCH 41/83] sonar on push Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 59f182d13b..685f66720a 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -59,3 +59,9 @@ jobs: 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 branch: ${{ steps.branch-name.outputs.current_branch }}/" + env: + GH_TOKEN: ${{ github.token }} From 7a92258e561902abc9b175f8b12f2a60958fb9c3 Mon Sep 17 00:00:00 2001 From: Tom Conner Date: Thu, 27 Jul 2023 21:59:41 -0400 Subject: [PATCH 42/83] announce message Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 685f66720a..29fcd8ef2f 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -62,6 +62,6 @@ jobs: - name: Announce run: | gh pr comment ${{ github.event.pull_request.number }} \ - --body "SonarCloud analyzed branch: ${{ steps.branch-name.outputs.current_branch }}/" + --body "SonarCloud analyzed ${{ matrix.subproject }} on ${{ steps.branch-name.outputs.current_branch }}/" env: GH_TOKEN: ${{ github.token }} From fe33a0c351fc846265582027bac51308e2af5172 Mon Sep 17 00:00:00 2001 From: Tom Conner Date: Thu, 27 Jul 2023 22:31:08 -0400 Subject: [PATCH 43/83] revert --- .github/workflows/java-ci.yml | 17 +++++++---------- .github/workflows/ui-ci.yml | 13 ++++++------- README.md | 29 ++++++++--------------------- 3 files changed, 21 insertions(+), 38 deletions(-) diff --git a/.github/workflows/java-ci.yml b/.github/workflows/java-ci.yml index 2244d35040..96b9df3fab 100644 --- a/.github/workflows/java-ci.yml +++ b/.github/workflows/java-ci.yml @@ -12,13 +12,12 @@ name: Java CI on: - # push: - # branches: [ development ] - # paths-ignore: [ '*.md'] - # pull_request: - # branches: [ '**' ] - # merge_group: - workflow_dispatch: + push: + branches: [ development ] + paths-ignore: [ '*.md'] + pull_request: + branches: [ '**' ] + merge_group: jobs: build: @@ -51,12 +50,10 @@ jobs: distribution: 'adopt' - name: Validate Gradle wrapper uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b - - name: Build and SonarQube scan with Gradle + - name: Build with Gradle uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 with: arguments: build --info # if you need to see test failure full stacktraces, change this to `build --info` - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any # Need to uncomment these in follow up PR, The new Trivy and Tag workflows need to exist on the development branch # before the following steps will work diff --git a/.github/workflows/ui-ci.yml b/.github/workflows/ui-ci.yml index 6c45e49525..876acbbb55 100644 --- a/.github/workflows/ui-ci.yml +++ b/.github/workflows/ui-ci.yml @@ -1,13 +1,12 @@ name: UI CI on: - # push: - # branches: [ development ] - # paths-ignore: [ '*.md'] - # pull_request: - # branches: [ '**' ] - # merge_group: - workflow_dispatch: + push: + branches: [ development ] + paths-ignore: [ '*.md'] + pull_request: + branches: [ '**' ] + merge_group: jobs: build: diff --git a/README.md b/README.md index ad0aa66f0a..1fe3ddb85d 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ DTOs, and populate services. the PopulateCliApp can be used to populate specifi In development, it serves at localhost:8081. Lives in `api-participant` directory ##### Study Manager UI Participant UI is a create-react-app SPA. Lives in `ui-participant` directory. Serves on localhost:3001 in development - + ## Local development @@ -47,7 +47,7 @@ run `./local-dev/run_postgres.sh start` This will start a postgres container with a schema and user configured #### IDE Setup -Open the root folder in IntelliJ. +Open the root folder in IntelliJ. * **server:** @@ -76,15 +76,15 @@ Open the root folder in IntelliJ. * set environment variable: `B2C_POLICY_NAME=B2C_1A_ddp_participant_signup_signin_dev` * set environment variable: `B2C_CHANGE_PASSWORD_POLICY_NAME=B2C_1A_ddp_participant_change_password_dev` * disable launch optimization - - + + ### Running the application #### Admin tool (study manager, population) * API (api-admin module) In intelliJ, you can either run ApiAdminApp (from the api-admin module) directly, or execute the "bootRun" gradle task. In basic development mode, this will only serve the API, not the frontend assets. -To make the application useful, you will want to populate some users and studies. After the admin API is running, +To make the application useful, you will want to populate some users and studies. After the admin API is running, from the root project directory, run ``` ./scripts/populate_portal.sh ourhealth @@ -98,7 +98,7 @@ From the command line: REACT_APP_B2C_TENANT_NAME=ddpdevb2c REACT_APP_B2C_CLIENT_ID=$(vault read -field value secret/dsp/ddp/b2c/dev/application_id) npm -w ui-admin start ``` (note that you can just run `npm -w ui-admin start` if you don't need to test B2C login functionality) -Then go to `localhost:3000` +Then go to `localhost:3000` ##### Participant API (api-participant module) In intelliJ, you can either run ApiParticipantApp (from the api-participant module) directly, or execute the "bootRun" gradle task. @@ -118,9 +118,9 @@ Then go to `sandbox.ourhealth.localhost:3001` (Notice how you need the environment name and portal name as subdomains) -### Feature Development +### Feature Development -#### Adding a new model +#### Adding a new model 1. Create the schema, models, and services 1. Create your POJO model in `core/src/main/java/bio/terra/pearl/core/model`, you will almost certainly want to extend `BaseEntity` @@ -150,16 +150,3 @@ Then go to `sandbox.ourhealth.localhost:3001` #### Adding environment variables Helm charts: https://github.com/broadinstitute/terra-helmfile/tree/master/values/app/d2p/live - - -### SonarCloud code scanning - -Because juniper contains TypeScript projects and Java projects, the scans are run independently -in each project - -Typescript UI subprojects (ui-admin, ui-core, and ui-participant) are scanned using the -SonarCloud GitHub Action. Analysis (SonarCloud -runs the scan on its own and comments back results to PRs). - -Java subprojects (core, client, api-admin, api-participant) are scanned using gradle with the -sonarqube plugin. \ No newline at end of file From 7743265e4f88c77f97ff9f6802e58bd14b85502c Mon Sep 17 00:00:00 2001 From: TomConner Date: Fri, 21 Jul 2023 13:43:51 -0400 Subject: [PATCH 44/83] separate project sonar scans Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 31 ------------------------------- ui-admin/sonar-project.properties | 6 ++++++ 2 files changed, 6 insertions(+), 31 deletions(-) create mode 100644 ui-admin/sonar-project.properties diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 6dc83c5629..b2102f270a 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -29,34 +29,3 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} with: projectBaseDir: ui-admin/ - args: > - -Dsonar.projectName=juniper - -Dsonar.organization=dsp-appsec - -Dsonar.projectKey=broadinstitute_juniper - -Dsonar.verbose=true - - # sonar: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - - # - name: Set up JDK - # uses: actions/setup-java@v3 - # with: - # java-version: '17' - # distribution: 'temurin' - # cache: 'gradle' - - # - name: SonarCloud Scan (Typescript only) - # uses: SonarSource/sonarcloud-github-action@master - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - - # - name: SonarCloud Scan (Java only) - # run: ./gradlew --build-cache compileJava sonar - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - diff --git a/ui-admin/sonar-project.properties b/ui-admin/sonar-project.properties new file mode 100644 index 0000000000..6d4dc573ef --- /dev/null +++ b/ui-admin/sonar-project.properties @@ -0,0 +1,6 @@ +sonar.projectName=juniper-ui-admin +sonar.projectKey=broadinstitute_juniper-ui-admin +sonar.organization=dsp-appsec +sonar.sourceEncoding=UTF-8 + +# TODO sonar.coverage.jacoco.xmlReportPaths \ No newline at end of file From 7d57f7d3931348cc397455621e35ad202c93749d Mon Sep 17 00:00:00 2001 From: TomConner Date: Fri, 21 Jul 2023 14:01:35 -0400 Subject: [PATCH 45/83] sonar-project.properties at root Signed-off-by: Tom Conner --- .../sonar-project.properties => sonar-project.properties | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename ui-admin/sonar-project.properties => sonar-project.properties (50%) diff --git a/ui-admin/sonar-project.properties b/sonar-project.properties similarity index 50% rename from ui-admin/sonar-project.properties rename to sonar-project.properties index 6d4dc573ef..cb8e1d2a1b 100644 --- a/ui-admin/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,7 @@ -sonar.projectName=juniper-ui-admin -sonar.projectKey=broadinstitute_juniper-ui-admin +sonar.projectName=juniper-ui +sonar.projectKey=broadinstitute_juniper sonar.organization=dsp-appsec +sonar.sources=ui-admin,ui-core sonar.sourceEncoding=UTF-8 # TODO sonar.coverage.jacoco.xmlReportPaths \ No newline at end of file From 9a051f7341464cbfdf76639c47164452e023be6b Mon Sep 17 00:00:00 2001 From: TomConner Date: Fri, 21 Jul 2023 14:12:27 -0400 Subject: [PATCH 46/83] combine all java and combine all typescript Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index b2102f270a..6bc9ab529b 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -9,23 +9,24 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Scan via gradle + run: ./gradlew --build-cache compileJava sonar - name: Scan via gradle run: ./gradlew --build-cache compileJava sonar env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - sonar-ui-admin: - name: SonarCloud ui-admin + + sonar-typescript: + name: SonarCloud TypeScript runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Scan ui-admin via sonarcloud-github-action + - name: Scan 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: ui-admin/ From 77927be2bed026dc152397c24ef73550daad6baa Mon Sep 17 00:00:00 2001 From: TomConner Date: Fri, 21 Jul 2023 14:17:18 -0400 Subject: [PATCH 47/83] sonar typescript Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 6bc9ab529b..98e9605599 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -17,16 +17,18 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - sonar-typescript: - name: SonarCloud TypeScript + sonar-ui-admin: + name: SonarCloud ui-admin runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Scan via sonarcloud-github-action + - name: Scan ui-admin 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: ui-admin/ + From 9564e2f76cc078abbedf63f49d319f0c078ef661 Mon Sep 17 00:00:00 2001 From: TomConner Date: Fri, 21 Jul 2023 14:46:16 -0400 Subject: [PATCH 48/83] sonar args in workflow Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 30 ++++++++++++++++++++++++++++++ sonar-project.properties | 7 ------- 2 files changed, 30 insertions(+), 7 deletions(-) delete mode 100644 sonar-project.properties diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 98e9605599..b99aa4095f 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -31,4 +31,34 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} with: projectBaseDir: ui-admin/ + args: > + -Dsonar.projectName=juniper-ui-admin + -Dsonar.organization=dsp-appsec + -Dsonar.projectKey=broadinstitute_juniper-ui-admin + -Dsonar.verbose=true + + # sonar: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + + # - name: Set up JDK + # uses: actions/setup-java@v3 + # with: + # java-version: '17' + # distribution: 'temurin' + # cache: 'gradle' + + # - name: SonarCloud Scan (Typescript only) + # uses: SonarSource/sonarcloud-github-action@master + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + + # - name: SonarCloud Scan (Java only) + # run: ./gradlew --build-cache compileJava sonar + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/sonar-project.properties b/sonar-project.properties deleted file mode 100644 index cb8e1d2a1b..0000000000 --- a/sonar-project.properties +++ /dev/null @@ -1,7 +0,0 @@ -sonar.projectName=juniper-ui -sonar.projectKey=broadinstitute_juniper -sonar.organization=dsp-appsec -sonar.sources=ui-admin,ui-core -sonar.sourceEncoding=UTF-8 - -# TODO sonar.coverage.jacoco.xmlReportPaths \ No newline at end of file From 6e9ce5ce369c9493e5354445259b53baa03a3a8a Mon Sep 17 00:00:00 2001 From: TomConner Date: Fri, 21 Jul 2023 14:49:14 -0400 Subject: [PATCH 49/83] sonarscanner Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index b99aa4095f..dc5b3123cc 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -32,9 +32,9 @@ jobs: with: projectBaseDir: ui-admin/ args: > - -Dsonar.projectName=juniper-ui-admin + -Dsonar.projectName=juniper -Dsonar.organization=dsp-appsec - -Dsonar.projectKey=broadinstitute_juniper-ui-admin + -Dsonar.projectKey=broadinstitute_juniper -Dsonar.verbose=true # sonar: From b26bc64baf2e6388051b173352b2306cbb5a0d35 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 17:15:00 -0400 Subject: [PATCH 50/83] multiproject sonar Signed-off-by: Tom Conner --- .gitignore | 3 +++ api-participant/build.gradle | 10 ---------- build.gradle | 5 ++--- client/build.gradle | 11 ----------- core/build.gradle | 11 ----------- integration/build.gradle | 11 ----------- populate/build.gradle | 11 ----------- 7 files changed, 5 insertions(+), 57 deletions(-) diff --git a/.gitignore b/.gitignore index b06543d7b0..af6569d321 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ tmp/ # direnv .envrc + +*.hprof + diff --git a/api-participant/build.gradle b/api-participant/build.gradle index b4f1353c4a..c4cce86100 100644 --- a/api-participant/build.gradle +++ b/api-participant/build.gradle @@ -60,13 +60,3 @@ jibDockerBuild.dependsOn('copyWebApp') test { useJUnitPlatform () } - -sonar { - properties { - property 'sonar.projectName', 'juniper-api-participant' - property 'sonar.projectKey', 'broadinstitute_juniper-api-participant' - property 'sonar.projectBaseDir', '.' - property 'sonar.organization', 'broad-databiosphere' - property 'sonar.host.url', 'https://sonarcloud.io' - } -} diff --git a/build.gradle b/build.gradle index f950171b13..af5012bec4 100644 --- a/build.gradle +++ b/build.gradle @@ -17,15 +17,14 @@ task bundleParticipantUI(type: NpmTask, dependsOn: [npmInstall, buildUICore]) { args = ['--workspace=ui-participant', 'run', 'build'] } +apply plugin: 'org.sonarqube' subprojects { - apply plugin: 'org.sonarqube' - sonar { properties { property 'sonar.projectName', "${rootProject.name}-${project.name}" property 'sonar.projectKey', "broadinstitute_${rootProject.name}-${project.name}" property 'sonar.projectBaseDir', "${projectDir}" - property 'sonar.organization', 'broad-databiosphere' + property 'sonar.organization', 'dsp-appsec' property 'sonar.host.url', 'https://sonarcloud.io' } } diff --git a/client/build.gradle b/client/build.gradle index c474db7905..1ed4a117bd 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -6,7 +6,6 @@ plugins { id 'io.spring.dependency-management' id 'com.jfrog.artifactory' version '4.18.2' id 'org.hidetake.swagger.generator' - id 'org.sonarqube' } dependencyManagement { @@ -17,13 +16,3 @@ dependencyManagement { apply from: 'artifactory.gradle' apply from: 'swagger.gradle' - -sonar { - properties { - property 'sonar.projectName', 'juniper-client' - property 'sonar.projectKey', 'broadinstitute_juniper-client' - property 'sonar.projectBaseDir', '.' - property 'sonar.organization', 'broad-databiosphere' - property 'sonar.host.url', 'https://sonarcloud.io' - } -} diff --git a/core/build.gradle b/core/build.gradle index 8f449f8e5c..40f7c6a14f 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -3,7 +3,6 @@ plugins { id 'java' id 'org.liquibase.gradle' version '2.1.0' id "java-test-fixtures" - id 'org.sonarqube' } group = 'bio.terra.pearl.core' @@ -56,13 +55,3 @@ dependencies { test { useJUnitPlatform () } - -sonar { - properties { - property 'sonar.projectName', 'juniper-core' - property 'sonar.projectKey', 'broadinstitute_juniper-core' - property 'sonar.projectBaseDir', '.' - property 'sonar.organization', 'broad-databiosphere' - property 'sonar.host.url', 'https://sonarcloud.io' - } -} diff --git a/integration/build.gradle b/integration/build.gradle index 2c8110abea..e658872b51 100644 --- a/integration/build.gradle +++ b/integration/build.gradle @@ -4,7 +4,6 @@ plugins { id 'bio.terra.java-application-conventions' id 'io.spring.dependency-management' id 'bio.terra.test-runner-plugin' - id 'org.sonarqube' } dependencyManagement { @@ -30,13 +29,3 @@ dependencies { // Requires client libraries implementation project(':client') } - -sonar { - properties { - property 'sonar.projectName', 'juniper-integration' - property 'sonar.projectKey', 'broadinstitute_juniper-integration' - property 'sonar.projectBaseDir', '.' - property 'sonar.organization', 'broad-databiosphere' - property 'sonar.host.url', 'https://sonarcloud.io' - } -} diff --git a/populate/build.gradle b/populate/build.gradle index a1bd2db72f..fa651fa441 100644 --- a/populate/build.gradle +++ b/populate/build.gradle @@ -1,7 +1,6 @@ plugins { id "io.freefair.lombok" version "5.3.3.3" id 'java' - id 'org.sonarqube' } group = 'bio.terra.pearl.core' @@ -36,13 +35,3 @@ dependencies { test { useJUnitPlatform () } - -sonar { - properties { - property 'sonar.projectName', 'juniper-populate' - property 'sonar.projectKey', 'broadinstitute_juniper-populate' - property 'sonar.projectBaseDir', '.' - property 'sonar.organization', 'broad-databiosphere' - property 'sonar.host.url', 'https://sonarcloud.io' - } -} From 8f95872b7441e213c7497c6d76a0e9f295dc1081 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 17:43:31 -0400 Subject: [PATCH 51/83] gradle sonar on single bound project Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 50 +----------------------------------- build.gradle | 20 +++++++-------- 2 files changed, 11 insertions(+), 59 deletions(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index dc5b3123cc..8c025de952 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -10,55 +10,7 @@ jobs: with: fetch-depth: 0 - name: Scan via gradle - run: ./gradlew --build-cache compileJava sonar - - name: Scan via gradle - run: ./gradlew --build-cache compileJava sonar + run: ./gradlew --build-cache compileJava sonar -info env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - sonar-ui-admin: - name: SonarCloud ui-admin - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Scan ui-admin 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: ui-admin/ - args: > - -Dsonar.projectName=juniper - -Dsonar.organization=dsp-appsec - -Dsonar.projectKey=broadinstitute_juniper - -Dsonar.verbose=true - - # sonar: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - - # - name: Set up JDK - # uses: actions/setup-java@v3 - # with: - # java-version: '17' - # distribution: 'temurin' - # cache: 'gradle' - - # - name: SonarCloud Scan (Typescript only) - # uses: SonarSource/sonarcloud-github-action@master - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - - # - name: SonarCloud Scan (Java only) - # run: ./gradlew --build-cache compileJava sonar - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - diff --git a/build.gradle b/build.gradle index af5012bec4..a8c29338d9 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' @@ -17,15 +18,14 @@ task bundleParticipantUI(type: NpmTask, dependsOn: [npmInstall, buildUICore]) { args = ['--workspace=ui-participant', 'run', 'build'] } -apply plugin: 'org.sonarqube' -subprojects { - sonar { - properties { - property 'sonar.projectName', "${rootProject.name}-${project.name}" - property 'sonar.projectKey', "broadinstitute_${rootProject.name}-${project.name}" - property 'sonar.projectBaseDir', "${projectDir}" - property 'sonar.organization', 'dsp-appsec' - property 'sonar.host.url', 'https://sonarcloud.io' - } +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' +} From 7139df98d5e1b5b42696552af651ff23d803528b Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 19:10:59 -0400 Subject: [PATCH 52/83] exclude spotless Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 8c025de952..bd3e6fe13e 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -10,7 +10,16 @@ jobs: with: fetch-depth: 0 - name: Scan via gradle - run: ./gradlew --build-cache compileJava sonar -info + 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 }} From 44739e2592f8a1acb7b3e8df197e396e17ab1b25 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 19:37:34 -0400 Subject: [PATCH 53/83] include resources in sonar Signed-off-by: Tom Conner --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index a8c29338d9..4fa3c22c7c 100644 --- a/build.gradle +++ b/build.gradle @@ -24,6 +24,7 @@ sonar { property 'sonar.projectKey', "broadinstitute_${rootProject.name}" property 'sonar.organization', 'dsp-appsec' property 'sonar.host.url', 'https://sonarcloud.io' + property 'sonar.sources', 'src/main/java,src/main/resources' } } subprojects { From 014f93a2b704eb4794f99a9f0481cc8c05cf95db Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 19:48:49 -0400 Subject: [PATCH 54/83] include resources in sonar Signed-off-by: Tom Conner --- build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 4fa3c22c7c..bdbcfae5b3 100644 --- a/build.gradle +++ b/build.gradle @@ -24,9 +24,11 @@ sonar { property 'sonar.projectKey', "broadinstitute_${rootProject.name}" property 'sonar.organization', 'dsp-appsec' property 'sonar.host.url', 'https://sonarcloud.io' - property 'sonar.sources', 'src/main/java,src/main/resources' } } subprojects { apply plugin: 'org.sonarqube' + sonar { + property 'sonar.sources', 'src/main/java,src/main/resources' + } } From 46043ed458bec0d5091514052c1fd7f69c412449 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 20:57:55 -0400 Subject: [PATCH 55/83] resources Signed-off-by: Tom Conner --- build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index bdbcfae5b3..34deabf251 100644 --- a/build.gradle +++ b/build.gradle @@ -29,6 +29,8 @@ sonar { subprojects { apply plugin: 'org.sonarqube' sonar { - property 'sonar.sources', 'src/main/java,src/main/resources' + properties { + property 'sonar.sources', 'src/main/java,src/main/resources' + } } } From a573adbb4211ec91113f49f76e74cff3c49f45d0 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 21:19:33 -0400 Subject: [PATCH 56/83] gha sonar Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index bd3e6fe13e..47b278d506 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -9,6 +9,23 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + - 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: Scan via gradle run: >- ./gradlew @@ -23,3 +40,28 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + + sonar-typescript: + name: SonarCloud ui-admin + runs-on: ubuntu-latest + strategy: + matrix: + subproject: ['ui-admin', 'ui-participant'] + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - 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.projectName=juniper-${{ matrix.subproject }} + -Dsonar.organization=dsp-appsec + -Dsonar.projectKey=broadinstitute_juniper-${{ matrix.subproject }} + -Dsonar.verbose=true From cfe6b3724ad7288352d53715f2493ef70e0bae9d Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 21:33:57 -0400 Subject: [PATCH 57/83] gha Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 18 +----------------- ui-admin/sonar-project.properties | 13 +++++++++++++ ui-participant/sonar-project.properties | 13 +++++++++++++ 3 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 ui-admin/sonar-project.properties create mode 100644 ui-participant/sonar-project.properties diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 47b278d506..09d23b930d 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -14,18 +14,6 @@ jobs: with: java-version: '17' distribution: 'adopt' - - 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: Scan via gradle run: >- ./gradlew @@ -43,12 +31,11 @@ jobs: sonar-typescript: - name: SonarCloud ui-admin + name: SonarCloud TypeScript runs-on: ubuntu-latest strategy: matrix: subproject: ['ui-admin', 'ui-participant'] - steps: - uses: actions/checkout@v3 with: @@ -61,7 +48,4 @@ jobs: with: projectBaseDir: ${{ github.workspace }}/${{ matrix.subproject }} args: > - -Dsonar.projectName=juniper-${{ matrix.subproject }} - -Dsonar.organization=dsp-appsec - -Dsonar.projectKey=broadinstitute_juniper-${{ matrix.subproject }} -Dsonar.verbose=true diff --git a/ui-admin/sonar-project.properties b/ui-admin/sonar-project.properties new file mode 100644 index 0000000000..0ed872c811 --- /dev/null +++ b/ui-admin/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.projectKey=broadinstitute_juniper-ui-admin +sonar.organization=dsp-appsec + +# This is the name and version displayed in the SonarCloud UI. +sonar.projectName=juniper-ui-admin +#sonar.projectVersion=1.0 + + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 diff --git a/ui-participant/sonar-project.properties b/ui-participant/sonar-project.properties new file mode 100644 index 0000000000..d4d36496c4 --- /dev/null +++ b/ui-participant/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.projectKey=broadinstitute_juniper-ui-participant +sonar.organization=dsp-appsec + +# This is the name and version displayed in the SonarCloud UI. +sonar.projectName=juniper-ui-participant +#sonar.projectVersion=1.0 + + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 From 51f0e3fc5cb6029b0647d311e975fa412e0e6f95 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 22:10:34 -0400 Subject: [PATCH 58/83] typescript sonar specify branch Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 8 +++++++- ui-admin/sonar-project.properties | 10 ---------- ui-participant/sonar-project.properties | 10 ---------- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 09d23b930d..da58be83fc 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -1,5 +1,10 @@ name: Sonar on: workflow_dispatch + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] jobs: sonar-java: @@ -48,4 +53,5 @@ jobs: with: projectBaseDir: ${{ github.workspace }}/${{ matrix.subproject }} args: > - -Dsonar.verbose=true + -Dsonar.branch.target=${{ github.event.repository.default_branch }} + -Dsonar.branch.name=${{ github.ref_name }} diff --git a/ui-admin/sonar-project.properties b/ui-admin/sonar-project.properties index 0ed872c811..2b785ca773 100644 --- a/ui-admin/sonar-project.properties +++ b/ui-admin/sonar-project.properties @@ -1,13 +1,3 @@ sonar.projectKey=broadinstitute_juniper-ui-admin sonar.organization=dsp-appsec - -# This is the name and version displayed in the SonarCloud UI. sonar.projectName=juniper-ui-admin -#sonar.projectVersion=1.0 - - -# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -#sonar.sources=. - -# Encoding of the source code. Default is default system encoding -#sonar.sourceEncoding=UTF-8 diff --git a/ui-participant/sonar-project.properties b/ui-participant/sonar-project.properties index d4d36496c4..1d55561464 100644 --- a/ui-participant/sonar-project.properties +++ b/ui-participant/sonar-project.properties @@ -1,13 +1,3 @@ sonar.projectKey=broadinstitute_juniper-ui-participant sonar.organization=dsp-appsec - -# This is the name and version displayed in the SonarCloud UI. sonar.projectName=juniper-ui-participant -#sonar.projectVersion=1.0 - - -# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -#sonar.sources=. - -# Encoding of the source code. Default is default system encoding -#sonar.sourceEncoding=UTF-8 From c49b6125fbebe24875d7d000e70ef110e3ca3966 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 22:13:58 -0400 Subject: [PATCH 59/83] sonar on push Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index da58be83fc..477faa7783 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -1,5 +1,6 @@ name: Sonar -on: workflow_dispatch +on: + workflow_dispatch: push: branches: - master From 8d1492a6cb87402b748b51c325f95b2e0e6f5f3e Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 22:26:55 -0400 Subject: [PATCH 60/83] sonar on push Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 477faa7783..59f182d13b 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -46,6 +46,9 @@ jobs: - 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: @@ -55,4 +58,4 @@ jobs: projectBaseDir: ${{ github.workspace }}/${{ matrix.subproject }} args: > -Dsonar.branch.target=${{ github.event.repository.default_branch }} - -Dsonar.branch.name=${{ github.ref_name }} + -Dsonar.branch.name=${{ steps.branch-name.outputs.current_branch }} From 61b1e54ba483b2882f2fca713a9261faecb76966 Mon Sep 17 00:00:00 2001 From: TomConner Date: Mon, 24 Jul 2023 22:41:49 -0400 Subject: [PATCH 61/83] sonar on push Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 59f182d13b..685f66720a 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -59,3 +59,9 @@ jobs: 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 branch: ${{ steps.branch-name.outputs.current_branch }}/" + env: + GH_TOKEN: ${{ github.token }} From 9d2a5334617e46f076154c9b0c6761192c4fd021 Mon Sep 17 00:00:00 2001 From: Tom Conner Date: Thu, 27 Jul 2023 21:59:41 -0400 Subject: [PATCH 62/83] announce message Signed-off-by: Tom Conner --- .github/workflows/sonar.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 685f66720a..29fcd8ef2f 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -62,6 +62,6 @@ jobs: - name: Announce run: | gh pr comment ${{ github.event.pull_request.number }} \ - --body "SonarCloud analyzed branch: ${{ steps.branch-name.outputs.current_branch }}/" + --body "SonarCloud analyzed ${{ matrix.subproject }} on ${{ steps.branch-name.outputs.current_branch }}/" env: GH_TOKEN: ${{ github.token }} From 9e76718323c80deda9deee219b61a0c183099e46 Mon Sep 17 00:00:00 2001 From: Devon Date: Thu, 20 Jul 2023 13:36:13 -0400 Subject: [PATCH 63/83] [JN-490] avoiding error on dupe mailing list signup (#482) Signed-off-by: Tom Conner --- .../MailingListContactController.java | 9 +++- .../service/MailingListContactExtService.java | 7 +++- .../MailingListContactExtServiceTests.java | 42 +++++++++++++++++++ .../dao/portal/MailingListContactDao.java | 5 +++ .../portal/MailingListContactService.java | 4 ++ 5 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 api-participant/src/test/java/bio/terra/pearl/api/participant/service/MailingListContactExtServiceTests.java diff --git a/api-participant/src/main/java/bio/terra/pearl/api/participant/controller/MailingListContactController.java b/api-participant/src/main/java/bio/terra/pearl/api/participant/controller/MailingListContactController.java index e5529e885b..ec37e72d99 100644 --- a/api-participant/src/main/java/bio/terra/pearl/api/participant/controller/MailingListContactController.java +++ b/api-participant/src/main/java/bio/terra/pearl/api/participant/controller/MailingListContactController.java @@ -32,9 +32,14 @@ public ResponseEntity create( String portalShortcode, String environmentName, MailingListContactDto body) { Optional participantUserOpt = requestUtilService.getUserFromRequest(request); EnvironmentName envName = EnvironmentName.valueOfCaseInsensitive(environmentName); + // do a get or create to avoid leaking information about whether the user has already signed up MailingListContact contact = - mailingListContactExtService.create( + mailingListContactExtService.createOrGet( body.getEmail(), body.getName(), portalShortcode, envName, participantUserOpt); - return ResponseEntity.ok(contact); + // convert to a DTO to avoid leaking when the contact was first created + var dto = new MailingListContactDto(); + dto.setEmail(contact.getEmail()); + dto.setName(contact.getName()); + return ResponseEntity.ok(dto); } } diff --git a/api-participant/src/main/java/bio/terra/pearl/api/participant/service/MailingListContactExtService.java b/api-participant/src/main/java/bio/terra/pearl/api/participant/service/MailingListContactExtService.java index 0c71253716..17cc656857 100644 --- a/api-participant/src/main/java/bio/terra/pearl/api/participant/service/MailingListContactExtService.java +++ b/api-participant/src/main/java/bio/terra/pearl/api/participant/service/MailingListContactExtService.java @@ -25,7 +25,7 @@ public MailingListContactExtService( this.mailingListContactService = mailingListContactService; } - public MailingListContact create( + public MailingListContact createOrGet( String email, String name, String portalShortcode, @@ -33,6 +33,11 @@ public MailingListContact create( Optional userOpt) { // mailing lists are open-access -- no need to auth anything. The user is optional PortalEnvironment portalEnv = portalEnvironmentService.findOne(portalShortcode, envName).get(); + Optional existing = + mailingListContactService.findByPortalEnv(portalEnv.getId(), email); + if (existing.isPresent()) { + return existing.get(); + } MailingListContact contact = MailingListContact.builder() .name(name) diff --git a/api-participant/src/test/java/bio/terra/pearl/api/participant/service/MailingListContactExtServiceTests.java b/api-participant/src/test/java/bio/terra/pearl/api/participant/service/MailingListContactExtServiceTests.java new file mode 100644 index 0000000000..37a1a87af2 --- /dev/null +++ b/api-participant/src/test/java/bio/terra/pearl/api/participant/service/MailingListContactExtServiceTests.java @@ -0,0 +1,42 @@ +package bio.terra.pearl.api.participant.service; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; + +import bio.terra.pearl.api.participant.BaseSpringBootTest; +import bio.terra.pearl.core.factory.DaoTestUtils; +import bio.terra.pearl.core.factory.portal.PortalEnvironmentFactory; +import bio.terra.pearl.core.model.portal.PortalEnvironment; +import bio.terra.pearl.core.service.portal.PortalService; +import java.util.Optional; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; + +public class MailingListContactExtServiceTests extends BaseSpringBootTest { + @Autowired MailingListContactExtService mailingListContactExtService; + @Autowired PortalEnvironmentFactory portalEnvironmentFactory; + @Autowired PortalService portalService; + + @Test + @Transactional + public void testGetOrCreate() { + PortalEnvironment portalEnv = portalEnvironmentFactory.buildPersisted("testMailingListCreate"); + String shortcode = portalService.find(portalEnv.getPortalId()).get().getShortcode(); + var contact = + mailingListContactExtService.createOrGet( + "test1@test.com", + "fakename", + shortcode, + portalEnv.getEnvironmentName(), + Optional.empty()); + DaoTestUtils.assertGeneratedProperties(contact); + + // check you can create again with same info + var contact2 = + mailingListContactExtService.createOrGet( + "test1@test.com", "fakename", shortcode, portalEnv.getEnvironmentName(), null); + DaoTestUtils.assertGeneratedProperties(contact2); + assertThat(contact.getId(), equalTo(contact2.getId())); + } +} diff --git a/core/src/main/java/bio/terra/pearl/core/dao/portal/MailingListContactDao.java b/core/src/main/java/bio/terra/pearl/core/dao/portal/MailingListContactDao.java index ca05f77048..863d0a03c0 100644 --- a/core/src/main/java/bio/terra/pearl/core/dao/portal/MailingListContactDao.java +++ b/core/src/main/java/bio/terra/pearl/core/dao/portal/MailingListContactDao.java @@ -3,6 +3,7 @@ import bio.terra.pearl.core.dao.BaseJdbiDao; import bio.terra.pearl.core.model.portal.MailingListContact; import java.util.List; +import java.util.Optional; import java.util.UUID; import org.jdbi.v3.core.Jdbi; import org.springframework.stereotype.Component; @@ -22,6 +23,10 @@ public List findByPortalEnv(UUID portalEnvId) { return findAllByProperty("portal_environment_id", portalEnvId); } + public Optional findByPortalEnv(UUID portalEnvId, String emailAddress) { + return findByTwoProperties("portal_environment_id", portalEnvId, "email", emailAddress); + } + public void deleteByPortalEnvId(UUID portalEnvId) { deleteByProperty("portal_environment_id", portalEnvId); } diff --git a/core/src/main/java/bio/terra/pearl/core/service/portal/MailingListContactService.java b/core/src/main/java/bio/terra/pearl/core/service/portal/MailingListContactService.java index 25753f2fb5..6b0a362f28 100644 --- a/core/src/main/java/bio/terra/pearl/core/service/portal/MailingListContactService.java +++ b/core/src/main/java/bio/terra/pearl/core/service/portal/MailingListContactService.java @@ -4,6 +4,7 @@ import bio.terra.pearl.core.model.portal.MailingListContact; import bio.terra.pearl.core.service.ImmutableEntityService; import java.util.List; +import java.util.Optional; import java.util.UUID; import org.springframework.stereotype.Service; @@ -16,6 +17,9 @@ public MailingListContactService(MailingListContactDao dao) { public List findByPortalEnv(UUID portalEnvId) { return dao.findByPortalEnv(portalEnvId); } + public Optional findByPortalEnv(UUID portalEnvId, String emailAddress) { + return dao.findByPortalEnv(portalEnvId, emailAddress); + } public void deleteByPortalEnvId(UUID portalEnvId) { dao.deleteByPortalEnvId(portalEnvId); } From e167a3256ccae6924bb4ce16f964eb324279ad64 Mon Sep 17 00:00:00 2001 From: Devon Date: Thu, 20 Jul 2023 13:51:19 -0400 Subject: [PATCH 64/83] [JN-477] admin help for export (#481) Signed-off-by: Tom Conner --- ui-admin/src/App.tsx | 5 +- ui-admin/src/help/ExportHelp.tsx | 115 ++++++++++++++++++ ui-admin/src/help/HelpPage.tsx | 12 ++ ui-admin/src/help/HelpRouter.tsx | 15 +++ .../export/ExportDataControl.test.tsx | 12 +- .../participants/export/ExportDataControl.tsx | 13 +- 6 files changed, 166 insertions(+), 6 deletions(-) create mode 100644 ui-admin/src/help/ExportHelp.tsx create mode 100644 ui-admin/src/help/HelpPage.tsx create mode 100644 ui-admin/src/help/HelpRouter.tsx diff --git a/ui-admin/src/App.tsx b/ui-admin/src/App.tsx index 095dd9d144..ea319ac693 100644 --- a/ui-admin/src/App.tsx +++ b/ui-admin/src/App.tsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react' +import React, { lazy, useContext } from 'react' import 'react-notifications-component/dist/theme.css' import 'styles/notifications.css' import 'survey-core/defaultV2.min.css' @@ -22,6 +22,7 @@ import UserList from './user/UserList' import InvestigatorTermsOfUsePage from './terms/InvestigatorTermsOfUsePage' import PrivacyPolicyPage from 'terms/PrivacyPolicyPage' import { IdleStatusMonitor } from 'login/IdleStatusMonitor' +const HelpRouter = lazy(() => import('./help/HelpRouter')) /** container for the app including the router */ @@ -39,11 +40,13 @@ function App() { }> + } /> }> }/> }/> }/> + } /> } /> Unknown page}/> diff --git a/ui-admin/src/help/ExportHelp.tsx b/ui-admin/src/help/ExportHelp.tsx new file mode 100644 index 0000000000..30802f5db8 --- /dev/null +++ b/ui-admin/src/help/ExportHelp.tsx @@ -0,0 +1,115 @@ +import React from 'react' + +/** guide to using the participant export/download function */ +export default function ExportHelp() { + return
+

Participant List Export Info

+

Participant export enables download of tabular files (.tsv or .xlsx) containing all participants + except those who have withdrawn from the study. + One row will be generated per participant.

+ +

File format

+
+
    +
  • + .xlsx will create an Excel spreadsheet of the participant data. Empty cells will represent + null values. +
  • +
  • + .tsv (tab-delimited values). Will export a tab-delimited file. This may be useful in + environments where Excel is unavailable, or if the + number of columns to be exported exceeds 16K. In order to have data be compliant, double-quotes will + be replaced by single quotes, and any values including + tabs or line breaks will be surrounded in double-quotes. +
  • +
+ + +
+ +

Human readable / Analysis friendly

+
    +
  • + Analysis friendly Each picklist answers will be displayed as a stable id, rather than the + displayed text. For multiselects, each answer option will appear in a separate column. For example, the + question "Which symptoms have you had?" + with options "fever", "nausea", and "persisent cough", + will be exported into 3 columns. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MEDICAL_HISTORY.SYMTPOMS.FEVERMEDICAL_HISTORY.SYMPTOMS.NAUSEAMEDICAL_HISTORY.SYMPTOMS.COUGH
    fevernauseapersistent cough
    010
    110
    000
    + +
  • +
  • + Human readable will use display text where possible, and will show multi-select questions as a + single column, with a comma-delimited string of the answers given. For example, the question "Which + symptoms have you had?" + with options "fever", "nausea", and "persisent cough", + will be exported into 1 column. + + + + + + + + + + + + + + + + + + + + +
    MEDICAL_HISTORY.SYMTPOMS
    symptoms
    nausea
    fever, nausea
    +
  • +
+

Include all completions of an activity

+ This option controls how the export will behave if a participant has completed an activity multiple times. +
    +
  • + Yes A new set of columns will be added to the export for each time the activity was completed. + These will be + denoted by _2, _3, etc... Columns will appear in order of *recency*. So e.g. MEDICAL_HISTORY.SYMPTOMS + represents the + most recent completion, while MEDICAL_HISTORY_2.SYMPTOMS represents the next-most recent, and so on. +
  • +
  • + No Only the most recent completion for each activity will be included in the export. +
  • +
+
+} diff --git a/ui-admin/src/help/HelpPage.tsx b/ui-admin/src/help/HelpPage.tsx new file mode 100644 index 0000000000..31f39f528b --- /dev/null +++ b/ui-admin/src/help/HelpPage.tsx @@ -0,0 +1,12 @@ +import React from 'react' +import { Link } from 'react-router-dom' + +/** shows the root help page. No structure yet */ +export default function HelpPage() { + return
+

Juniper help topics

+
+ Participant export +
+
+} diff --git a/ui-admin/src/help/HelpRouter.tsx b/ui-admin/src/help/HelpRouter.tsx new file mode 100644 index 0000000000..caaaab66ab --- /dev/null +++ b/ui-admin/src/help/HelpRouter.tsx @@ -0,0 +1,15 @@ +import React from 'react' +import { Route, Routes } from 'react-router-dom' +import ExportHelp from './ExportHelp' +import HelpPage from './HelpPage' + +/** routes across individual help pages -- catches any unmatched routes to the main index */ +export default function HelpRouter() { + return
+ + }/> + }/> + }/> + +
+} diff --git a/ui-admin/src/study/participants/export/ExportDataControl.test.tsx b/ui-admin/src/study/participants/export/ExportDataControl.test.tsx index ec245cbe7e..f177289d58 100644 --- a/ui-admin/src/study/participants/export/ExportDataControl.test.tsx +++ b/ui-admin/src/study/participants/export/ExportDataControl.test.tsx @@ -2,8 +2,9 @@ import React from 'react' import { setupRouterTest } from 'test-utils/router-testing-utils' import { mockStudyEnvContext } from 'test-utils/mocking-utils' -import { render, screen } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import ExportDataControl from './ExportDataControl' +import userEvent from '@testing-library/user-event' test('renders the file types', async () => { const { RoutedComponent } = setupRouterTest( @@ -13,3 +14,12 @@ test('renders the file types', async () => { expect(screen.getByText('Tab-delimted (.tsv)')).toBeInTheDocument() expect(screen.getByText('Excel (.xlsx)')).toBeInTheDocument() }) + +test('help page loads', async () => { + const { RoutedComponent } = setupRouterTest( + // eslint-disable-next-line @typescript-eslint/no-empty-function + {}}/>) + render(RoutedComponent) + userEvent.click(screen.getByText('help page')) + waitFor(() => expect(screen.getByText('Participant List Export Info')).toBeInTheDocument()) +}) diff --git a/ui-admin/src/study/participants/export/ExportDataControl.tsx b/ui-admin/src/study/participants/export/ExportDataControl.tsx index 23beedc1f8..fabbd25517 100644 --- a/ui-admin/src/study/participants/export/ExportDataControl.tsx +++ b/ui-admin/src/study/participants/export/ExportDataControl.tsx @@ -6,6 +6,7 @@ import Api from 'api/api' import { currentIsoDate } from 'util/timeUtils' import { failureNotification } from 'util/notifications' import { Store } from 'react-notifications-component' +import { Link } from 'react-router-dom' const FILE_FORMATS = [{ label: 'Tab-delimted (.tsv)', @@ -74,10 +75,9 @@ const ExportDataControl = ({ studyEnvContext, show, setShow }: {studyEnvContext: return setShow(false)}> - Download -
- {studyEnvContext.study.name}: {studyEnvContext.currentEnv.environmentName} -
+ + Download +
e.preventDefault()}> @@ -114,6 +114,11 @@ const ExportDataControl = ({ studyEnvContext, show, setShow }: {studyEnvContext: {format.label} )} +
+
+ For more information about download formats, + see the help page. +
From 277da84244ca17180ff7d45de755ffda2e2195f6 Mon Sep 17 00:00:00 2001 From: Matt Bemis Date: Thu, 27 Jul 2023 15:22:37 -0400 Subject: [PATCH 65/83] [JN-453] Preserve fields when switching question types in new question form (#485) Signed-off-by: Tom Conner --- .../src/forms/designer/NewQuestionForm.tsx | 48 +++---------- .../designer/questions/questionTypes.tsx | 70 ++++++++++++++++++- 2 files changed, 77 insertions(+), 41 deletions(-) diff --git a/ui-admin/src/forms/designer/NewQuestionForm.tsx b/ui-admin/src/forms/designer/NewQuestionForm.tsx index 5140083731..8c657a9e99 100644 --- a/ui-admin/src/forms/designer/NewQuestionForm.tsx +++ b/ui-admin/src/forms/designer/NewQuestionForm.tsx @@ -5,6 +5,8 @@ import { Question, QuestionType } from '@juniper/ui-core' import { Button } from 'components/forms/Button' import { QuestionDesigner } from './QuestionDesigner' import { TextInput } from 'components/forms/TextInput' +import { baseQuestions } from './questions/questionTypes' +import _ from 'lodash' type NewQuestionFormProps = { onCreate: (newQuestion: Question) => void @@ -15,45 +17,9 @@ type NewQuestionFormProps = { export const NewQuestionForm = (props: NewQuestionFormProps) => { const { onCreate, readOnly } = props const [selectedQuestionType, setSelectedQuestionType] = useState('text') - const [questionName, setQuestionName] = useState('') - - const baseQuestions: Record = { - checkbox: { - type: 'checkbox', - name: questionName, - title: '', - choices: [] - }, - dropdown: { - type: 'dropdown', - name: questionName, - title: '', - choices: [] - }, - medications: { - type: 'medications', - name: questionName, - title: '' - }, - radiogroup: { - type: 'radiogroup', - name: questionName, - title: '', - choices: [] - }, - signaturepad: { - type: 'signaturepad', - name: questionName, - title: '' - }, - text: { - type: 'text', - name: questionName, - title: '' - } - } const [question, setQuestion] = useState(baseQuestions[selectedQuestionType]) + const { name: questionName } = question return ( <> @@ -65,7 +31,6 @@ export const NewQuestionForm = (props: NewQuestionFormProps) => { label='Question stable ID' value={questionName} onChange={value => { - setQuestionName(value) setQuestion({ ...question, name: value }) }} /> @@ -75,7 +40,7 @@ export const NewQuestionForm = (props: NewQuestionFormProps) => { onChange={e => { const newQuestionType = e.target.value as QuestionType setSelectedQuestionType(newQuestionType) - setQuestion(baseQuestions[newQuestionType]) + setQuestion({ ...baseQuestions[newQuestionType], ...question, type: newQuestionType } as Question) }}> @@ -98,7 +63,10 @@ export const NewQuestionForm = (props: NewQuestionFormProps) => {