Coverage Reporting Issue for Typescript in sonarcloud

The coverage for Typescript is not imported in sonarcloud anymore. I checked
https://community.sonarsource.com/t/coverage-issues-for-typescript-lcov-could-not-resolve-file-paths/13301
but that did not solve the issue
As you can see eslint reports are neither imported
relevant parts of sonar.proerties are:

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set. 
sonar.sources=dispatcher,tenant-configuration-validator
sonar.tests=test/unit
# sonar.typescript.lcov.reportPaths=test/unit/coverage/lcov.info
sonar.javascript.lcov.reportPaths=test/unit/coverage/lcov.info
sonar.testExecutionReportPaths=test-report.xml
sonar.eslint.reportPaths=eslint-report.json

We use the sonarcloud github action to perform the scan

2019-11-28T15:35:45.0568570Z --------------------------------|----------|----------|----------|----------|-------------------|
2019-11-28T15:35:45.0570241Z File                            |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
2019-11-28T15:35:45.0586825Z --------------------------------|----------|----------|----------|----------|-------------------|
2019-11-28T15:35:45.0589128Z All files                       |      100 |      100 |      100 |      100 |                   |
2019-11-28T15:35:45.0590234Z 
2019-11-28T15:35:45.0590532Z  dispatcher                     |      100 |      100 |      100 |      100 |                   |
2019-11-28T15:35:45.0591326Z   index.ts                      |      100 |      100 |      100 |      100 |                   |
2019-11-28T15:35:45.0592247Z  tenant-configuration-validator |      100 |      100 |      100 |      100 |                   |
2019-11-28T15:35:45.0593060Z   index.ts                      |      100 |      100 |      100 |      100 |                   |
2019-11-28T15:35:45.0594369Z --------------------------------|----------|----------|----------|----------|-------------------|
2019-11-28T15:35:45.0606007Z Test Suites: 2 passed, 2 total
2019-11-28T15:35:45.0606699Z Tests:       4 passed, 4 total
2019-11-28T15:35:45.0607006Z Snapshots:   0 total
2019-11-28T15:35:45.0607294Z Time:        4.63s
2019-11-28T15:35:45.0607554Z Ran all test suites.
2019-11-28T15:35:45.0910697Z ~/work/jobreporter/jobreporter
2019-11-28T15:35:45.1062041Z ##[group]Run sonarsource/sonarcloud-github-action@master
2019-11-28T15:35:45.1062213Z with:
2019-11-28T15:35:45.1062330Z   projectBaseDir: .
2019-11-28T15:35:45.1062439Z env:
2019-11-28T15:35:45.1062965Z   GITHUB_TOKEN: ***
2019-11-28T15:35:45.1063108Z   SONAR_TOKEN: ***
2019-11-28T15:35:45.1063221Z ##[endgroup]
2019-11-28T15:35:45.1093231Z ##[command]/usr/bin/docker run --name f6cdebab523c01402c43a9ad44880477c2de20_9f3940 --label f6cdeb --workdir /github/workspace --rm -e GITHUB_TOKEN -e SONAR_TOKEN -e INPUT_PROJECTBASEDIR -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/jobreporter/jobreporter":"/github/workspace" f6cdeb:ab523c01402c43a9ad44880477c2de20
2019-11-28T15:35:56.2946529Z INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
2019-11-28T15:35:56.2960775Z INFO: Project root configuration file: /github/workspace/sonar-project.properties
2019-11-28T15:35:56.3340422Z INFO: SonarQube Scanner 3.3.0.1492
2019-11-28T15:35:56.3341591Z INFO: Java 11.0.5 Oracle Corporation (64-bit)
2019-11-28T15:35:56.3345372Z INFO: Linux 5.0.0-1023-azure amd64
2019-11-28T15:35:56.6551252Z INFO: User cache: /root/.sonar/cache
2019-11-28T15:35:58.9457962Z INFO: SonarQube server 8.0.0
2019-11-28T15:35:58.9470046Z INFO: Default locale: "en", source code encoding: "UTF-8" (analysis is platform dependent)
2019-11-28T15:35:59.3637041Z INFO: Load global settings
2019-11-28T15:35:59.9985520Z INFO: Load global settings (done) | time=636ms
2019-11-28T15:36:00.0044910Z INFO: Server id: 74E9293D-AWHW8ct9-T_TB3XqouNu
2019-11-28T15:36:00.0075338Z INFO: User cache: /root/.sonar/cache
2019-11-28T15:36:00.0102425Z INFO: Load/download plugins
2019-11-28T15:36:00.0106008Z INFO: Load plugins index
2019-11-28T15:36:00.1603094Z INFO: Load plugins index (done) | time=145ms
2019-11-28T15:36:20.6372008Z INFO: Load/download plugins (done) | time=20627ms
2019-11-28T15:36:20.9329004Z INFO: Loaded core extensions: developer-scanner
2019-11-28T15:36:21.5943414Z INFO: Process project properties
2019-11-28T15:36:21.6016270Z INFO: Execute project builders
2019-11-28T15:36:21.6053383Z INFO: Execute project builders (done) | time=3ms
2019-11-28T15:36:21.6078584Z INFO: Project key: TTS-TMC_jobreporter
2019-11-28T15:36:21.6078847Z INFO: Base dir: /github/workspace
2019-11-28T15:36:21.6079077Z INFO: Working dir: /github/workspace/.scannerwork
2019-11-28T15:36:21.6126465Z INFO: Load project settings for component key: 'TTS-TMC_jobreporter'
2019-11-28T15:36:21.7574601Z INFO: Load project settings for component key: 'TTS-TMC_jobreporter' (done) | time=144ms
2019-11-28T15:36:21.8540460Z INFO: Found an active CI vendor: 'Github Actions'
2019-11-28T15:36:21.8616295Z INFO: Load project branches
2019-11-28T15:36:21.9847786Z INFO: Load project branches (done) | time=124ms
2019-11-28T15:36:21.9872144Z INFO: Load projects for organization 'tts-tmc'
2019-11-28T15:36:24.1773199Z INFO: Load projects for organization 'tts-tmc' (done) | time=2188ms
2019-11-28T15:36:24.1773483Z INFO: Load project pull requests
2019-11-28T15:36:24.2943968Z INFO: Load project pull requests (done) | time=118ms
2019-11-28T15:36:24.2971895Z INFO: Load branch configuration
2019-11-28T15:36:24.3013248Z INFO: Github event: push
2019-11-28T15:36:24.5259020Z INFO: Auto-configuring branch feature/sonar-scanner
2019-11-28T15:36:24.5263289Z INFO: Load branch configuration (done) | time=229ms
2019-11-28T15:36:24.5648424Z INFO: Load quality profiles
2019-11-28T15:36:24.7059730Z INFO: Load quality profiles (done) | time=141ms
2019-11-28T15:36:24.7108878Z INFO: Load active rules
2019-11-28T15:36:31.2426748Z INFO: Load active rules (done) | time=6531ms
2019-11-28T15:36:31.2732694Z INFO: Organization key: tts-tmc
2019-11-28T15:36:31.2739737Z INFO: Branch name: feature/sonar-scanner, type: short living
2019-11-28T15:36:31.2936183Z INFO: SCM collecting changed files in the branch
2019-11-28T15:36:31.4725611Z INFO: SCM collecting changed files in the branch (done) | time=178ms
2019-11-28T15:36:31.5073533Z INFO: Indexing files...
2019-11-28T15:36:31.5082305Z INFO: Project configuration:
2019-11-28T15:36:31.5796294Z INFO: 9 files indexed
2019-11-28T15:36:31.5831560Z INFO: 0 files ignored because of scm ignore settings
2019-11-28T15:36:31.5841964Z INFO: Quality profile for ts: Sonar way
2019-11-28T15:36:31.5849401Z INFO: ------------- Run sensors on module Jobreporter
2019-11-28T15:36:31.7179294Z INFO: Load metrics repository
2019-11-28T15:36:31.8288965Z INFO: Load metrics repository (done) | time=111ms
2019-11-28T15:36:32.9841856Z WARNING: An illegal reflective access operation has occurred
2019-11-28T15:36:32.9843749Z WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$1 (file:/root/.sonar/cache/a89f1943fc75b65becd9fb4ecab8d913/sonar-tsql-plugin.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
2019-11-28T15:36:32.9844295Z WARNING: Please consider reporting this to the maintainers of net.sf.cglib.core.ReflectUtils$1
2019-11-28T15:36:32.9845264Z WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
2019-11-28T15:36:32.9845574Z WARNING: All illegal access operations will be denied in a future release
2019-11-28T15:36:34.9066496Z INFO: Sensor JavaXmlSensor [java]
2019-11-28T15:36:34.9086113Z INFO: Sensor JavaXmlSensor [java] (done) | time=3ms
2019-11-28T15:36:34.9087388Z INFO: Sensor HTML [web]
2019-11-28T15:36:34.9126372Z INFO: Sensor HTML [web] (done) | time=4ms
2019-11-28T15:36:34.9127663Z INFO: Sensor SonarTS [typescript]
2019-11-28T15:36:34.9129163Z INFO: Since SonarTS v2.0, TypeScript analysis is performed by SonarJS analyzer v6.0 or later. No TypeScript analysis is performed by SonarTS.
2019-11-28T15:36:34.9129457Z INFO: Sensor SonarTS [typescript] (done) | time=0ms
2019-11-28T15:36:34.9129695Z INFO: Sensor JaCoCo XML Report Importer [jacoco]
2019-11-28T15:36:34.9155239Z INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=3ms
2019-11-28T15:36:34.9155533Z INFO: Sensor SonarJS Coverage [javascript]
2019-11-28T15:36:34.9170323Z INFO: Analysing [/github/workspace/test/unit/coverage/lcov.info]
2019-11-28T15:36:34.9243068Z WARN: Could not resolve 2 file paths in [/github/workspace/test/unit/coverage/lcov.info], first unresolved path: /home/runner/work/jobreporter/jobreporter/dispatcher/index.ts
2019-11-28T15:36:34.9243445Z INFO: Sensor SonarJS Coverage [javascript] (done) | time=8ms
2019-11-28T15:36:34.9243685Z INFO: Sensor Import of ESLint issues [javascript]
2019-11-28T15:36:34.9255971Z INFO: Importing /github/workspace/eslint-report.json
2019-11-28T15:36:34.9331307Z WARN: No input file found for /home/runner/work/jobreporter/jobreporter/dispatcher/index.ts. No ESLint issues will be imported on this file.
2019-11-28T15:36:34.9334533Z WARN: No input file found for /home/runner/work/jobreporter/jobreporter/tenant-configuration-validator/index.ts. No ESLint issues will be imported on this file.
2019-11-28T15:36:34.9344297Z WARN: No input file found for /home/runner/work/jobreporter/jobreporter/test/unit/dispatcher/index.spec.ts. No ESLint issues will be imported on this file.
2019-11-28T15:36:34.9352844Z WARN: No input file found for /home/runner/work/jobreporter/jobreporter/test/unit/fixtures/default-context.ts. No ESLint issues will be imported on this file.
2019-11-28T15:36:34.9353784Z WARN: No input file found for /home/runner/work/jobreporter/jobreporter/test/unit/tenant-configuration-validator/index.spec.ts. No ESLint issues will be imported on this file.
2019-11-28T15:36:34.9358812Z INFO: Sensor Import of ESLint issues [javascript] (done) | time=12ms
2019-11-28T15:36:34.9365027Z INFO: Sensor TypeScript analysis [javascript]
2019-11-28T15:36:36.0736607Z INFO: Using TypeScript at: '/github/workspace/node_modules'
2019-11-28T15:36:37.3259952Z INFO: Found 1 tsconfig.json file(s): [/github/workspace/tsconfig.json]
2019-11-28T15:36:37.4093422Z INFO: 2 source files to be analyzed
2019-11-28T15:36:37.4098632Z INFO: Analyzing 2 files using tsconfig: /github/workspace/tsconfig.json
2019-11-28T15:36:39.9306110Z INFO: 2/2 source files have been analyzed
2019-11-28T15:36:39.9322620Z INFO: Sensor TypeScript analysis [javascript] (done) | time=4996ms
2019-11-28T15:36:39.9324731Z INFO: Sensor Generic Test Executions Report
2019-11-28T15:36:39.9326426Z INFO: Parsing /github/workspace/test-report.xml
2019-11-28T15:36:39.9499229Z INFO: Imported test execution data for 0 files
2019-11-28T15:36:39.9502099Z INFO: Test execution data ignored for 2 unknown files, including:
2019-11-28T15:36:39.9503635Z /home/runner/work/jobreporter/jobreporter/test/unit/tenant-configuration-validator/index.spec.ts
2019-11-28T15:36:39.9504260Z /home/runner/work/jobreporter/jobreporter/test/unit/dispatcher/index.spec.ts
2019-11-28T15:36:39.9504765Z INFO: Sensor Generic Test Executions Report (done) | time=18ms
2019-11-28T15:36:39.9505842Z INFO: Sensor JavaSecuritySensor [security]
2019-11-28T15:36:39.9506406Z INFO: Reading type hierarchy from: /github/workspace/.scannerwork/ucfg2/java
2019-11-28T15:36:39.9507504Z INFO: Read 0 type definitions
2019-11-28T15:36:39.9530580Z INFO: Reading UCFGs from: /github/workspace/.scannerwork/ucfg2/java
2019-11-28T15:36:39.9536816Z INFO: No UCFGs have been included for analysis.
2019-11-28T15:36:39.9552148Z INFO: Sensor JavaSecuritySensor [security] (done) | time=4ms
2019-11-28T15:36:39.9554093Z INFO: Sensor CSharpSecuritySensor [security]
2019-11-28T15:36:39.9555428Z INFO: Reading type hierarchy from: /github/workspace/ucfg_cs2
2019-11-28T15:36:39.9555769Z INFO: Read 0 type definitions
2019-11-28T15:36:39.9556116Z INFO: Reading UCFGs from: /github/workspace/ucfg_cs2
2019-11-28T15:36:39.9556467Z INFO: No UCFGs have been included for analysis.
2019-11-28T15:36:39.9557566Z INFO: Sensor CSharpSecuritySensor [security] (done) | time=0ms
2019-11-28T15:36:39.9557992Z INFO: Sensor PhpSecuritySensor [security]
2019-11-28T15:36:39.9558595Z INFO: Reading type hierarchy from: /github/workspace/.scannerwork/ucfg2/php
2019-11-28T15:36:39.9558980Z INFO: Read 0 type definitions
2019-11-28T15:36:39.9559393Z INFO: Reading UCFGs from: /github/workspace/.scannerwork/ucfg2/php
2019-11-28T15:36:39.9559750Z INFO: No UCFGs have been included for analysis.
2019-11-28T15:36:39.9560124Z INFO: Sensor PhpSecuritySensor [security] (done) | time=1ms
2019-11-28T15:36:39.9594791Z INFO: ------------- Run sensors on project

P.S.: use the #bug:fault sub-category if you’re hitting a specific crash/error , or the #bug:fp sub-category for rules-related behaviour

Ok so I figured what is happening. The Docker run command is setting the workdir to /github/workspace but the lcov.info obviously has different paths namely /home/runner/work/YourRepoName... so the files are never found.
I hacked a little and did a sed -i 's+/home/runner/work/jobreporter/jobreporter+/github/workspace+g' test/unit/coverage/lcov.info after that the coverage is imported correctly.

Not sure about a solution because I am not that familiar with Docker. Maybe the workDir can be changed to match the paths in Github?

Regards
Mathias

2 Likes

Hello @mathiasmaerker, welcome to the community forum!

I’m glad you found the issue.
Setting the projectBaseDir property should cover your use case as well, see the example on this page.

Tom

Hi Tom, thanks for the welcome :bowing_man:

I can’t find a good example on the page. I set projectBaseDir: /home/runner/work... and end up with the same errors as before.
An other thing I noticed even in my original solution the eslint errors are not imported any clue why?

Thanks in advance
regards
Mathias

Hello @mathiasmaerker,

Yes, setting the projectBaseDir will not do anything because the paths in your lcov.info are absolute, sorry for that. So I guess replacing the paths in lcov.info like you did or creating a symbolic link are the best options you have.

Don’t you have exactly the same issue here as with importing the coverage here?

Tom

Hi @TomVanBraband ,
yes exactly the same error even thou I replaced the paths the same as in lcov.info. To verify I used cat before and after and I can see the correct paths in eslint-report.json

Regards
Mathias

Hello @mathiasmaerker,

It is hard to figure out what is going on without the seeing the set-up, is your project open-source?

Hi @TomVanBraband,

unfortunately not, it is private. let me investigate and I come back to you

1 Like

Hi @TomVanBraband i am still stuck, can I enable some deeper logging for the github action?

@mathiasmaerker

It’s best if you generate reports imported into SonarCloud (like coverage and eslint report) on the same machine where you run analysis, that way paths will match. If it’s not possible check if tools you use can generate reports with relative paths or edit reports so that they contain relative paths (what you’ve did as far as I understood).

If something is still not working, please provide debug logs and explain your problem (it’s hard to follow on a long thread what’s eventually is ok and what’s not).

Thanks

Hi @Lena,

I finally solved the Problem, I still need to change the Path I think that relates to how GitHub Actions/Docker works in conjunction with absolute paths generated by Istanbul. The main Problem I had, I was missing the sonar.srources so not all source files where recognized :confused:
Anyway, thanks for all your help!