Can't find std headers #57
-
Now to my understanding not finding the standard headers is a common issue when using CLang and according to this page it is possible to remove these errors on local runs of CLang-tidy by using a script or a database. Now because this is a github action I do not know how to either generate a database for the workspace and I do not know if it is possible to check what kind of error has been thrown by the action. So maybe one of you know how to fix this. The link to the Github action is here if you want to check out the error for yourself. EDIT: PS: |
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 15 replies
-
Well, filtering the errors thrown by clang-tidy is not an option, and it isn't a feature that we plan to add.
This problem is rather easy. Just run CMake with the option to save the generated compilation database.
Then specify to the action where the database exists using the Full examplecpp-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Generate compilation database
run: mkdir build && cmake -Bbuild src -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: run linter as action
uses: shenxianpeng/cpp-linter-action@master
id: linter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files-changed-only: false
# to ignore all build folder contents
ignore: build
# indicate where the database is located
database: build
version: 14
- name: Fail fast?!
if: steps.linter.outputs.checks-failed > 0
# for actual deployment
# run: exit 1 Clang-tidy should now be able to use the generated database and hopefully find the I noticed that repo only runs CMake on a workflow that uses Windows. Unfortunately, Windows OS isn't supported for this action; it is supported by the action's src code, but the nature of using a docker image for the action limits workflow runners to Ubuntu only (per GitHub - not something we can control). This is why I design the action's src code to also be used as a python package (which should work on Windows-based workflows). Here's an example of the action used as a python package. - uses: actions/setup-python@v3
- name: Install clang-tools
uses: KyleMayes/install-llvm-action@v1
with:
version: "14"
- name: Install linter package
run: python3 -m pip install git+https://github.com/shenxianpeng/cpp-linter-action
- name: Generate compilation database
run: mkdir build && cmake -Bbuild src -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: run linter as package
id: linter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# --version arg is useless on Windows - it will use whatever version is installed
# --ignore the build/* artifacts generated by CMake
# --database indicates the path of the generated database
run: python3 -m cpp_linter.run --ignore=build --database=build --thread-comments=true
- name: Fail fast?!
if: steps.linter.outputs.checks-failed > 0
run: echo "Some files failed the linting checks!"
# for actual deployment
# run: exit 1 |
Beta Was this translation helpful? Give feedback.
-
Tested 13 and 14 both have From the search results, it should be 13 and 14 are not properly installed into the Docker image
$ docker run -it -v $PWD:/src xianpengshen/clang-tools:all bash
Unable to find image 'xianpengshen/clang-tools:all' locally
all: Pulling from xianpengshen/clang-tools
4d32b49e2995: Pull complete
1f55ef746619: Pull complete
5949dcd7fe24: Pull complete
Digest: sha256:ec50a7c540fa73c04423062d76c56f578958edaeea201398f77c1fbc7d28aba5
Status: Downloaded newer image for xianpengshen/clang-tools:all
root@aafbbe2227c1:/# find / -name stddef.h
find: '/proc/tty/driver': Permission denied
/usr/include/linux/stddef.h
/usr/lib/gcc/x86_64-linux-gnu/8/include/stddef.h
/usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h
/usr/lib/llvm-10/lib/clang/10.0.0/include/stddef.h
/usr/lib/llvm-11/lib/clang/11.0.0/include/stddef.h
/usr/lib/llvm-12/lib/clang/12.0.0/include/stddef.h
/usr/lib/llvm-8/lib/clang/8.0.1/include/stddef.h
/usr/lib/llvm-9/lib/clang/9.0.1/include/stddef.h |
Beta Was this translation helpful? Give feedback.
Well, filtering the errors thrown by clang-tidy is not an option, and it isn't a feature that we plan to add.
This problem is rather easy. Just run CMake with the option to save the generated compilation database.
Then specify to the action where the database exists using the
database
option.Full example