|
1 |
| -name: EMD - CodeReview |
| 1 | +name: SonarCloud Analysis |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | pull_request:
|
|
8 | 8 | - synchronize
|
9 | 9 |
|
10 | 10 | jobs:
|
11 |
| - build: |
| 11 | + sonarcloud: |
| 12 | + name: SonarCloud Analysis |
12 | 13 | runs-on: ubuntu-latest
|
| 14 | + |
13 | 15 | steps:
|
14 |
| - - name: Checkout sources |
| 16 | + - name: Checkout code |
15 | 17 | uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
|
16 |
| - with: |
17 |
| - fetch-depth: 0 |
18 | 18 |
|
19 |
| - - name: Setup Java |
| 19 | + - name: Set up JDK 17 |
20 | 20 | uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 #v4.2.1
|
21 | 21 | with:
|
22 |
| - distribution: 'corretto' |
23 |
| - java-version: 17 |
24 |
| - |
25 |
| - - name: Set up Apache Maven |
26 |
| - uses: actions/setup-java@v3 |
27 |
| - with: |
28 |
| - distribution: 'corretto' |
| 22 | + distribution: 'adopt' |
29 | 23 | java-version: '17'
|
30 |
| - cache: 'maven' |
31 | 24 |
|
32 |
| - - name: Build with Maven |
33 |
| - run: mvn clean install |
| 25 | + - name: Cache Maven packages |
| 26 | + uses: actions/cache@v3 |
| 27 | + with: |
| 28 | + path: ~/.m2/repository |
| 29 | + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} |
| 30 | + restore-keys: | |
| 31 | + ${{ runner.os }}-maven- |
34 | 32 |
|
35 |
| - - name: Copy dependencies |
36 |
| - run: mvn dependency:copy-dependencies |
| 33 | + - name: Build and test with Maven |
| 34 | + run: mvn clean org.jacoco:jacoco-maven-plugin:0.8.8:prepare-agent verify org.jacoco:jacoco-maven-plugin:0.8.8:report org.jacoco:jacoco-maven-plugin:0.8.8:report-aggregate -B |
37 | 35 |
|
38 | 36 | - name: SonarCloud Scan
|
39 |
| - uses: sonarsource/sonarcloud-github-action@e44258b109568baa0df60ed515909fc6c72cba92 #v2.3.0 |
40 | 37 | env:
|
41 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
42 | 38 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
43 |
| - with: |
44 |
| - args: > |
45 |
| - -Dsonar.organization=${{ vars.SONARCLOUD_ORG }} |
46 |
| - -Dsonar.projectKey=${{ vars.SONARCLOUD_PROJECT_KEY }} |
47 |
| - -Dsonar.projectName="${{ vars.SONARCLOUD_PROJECT_NAME }}" |
48 |
| - -Dsonar.java.binaries=target/classes |
49 |
| - -Dsonar.java.libraries=target/dependency/*.jar |
50 |
| - -Dsonar.exclusions=**/enums/**,**/model/**,**/stub/**,**/dto/**,**/*Constant*,**/*Config.java,**/*Scheduler.java,**/*Application.java,**/src/test/**,**/Dummy*.java |
| 39 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 40 | + run: | |
| 41 | + mvn sonar:sonar \ |
| 42 | + -Dsonar.projectKey=${{ vars.SONARCLOUD_PROJECT_KEY }} \ |
| 43 | + -Dsonar.organization=${{ vars.SONARCLOUD_ORG }} \ |
| 44 | + -Dsonar.host.url=https://sonarcloud.io \ |
| 45 | + -Dsonar.login=${{ secrets.SONAR_TOKEN }} \ |
| 46 | + -Dsonar.java.binaries=target/classes \ |
| 47 | + -Dsonar.junit.reportPaths=target/surefire-reports \ |
| 48 | + -Dsonar.jacoco.reportPaths=target/jacoco.exec \ |
| 49 | + -Dsonar.exclusions=**/enums/**,**/model/**,**/stub/**,**/dto/**,**/*Constant*,**/*Config.java,**/*Scheduler.java,**/*Application.java,**/src/test/**,**/Dummy*.java |
0 commit comments