cpp-linter / cpp-linter-action

A Github Action for linting C/C++ code integrating clang-tidy and clang-format to collect feedback provided in the form of file-annotations, thread-comments, workflow step-summary, and Pull Request reviews.

Home Page:https://cpp-linter.github.io/cpp-linter-action/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve paths handling

ivancho-ifa opened this issue · comments

First of all, great Action!

I noticed that when setting an absolute path to the compilation database I receive wrong paths.

    - name: Run clang-tidy and clang-format 
      uses: cpp-linter/cpp-linter-action@v2
      id: linter
      env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
          style: file
          database: ${{github.workspace}}/out/build/${{matrix.arch}}-${{env.BUILD_TYPE}}
          thread-comments: true
          step-summary: true

Produces "D:\a\figures-counter\figures-counter\afigures-counterfigures-counter\out\build\x64-debug" instead of the correct path "D:\a\figures-counter\figures-counter\out\build\x64-debug"

The workaround is to omit the prefix and use relative path

database: out/build/${{matrix.arch}}-${{env.BUILD_TYPE}}

I think what's happening here might be related to using a Windows runner. The var github.workspace lost all it path delimiters: afigures-counterfigures-counter. This makes me wonder what stripped them. Typically python strings with \ have to be doubled (\\) to escape the misinterpreted reg-exp token. Otherwise you'd get strings with tokens like \a that mean "literal a".

What perplexes me more is that drive letter D: was stripped as well. I think I have the details to reproduce, and hopefully I can find a fix for this.

Paths on windows will be passed to cpp-linter's python package using powershell in the next release. I still have to do a little more testing to make sure clang-tidy can actually find the database on Windows runners where the database option is given an absolute path.