From 586073a5611890d639eadeec85bcdefff6c390f1 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Fri, 19 Aug 2022 12:20:26 -0300 Subject: [PATCH 1/4] change sample version for sonar --- .github/actions/setup/action.yml | 6 ++++++ .github/workflows/angular.yml | 11 ++++++++--- .github/workflows/devserver.yml | 6 ------ .../generator-database-changelog-liquibase.yml | 5 ----- .github/workflows/react.yml | 13 ------------- .github/workflows/vue.yml | 13 ------------- .../common/templates/sonar-project.properties.ejs | 1 - generators/generator-base.js | 1 + generators/server/templates/pom.xml.ejs | 2 +- test-integration/scripts/00-init-env.sh | 3 +++ test-integration/workflow-samples/angular.json | 6 +++--- 11 files changed, 22 insertions(+), 45 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index fe18a31e96ec..dd3c6a383634 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -141,6 +141,12 @@ runs: echo "SPRING_JPA_SHOW_SQL=false" >> $GITHUB_ENV echo "NG_CLI_ANALYTICS=ci" >> $GITHUB_ENV + JHI_PROJECT_VERSION=$JHI_VERSION + if [[ "true" != "{{ startsWith(github.ref, 'refs/tags/v') }}" ]]; then + JHI_PROJECT_VERSION="$JHI_VERSION-git" + fi + echo "JHI_PROJECT_VERSION=$JHI_PROJECT_VERSION" >> $GITHUB_ENV + if [[ "${{inputs.jhipster-bom-branch}}" != "release" && "${{inputs.jhipster-bom-branch}}" != "ignore" ]]; then echo "JHI_BOM_VERSION=0.0.0-CICD" >> $GITHUB_ENV fi diff --git a/.github/workflows/angular.yml b/.github/workflows/angular.yml index cabbcbddf195..f61c0bb22a14 100644 --- a/.github/workflows/angular.yml +++ b/.github/workflows/angular.yml @@ -226,16 +226,21 @@ jobs: uses: jwalton/gh-docker-logs@v2 - name: 'ANALYSIS: Sonar analysis' if: >- + github.repository == 'jhipster/generator-jhipster' && + matrix.sonar-analyse == 'true' && steps.compare.outputs.equals != 'true' && - matrix.sonar-analyse != 'false' && matrix.workspaces != 'true' && matrix.skip-frontend-tests != 1 && needs.build-matrix.outputs.client != 'false' && matrix.skip-backend-tests != 1 && needs.build-matrix.outputs.server != 'false' - run: $JHI_SCRIPTS/25-sonar-analyze.sh + run: | + ./mvnw -ntp --batch-mode initialize org.jacoco:jacoco-maven-plugin:prepare-agent sonar:sonar \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.projectKey=jhipster-sample-application \ + -Dsonar.organization=jhipster \ + -Dsonar.login=$SONAR_TOKEN env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} check-angular: permissions: diff --git a/.github/workflows/devserver.yml b/.github/workflows/devserver.yml index 420702202cf2..993909d6617d 100644 --- a/.github/workflows/devserver.yml +++ b/.github/workflows/devserver.yml @@ -148,12 +148,6 @@ jobs: with: name: screenshots-${{ matrix.app-sample }} path: ${{ steps.setup.outputs.application-path }}/*/cypress/screenshots - - name: 'ANALYSIS: Sonar analysis' - if: steps.compare.outputs.equals != 'true' && matrix.sonar-analyse == 'true' - run: $JHI_SCRIPTS/25-sonar-analyze.sh - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} check-dev-server: permissions: contents: none diff --git a/.github/workflows/generator-database-changelog-liquibase.yml b/.github/workflows/generator-database-changelog-liquibase.yml index 2009897a05f7..b911560f6996 100644 --- a/.github/workflows/generator-database-changelog-liquibase.yml +++ b/.github/workflows/generator-database-changelog-liquibase.yml @@ -145,8 +145,3 @@ jobs: with: name: screenshots-${{ matrix.app-type }} path: ${{ steps.setup.outputs.application-path }}/*/cypress/screenshots - - name: 'ANALYSIS: Sonar analysis' - run: $JHI_SCRIPTS/25-sonar-analyze.sh - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/react.yml b/.github/workflows/react.yml index 8447c3583c1a..b5d7086a9c49 100644 --- a/.github/workflows/react.yml +++ b/.github/workflows/react.yml @@ -224,19 +224,6 @@ jobs: - name: Dump docker logs if: always() uses: jwalton/gh-docker-logs@v2 - - name: 'ANALYSIS: Sonar analysis' - if: >- - steps.compare.outputs.equals != 'true' && - matrix.sonar-analyse != 'false' && - matrix.workspaces != 'true' && - matrix.skip-frontend-tests != 1 && - needs.build-matrix.outputs.client != 'false' && - matrix.skip-backend-tests != 1 && - needs.build-matrix.outputs.server != 'false' - run: $JHI_SCRIPTS/25-sonar-analyze.sh - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} check-react: permissions: contents: none diff --git a/.github/workflows/vue.yml b/.github/workflows/vue.yml index 2aa3f35211ca..559dbc89b3de 100644 --- a/.github/workflows/vue.yml +++ b/.github/workflows/vue.yml @@ -224,19 +224,6 @@ jobs: - name: Dump docker logs if: always() uses: jwalton/gh-docker-logs@v2 - - name: 'ANALYSIS: Sonar analysis' - if: >- - steps.compare.outputs.equals != 'true' && - matrix.sonar-analyse != 'false' && - matrix.workspaces != 'true' && - matrix.skip-frontend-tests != 1 && - needs.build-matrix.outputs.client != 'false' && - matrix.skip-backend-tests != 1 && - needs.build-matrix.outputs.server != 'false' - run: $JHI_SCRIPTS/25-sonar-analyze.sh - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} check-vue: permissions: contents: none diff --git a/generators/common/templates/sonar-project.properties.ejs b/generators/common/templates/sonar-project.properties.ejs index cbd9226ce7bb..1b589b48ef12 100644 --- a/generators/common/templates/sonar-project.properties.ejs +++ b/generators/common/templates/sonar-project.properties.ejs @@ -1,6 +1,5 @@ sonar.projectKey=<%= baseName %> sonar.projectName=<%= baseName %> generated by jhipster -sonar.projectVersion=1.0 sonar.sources=<%= MAIN_DIR %> sonar.host.url=http://localhost:9001 diff --git a/generators/generator-base.js b/generators/generator-base.js index e778d5b2ae24..015c5e21d790 100644 --- a/generators/generator-base.js +++ b/generators/generator-base.js @@ -2917,6 +2917,7 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`; loadAppConfig(config = _.defaults({}, this.jhipsterConfig, this.jhipsterDefaults), dest = this) { dest.jhipsterVersion = config.jhipsterVersion; dest.baseName = config.baseName; + dest.projectVersion = process.env.JHI_PROJECT_VERSION || '0.0.1-SNAPSHOT'; dest.applicationType = config.applicationType; dest.reactive = config.reactive; dest.jhiPrefix = config.jhiPrefix; diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 796fb4df12b8..24dc5b5e33ab 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -25,7 +25,7 @@ <%= packageName %> <%= dasherizedBaseName %> - 0.0.1-SNAPSHOT + <%= projectVersion %> jar <%= humanizedBaseName %> <%= projectDescription %> diff --git a/test-integration/scripts/00-init-env.sh b/test-integration/scripts/00-init-env.sh index 6a24df622b88..05d2125bb05f 100755 --- a/test-integration/scripts/00-init-env.sh +++ b/test-integration/scripts/00-init-env.sh @@ -96,3 +96,6 @@ JHI_NODE_VERSION=$(grep -o "NODE_VERSION = '[^']*'" $JHI_HOME/generators/generat # npm version JHI_NPM_VERSION=$(grep -o '"npm": "[^"]*"' $JHI_HOME/generators/common/templates/package.json | cut -f4 -d '"') + +# generator-jhipster version +JHI_VERSION=$(grep -o '"version": "[^"]*"' $JHI_HOME/package.json | cut -f4 -d '"') diff --git a/test-integration/workflow-samples/angular.json b/test-integration/workflow-samples/angular.json index 8e73cf33c6a9..2421c1054a4d 100644 --- a/test-integration/workflow-samples/angular.json +++ b/test-integration/workflow-samples/angular.json @@ -3,14 +3,14 @@ { "name": "ngx-default", "app-sample": "ngx-default", - "entity": "sqlfull" + "entity": "sqlfull", + "sonar-analyse": "true" }, { "name": "ngx-default-additional", "entity": "none", "app-sample": "ngx-default", - "jdl-entity": "*", - "sonar-analyse": "false" + "jdl-entity": "*" }, { "name": "ngx-mysql-es-noi18n-mapsid", From d1f9ab41e7aa8dcbb0d8be7c6e4897b19796628b Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Fri, 19 Aug 2022 20:15:24 -0300 Subject: [PATCH 2/4] Update angular.yml --- .github/workflows/angular.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/angular.yml b/.github/workflows/angular.yml index f61c0bb22a14..ba3e6834e1b0 100644 --- a/.github/workflows/angular.yml +++ b/.github/workflows/angular.yml @@ -226,6 +226,7 @@ jobs: uses: jwalton/gh-docker-logs@v2 - name: 'ANALYSIS: Sonar analysis' if: >- + secrets.SONAR_TOKEN && github.repository == 'jhipster/generator-jhipster' && matrix.sonar-analyse == 'true' && steps.compare.outputs.equals != 'true' && From d7a90dd4d50e5002e316bec9f9a7e2c4eaf29333 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Fri, 19 Aug 2022 20:18:18 -0300 Subject: [PATCH 3/4] Update angular.yml --- .github/workflows/angular.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/angular.yml b/.github/workflows/angular.yml index ba3e6834e1b0..3ccafeafebc8 100644 --- a/.github/workflows/angular.yml +++ b/.github/workflows/angular.yml @@ -226,7 +226,7 @@ jobs: uses: jwalton/gh-docker-logs@v2 - name: 'ANALYSIS: Sonar analysis' if: >- - secrets.SONAR_TOKEN && + secrets.SONAR_TOKEN != '' && github.repository == 'jhipster/generator-jhipster' && matrix.sonar-analyse == 'true' && steps.compare.outputs.equals != 'true' && From 00ce34f3d06e382080ec304d7c3662b074eb5458 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Fri, 19 Aug 2022 21:25:13 -0300 Subject: [PATCH 4/4] Update angular.yml --- .github/workflows/angular.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/angular.yml b/.github/workflows/angular.yml index 3ccafeafebc8..0dc93b04431b 100644 --- a/.github/workflows/angular.yml +++ b/.github/workflows/angular.yml @@ -226,7 +226,7 @@ jobs: uses: jwalton/gh-docker-logs@v2 - name: 'ANALYSIS: Sonar analysis' if: >- - secrets.SONAR_TOKEN != '' && + github.event_name == 'push' && github.repository == 'jhipster/generator-jhipster' && matrix.sonar-analyse == 'true' && steps.compare.outputs.equals != 'true' &&