ESlint report paths not working in GitHub Actions

Hi,

I am trying to scan my typescript project with GitHub action using this GitHub - SonarSource/sonarcloud-github-action: Integrate SonarCloud code analysis to GitHub Actions

My typescript is using ESLint and generate a report that I would like to send to SonarCloud

But it seems that the working dir, and the execution dir are not the same, and that sonar is then not capable of finding the files.

Here is the error report from Github action :

...
Project root configuration file: /github/workspace/sonar-project.properties
...
INFO: Sensor Import of ESLint issues [javascript]
103
INFO: Importing /github/workspace/eslint-report.json
104
WARN: No input file found for /home/runner/work/**/*.ts. No ESLint issues will be imported on this file.
105
WARN: No input file found for /home/runner/work/**/*.ts. No ESLint issues will be imported on this file.
106
WARN: No input file found for /home/runner/work/**/*.ts. No ESLint issues will be imported on this file.
107
WARN: No input file found for /home/runner/work/**/*.ts. No ESLint issues will be imported on this file.
108
WARN: No input file found for /home/runner/work/**/*.ts. No ESLint issues will be imported on this file.
109
WARN: No input file found for /home/runner/work/**/*.ts. No ESLint issues will be imported on this file.
110
WARN: No input file found for /home/runner/work/**/*.ts. No ESLint issues will be imported on this file.
111
WARN: No input file found for /home/runner/work/**/*.ts. No ESLint issues will be imported on this file.
112
WARN: No input file found for /home/runner/work/**/*.ts. No ESLint issues will be imported on this file.
113
WARN: No input file found for /home/runner/work/**/*.ts. No ESLint issues will be imported on this file.
114
WARN: No input file found for /home/runner/work/**/*.ts. No ESLint issues will be imported on this file.
115
WARN: No input file found for /home/runner/work/**/*.ts. No ESLint issues will be imported on this file.
116
WARN: No input file found for /home/runner/work/**/*.ts. No ESLint issues will be imported on this file.
117
WARN: No input file found for /home/runner/work/**/*.ts. No ESLint issues will be imported on this file.
118
WARN: No input file found for /home/runner/work/**/*.ts. No ESLint issues will be imported on this file.
119
WARN: No input file found for /home/runner/work/**/*.ts. No ESLint issues will be imported on this file.
120
WARN: No input file found for /home/runner/work/**/*.ts. No ESLint issues will be imported on this file.
121
WARN: No input file found for /home/runner/work/**/*.ts. No ESLint issues will be imported on this file.
...

Here is the scanner config :

sonar.projectKey=***
sonar.organization=***
sonar.projectVersion=0.0.1
sonar.sources=.
sonar.sourceEncoding=UTF-8
sonar.eslint.reportPaths=eslint-report.json
sonar.typescript.tsconfigPath=tsconfig.json
sonar.typescript.lcov.reportPaths=coverage/lcov.info

And here is the GitHub action job


name: Github CI
on:
  pull_request:
    types: [opened, synchronize, reopened]
  push:
    branches:
      - master

jobs:

  sonar:
    name: Sonar analysis
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [ 14.x ]

    services:
      mongodb:
        image: mongo:latest
        env:
          MONGO_INITDB_DATABASE: ****
        ports:
          - 27017:27017

    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Installtion of NodeJS ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}
      - name: Installation
        run: yarn
      - name: Build
        run: yarn build
      - name: Tests
        run: yarn test
        env:
          DATABASE_URI: ***
      - name: ESLint
        run: yarn lint
        continue-on-error: true
      - name: Sonar
        uses: SonarSource/sonarcloud-github-action@master
        env:
          GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

I dunno what to do to solve this issue, do you guys have an idea ?

1 Like

Searched a bit more after a short night and found this

So the GitHub action sonar is a docker container mounting the /home/runner/work/*** into /github/workspace.

As ESLint seemed to not have any way of using relative paths instead of absolute, I added a step in the workflow with this command :

sed -i 's+/home/runner/work/***+/github/workspace+g' eslint-report.json

This seems to work well for now !

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.