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

No such file or directory: 'clang-tidy-*' on macos

shenxianpeng opened this issue · comments

Test action failed when running cpp-linter, it may be that clang-format and clang-tidy are not installed correctly on macOS.

https://github.com/cpp-linter/test-cpp-linter-action/actions/runs/3248892324/jobs/5330649416

Form my test , it looks like was cpp-linter's failure on macOS. so I transfer issue to here(cpp-linter).

When I installed clang-tools manually before running cpp-linter, the test action ran successfully. here is the job.


cpp-linter-action installed clang-tools path is /usr/local/opt/python@3.10/bin, this path can not be found by cpp-linter? @2bndy5

Run clang-tools -i 12 -b
/usr/local/opt/python@3.10/bin directory is not in your environment variable PATH.
downloading clang-format (version 12)
Installing clang-format-12 to /usr/local/opt/python@3.10/bin
symbolic link created /usr/local/opt/python@3.10/bin/clang-format
downloading clang-tidy (version 12)
Installing clang-tidy-12 to /usr/local/opt/python@3.10/bin
symbolic link created /usr/local/opt/python@3.10/bin/clang-tidy

manually installed clang-tools before running cpp-linter, the path is /Users/runner/hostedtoolcache/Python/3.10.7/x64/bin

Run pip install clang-tools
  
Collecting clang-tools
  Downloading clang_tools-0.6.2-py3-none-any.whl (10 kB)
Installing collected packages: clang-tools
Successfully installed clang-tools-0.6.2

Notice:  A new release of pip available: 22.2.2 -> 22.3
Notice:  To update, run: pip install --upgrade pip
downloading clang-format (version [12](https://github.com/shenxianpeng/test-repo/actions/runs/3262462546/jobs/5359632173#step:4:13))
Installing clang-format-12 to /Users/runner/hostedtoolcache/Python/3.10.7/x64/bin
symbolic link created /Users/runner/hostedtoolcache/Python/3.10.7/x64/bin/clang-format
downloading clang-tidy (version 12)
Installing clang-tidy-12 to /Users/runner/hostedtoolcache/Python/3.10.7/x64/bin
symbolic link created /Users/runner/hostedtoolcache/Python/3.10.7/x64/bin/clang-tidy

This seems more like an issue with clang-tools-pip or cpp-linter-action repo.

I assume the location for macOS is gotten from str(Path(sys.executable).parent) (which is used for anything but Linux - see the src here) is resolving differently depending on the location of the python executable.

I notice that you also manually setup python using actions/setup-python step on the successful test run (which resolved to /Users/runner/hostedtoolcache/Python/3.10.7/x64/bin). In the failed test run, the default version of python (that ships with the OS container) is used, which apparently exists in /usr/local/opt/python@3.10/bin/.

We have not mandated this (yet), but installing python with the github action seems to help resolve the install path as a folder that cpp-linter (& clang-tools-pip) can access. We could make a temp venv from a composite step so users are not burdened with an extra CI step (uses: actions/setup-python) just to use cpp-linter-action.

This might be more easily solved by addressing cpp-linter/clang-tools-pip#15 with a path we create in the user space (independent of the location for the python executable).

Making a temp venv from a composite step should be the faster way to resolve this problem. it will increase a little time.
This might be the better way to solve this problem by addressing cpp-linter/clang-tools-pip#15, but it may take longer.

We could do both solutions.

  1. resolve cpp-linter/clang-tools-pip#15
  2. create a temp venv

immediate solution with venv in #113 (made available in v2.1.3)