lukka / run-cmake

GitHub Action to build C++ applications with CMake (CMakePresets.json), Ninja and vcpkg on GitHub.
MIT License
176 stars 19 forks source link

How to run tests? #22

Closed vadi2 closed 4 years ago

vadi2 commented 4 years ago

I'm looking at running tests - what's the best way to do that? On the CLI, I can either run ctest or make test to run them.

Should I have a separate run action, or can cmakeAppendedArgs be massaged somehow to run and test at once?

lukka commented 4 years ago

If your 'test' build target depends on the tested binaries, you can use run-cmakewith buildWithCMakeArgs: --target test

Otherwise, you can use the run action and use ctest directly, I do not think a special action is necessary to run ctest, at least I am not aware of a specific use case for it, I would be glad to hear more.

Last point, if you do not have ctest installed or you want the most recent one, you can use the get-cmake action to add ctest in the PATH.

vadi2 commented 4 years ago

Did you mean cmakeAppendedArgs?

I tried cmakeAppendedArgs: --target test -G Ninja -DCMAKE_PREFIX_PATH=${{runner.workspace}}/Qt/${{env.qt}}/${{matrix.compiler}}/ but it didn't seem to do it: https://github.com/Mudlet/Mudlet/pull/3790/checks?check_run_id=680550950

Happy to add a separate run action either way, it'll just be a nice perk if one didn't have to.

lukka commented 4 years ago

Here there is an example: https://github.com/OPM/ResInsight/blob/dev/.github/workflows/main.yml#L64

vadi2 commented 4 years ago

Thanks :)

After looking at it, I realised a separate action is better for visibility anyway :sweat_smile: