Sudden Error Popping up During Sonar Analysis in github actions

  • ALM used (GitHub)
  • CI system used (Github Actions)
  • Scanner command used when applicable (sonarsource/sonarqube-scan-action@master)
  • Languages of the repository - JavaScript/Typescript
  • Error observed -
    ‘’‘ERROR Caused by: Line 3 of report refers to a file which is not configured as a test file: /home/runner/work/repo-name/app_dir/apps/app_name/src/app/resolver/app.resolver.spec.ts’‘’
  • Steps to reproduce - Using this action (sonarsource/sonarqube-scan-action@master)
  • Potential workaround -
    Using - sonarsource/sonarqube-scan-action@v3

Note Here - No test files or sonar configs were updated.
Just after the Sonar update this error is popping up across multiple repos.
But using an older version is running fine.

Hey there.

Take a look at this post:

While it’s related to Python, I think the issue might have the same cause. Are you doing some processing of the coverage report that could affect the file paths?

Hi Colin ,
Thanks for getting back here so quickly.
For one of the repos we are not , it is as is.

- name: Unit Tests
        run: yarn test --coverage

      - name: Run sonarqube analysis
        uses: sonarsource/sonarqube-scan-action@master
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
        with:
          args: >
            -Dsonar.projectVersion=${{ github.sha }}

But for another repo it goes something like

      # Setup our coverage directory and files for SonarQube reporting
      - name: Setup Files
        run: |
          mkdir ./coverage
          touch ./coverage/.gitkeep
          echo '<?xml version="1.0" encoding="UTF-8"?><testExecutions version="1"></testExecutions>' > ./test-report.xml

Yes we face a similar issue

Let me give you the whole piece for the 2nd repo here

# Setup our coverage directory and files for SonarQube reporting
      - name: Setup Files
        run: |
          mkdir ./coverage
          touch ./coverage/.gitkeep
          echo '<?xml version="1.0" encoding="UTF-8"?><testExecutions version="1"></testExecutions>' > ./test-report.xml

      # Run our tests
      - name: ${{ matrix.data.type }} Test
        uses: mansagroup/nrwl-nx-action@v3
        with:
          targets: ${{ matrix.data.target }}
          all: ${{ needs.context.outputs.nx-run-all }}
          parallel: true
          args: --codeCoverage

      # Upload coverage report as an artifact
      - uses: actions/upload-artifact@v4
        with:
          name: test-results-${{ matrix.data.target }}
          path: |
            ./coverage
            ./test-report.xml

  sonarqube:
    name: Run SonarQube
    runs-on: ubuntu-latest
    needs: [context, test]
    steps:
      - name: Checkout Source Files
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      # Here we download our individual coverage reports
      # That we previously uploaded as artifacts
      - uses: actions/download-artifact@v4
        if: needs.context.outputs.sonarqube == 'true'
        with:
          name: test-results-unit
          path: ./coverage-unit

      - uses: actions/download-artifact@v4
        if: needs.context.outputs.sonarqube == 'true'
        with:
          name: test-results-integration
          path: ./coverage-integration

      # In the project's sonar-project.properties file, it's
      # Configured to point at the ./coverage-unit and the
      # ./coverage-integration paths for coverage files and it
      # Uses those to stitch together a total coverage report
      - name: Run SonarQube
        uses: sonarsource/sonarqube-scan-action@v3.1.0
        if: needs.context.outputs.sonarqube == 'true'
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
        with:
          args: >
            -Dsonar.projectVersion=${{ github.sha }}

Let me suggest you build a small sample repository where you face this issue and make it a public GitHub repo so that it’s easy to reproduce on our end and suggest the best fix.

Creating a sample repo might not be possibile :confused: .
Is there any more information I can give you here to better understand this ?

In any efficient manner, probably not. It’s important that we’re able to reproduce the issue under the same conditions. Having a reproducer is a pretty reasonable ask, especially if we need to call in the help of our dev teams.

It doesn’t have to be “real” code, but any sample project/pipeline that can reproduce the issue will do. :slight_smile: