From e660faa8a96fba2ae0c4d0bc1209718aa4677bc3 Mon Sep 17 00:00:00 2001 From: svariant <128470180+svariant@users.noreply.github.com> Date: Tue, 31 Oct 2023 10:55:16 +0100 Subject: [PATCH] [PRDP-193] Migrate to java17 (#80) * [PRDP-193] Migrated to java17 * [chore] Updated azure java docker image * [chore] Updated azure java docker image * [PRDP-193] Updated version action code review * [PRDP-193] Updated code review to local version * add ai sampling --------- Co-authored-by: pasqualespica <36746022+pasqualespica@users.noreply.github.com> --- .github/maven_code_review/action.yml | 101 +++++++++++++++++++++++++++ .github/workflows/code_review.yml | 7 +- Dockerfile | 6 +- host.json | 9 ++- pom.xml | 4 +- 5 files changed, 117 insertions(+), 10 deletions(-) create mode 100644 .github/maven_code_review/action.yml diff --git a/.github/maven_code_review/action.yml b/.github/maven_code_review/action.yml new file mode 100644 index 00000000..a2689590 --- /dev/null +++ b/.github/maven_code_review/action.yml @@ -0,0 +1,101 @@ +name: Maven Code Review +description: "Code Review for Pull Request" + +inputs: + github_token: + required: true + type: string + description: Github Token + sonar_token: + required: true + type: string + description: Sonar Token for the login + project_key: + required: true + type: string + description: Key of the project on SonarCloud + coverage_exclusions: + required: false + type: string + description: Files to exclude from coverage + default: '**/config/*,**/*Mock*,**/model/**,**/entity/*' + cpd_exclusions: + required: false + type: string + description: Files to exclude from code duplication + default: '**/model/**,**/entity/*' + jdk_version: + required: true + type: string + description: JDK version + default: 11 + maven_version: + required: true + type: string + description: Maven version + default: 3.8.2 + +runs: + using: "composite" + steps: + - uses: actions/checkout@v2 + + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: ${{ inputs.jdk_version }} + + - name: Set up Maven + uses: stCarolas/setup-maven@v4.5 + with: + maven-version: ${{ inputs.maven_version }} + + - name: Cache Maven packages + uses: actions/cache@v1 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~/.sonar-project.properties/cache + key: ${{ runner.os }}-sonar-project.properties + restore-keys: ${{ runner.os }}-sonar-project.properties + + - name: Build and analyze on Pull Requests + if: ${{ github.event_name == 'pull_request' }} + shell: bash + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar + -Dsonar.organization=pagopa + -Dsonar.projectKey=${{ env.PROJECT_KEY }} + -Dsonar.coverage.jacoco.xmlReportPaths=./target/jacoco-report/jacoco.xml + -Dsonar.coverage.exclusions=${{inputs.coverage_exclusions}} + -Dsonar.cpd.exclusions=${{inputs.cpd_exclusions}} + -Dsonar.host.url=https://sonarcloud.io + -Dsonar.login=${{ inputs.sonar_token }} + -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} + -Dsonar.pullrequest.branch=${{ github.head_ref }} + -Dsonar.pullrequest.base=${{ github.base_ref }} + env: + # Needed to get some information about the pull request, if any + GITHUB_TOKEN: ${{ inputs.github_token }} + # SonarCloud access token should be generated from https://sonarcloud.io/account/security/ + SONAR_TOKEN: ${{ inputs.sonar_token }} + + - name: Build and analyze on Push main + if: ${{ github.event_name != 'pull_request' }} + shell: bash + env: + GITHUB_TOKEN: ${{ inputs.github_token }} + SONAR_TOKEN: ${{ inputs.sonar_token }} + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar + -Dsonar.organization=pagopa + -Dsonar.projectKey=${{ env.PROJECT_KEY }} + -Dsonar.coverage.jacoco.xmlReportPaths=./target/site/jacoco/jacoco.xml + -Dsonar.coverage.exclusions=${{inputs.coverage_exclusions}} + -Dsonar.cpd.exclusions=${{inputs.cpd_exclusions}} + -Dsonar.branch.name=${{ github.head_ref }} + -Dsonar.host.url=https://sonarcloud.io + -Dsonar.login=${{ inputs.sonar_token }} \ No newline at end of file diff --git a/.github/workflows/code_review.yml b/.github/workflows/code_review.yml index 62c19ce4..7d603b0e 100644 --- a/.github/workflows/code_review.yml +++ b/.github/workflows/code_review.yml @@ -33,13 +33,16 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: + - uses: actions/checkout@v2.3.4 - name: Code Review - uses: pagopa/github-actions-template/maven-code-review@v1.4.2 + uses: ./.github/maven_code_review with: github_token: ${{ secrets.GITHUB_TOKEN }} sonar_token: ${{ secrets.SONAR_TOKEN }} project_key: ${{env.PROJECT_KEY}} - coverage_exclusions: "**/config/*,**/*Mock*,**/model/**,**/entity/**" + jdk_version: 17 + maven_version: 3.9.3 + coverage_exclusions: "**/config/*,**/*Mock*,**/model/**,**/entity/*,**/producer/**,**/enumeration/**" cpd_exclusions: "**/model/**,**/entity/*" smoke-test: diff --git a/Dockerfile b/Dockerfile index 7663b0ba..201c8516 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -ARG JAVA_VERSION=11 +ARG JAVA_VERSION=17 # This image additionally contains function core tools – useful when using custom extensions -FROM mcr.microsoft.com/azure-functions/java:3.0-java$JAVA_VERSION-build AS installer-env +FROM mcr.microsoft.com/azure-functions/java:4-java$JAVA_VERSION-build AS installer-env COPY . /src/java-function-app RUN echo $(ls -1 /src/java-function-app) @@ -23,7 +23,7 @@ RUN chmod 777 /src/java-function-app/opentelemetry-javaagent.jar && \ # This image is ssh enabled #FROM mcr.microsoft.com/azure-functions/java:3.0-java$JAVA_VERSION-appservice # This image isn't ssh enabled -FROM mcr.microsoft.com/azure-functions/java:3.0-java$JAVA_VERSION +FROM mcr.microsoft.com/azure-functions/java:4-java$JAVA_VERSION ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsJobHost__Logging__Console__IsEnabled=true diff --git a/host.json b/host.json index fda7e648..ac6d1b14 100644 --- a/host.json +++ b/host.json @@ -10,7 +10,7 @@ }, "queues": { "maxPollingInterval": "00:00:02", - "visibilityTimeout" : "00:00:30", + "visibilityTimeout": "00:00:30", "batchSize": 8, "maxDequeueCount": 5, "newBatchThreshold": 4, @@ -27,8 +27,11 @@ }, "applicationInsights": { "samplingSettings": { - "isEnabled": false + "isEnabled": true, + "maxTelemetryItemsPerSecond": 5, + "includedTypes": "PageView;Trace;Dependency;Request", + "excludedTypes": "Exception;Event;CustomEvent" + } } } } -} diff --git a/pom.xml b/pom.xml index f31042b3..89eb2f3d 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ UTF-8 - 11 + 17 1.15.0 1.4.2 com.microsoft.azure-20220215182005862 @@ -71,7 +71,7 @@ uk.org.webcompere system-stubs-jupiter - 1.1.0 + 2.1.3 test