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

Change action from using docker to composite steps

2bndy5 opened this issue · comments

This will:

  1. improve workflow runs times from 1m 24s (currently) to 6-20s (as shown in proof-of-concept tests).
  2. better support for the database input option (which is currently broken with the docker env).
  3. better support cross-compilation
  4. better support 3rd party libraries

WIP PR at #83

I still want to test the database option (using a third party lib installed).

OK. that should be the last step before we release v2

I'm working on changes to the test repo that will make use of vcpkg, conan, and chocolate package managers... Just wanted to say something to report my progress. The changes will also use both windows and ubuntu runners (for the composite action).

I finally got the new CI workflow (for composite action) working on the test repo. Here's the new src/demo build process:

  1. Install fmt using conan. This results in fmt getting installed to $HOME/.conan/data/packages/
  2. Run cmake with vcpkg's toolchain file. This results in boost libs (namely boost-assert) installed to the ./build/vcpkg_installed/<target triplet>

Notes

  • Successful workflow log is here
  • For good measure, I made sure that the demo app actually builds using the fmt and boost.assert libs, but this isn't done in the CI.
  • On Windows the database can only be generated with the "NMake Makefiles" CMake generator which requires using the Visual Studio Dev prompt... There's an action for that.

Database usage

Now calling cpp-linter -p build -i build does use the generated database, but I noticed

  1. The database does not include a path to the system's libc++ headers, so we see
    /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/cstddef:50:10: error: 'stddef.h' file not found [clang-diagnostic-error]
    #include <stddef.h>
    
    This seems only happen on the Ubuntu runner. I think the Windows runner has already set the CCFLAGS env var due to using the VS Dev Prompt's env, but I haven't researched it locally yet (WSL is super slow when I run cmake now).
  2. Using Windows (namely any clang version < 13), clang-tidy has trouble finding the boost/assert.hpp file. I have a feeling its because the VS compiler expects v13.
    D:\a\test-cpp-linter-action\test-cpp-linter-action\src\demo.cpp:4:10: error: 'boost/assert.hpp' file not found [clang-diagnostic-error]
      #include <boost/assert.hpp> // to use a third party lib (internal via vcpkg - located in build env)
               ^
    

Conclusion

I'm giving this a passing grade 💯 . Since it seems to be working for third party libs in the CI, I'm willing to work through the kinks as users report them.