| 
8 | 8 | 
 
  | 
9 | 9 | # Cancel old PR builds when pushing new commits.  | 
10 | 10 | concurrency:  | 
11 |  | -  group: scan-${{ github.event.pull_request.number || github.ref }}  | 
 | 11 | +  group: sonar-scan-${{ github.event.pull_request.number || github.ref }}  | 
12 | 12 |   cancel-in-progress: true  | 
13 | 13 | 
 
  | 
14 | 14 | jobs:  | 
15 | 15 |   sonar-scan:  | 
16 | 16 |     runs-on: ubuntu-latest  | 
17 | 17 |     env:  | 
18 |  | -      SONAR_SCANNER_VERSION: 5.0.1.3006  | 
19 |  | -      SONAR_SERVER_URL: "https://sonarcloud.io"  | 
20 | 18 |       BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed  | 
21 | 19 |     steps:  | 
22 | 20 |       - uses: actions/checkout@v4  | 
23 | 21 |         with:  | 
24 | 22 |           fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis  | 
25 | 23 |           submodules: recursive  | 
26 |  | -      - name: Set up JDK 17  | 
27 |  | -        uses: actions/setup-java@v2  | 
28 |  | -        with:  | 
29 |  | -          distribution: "zulu"  | 
30 |  | -          java-version: 17  | 
31 |  | -      - name: Download and set up sonar-scanner  | 
32 |  | -        env:  | 
33 |  | -          SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip  | 
34 |  | -        run: |  | 
35 |  | -          mkdir -p $HOME/.sonar  | 
36 |  | -          curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}  | 
37 |  | -          unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/  | 
38 |  | -          echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH  | 
39 |  | -      - name: Download and set up build-wrapper  | 
40 |  | -        env:  | 
41 |  | -          BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip  | 
42 |  | -        run: |  | 
43 |  | -          curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}  | 
44 |  | -          unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/  | 
45 |  | -          echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH  | 
 | 24 | +      - name: Install Build Wrapper  | 
 | 25 | +        uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v6  | 
46 | 26 |       - name: Install dependencies and prepare build  | 
47 | 27 |         run: |  | 
48 | 28 |           .github/scripts/sonar-prepare  | 
49 |  | -      - name: Run build-wrapper  | 
 | 29 | +      - name: Run Build Wrapper  | 
50 | 30 |         run: |  | 
51 | 31 |           build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} .github/scripts/sonar-build  | 
52 |  | -      - name: Run sonar-scanner  | 
 | 32 | +      - name: Ensure compile_commands.json is generated  | 
 | 33 | +        run: ls -l "${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"  | 
 | 34 | +      - name: SonarQube Scan  | 
53 | 35 |         if: github.event_name == 'push'  | 
 | 36 | +        uses: SonarSource/sonarqube-scan-action@v6  | 
54 | 37 |         env:  | 
55 |  | -          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  | 
56 | 38 |           SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}  | 
57 |  | -        run: 'sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"'  | 
 | 39 | +        with:  | 
 | 40 | +          args: >  | 
 | 41 | +            --define "sonar.cfamily.compile-commands=${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"  | 
0 commit comments