GitHub Action
run-cmake
Before using this action, please consider reading and learning how to write a workflow which is directly using the well known tools you can run on your own machine, without relying on GitHub actions that you cannot run on your development machine. You can read more in this issue about it: #41
Build C++ software with the multi-platform run-cmake action by running CMake on GitHub workflows. Samples provided use GitHub hosted runners and Caching.
Good companions are the run-vcpkg action and the get-cmake action.
It is highly recommended to use both vcpkg as a submodule and a vcpkg.json manifest file to declaratively specify the dependencies.
# Sample when vcpkg is a submodule of your repository (highly recommended!)
jobs:
build:
env:
buildDir: '${{ github.workspace }}/build'
steps:
# Cache/Restore the vcpkg's build artifacts using a vcpkg.json manifest.
- name: Run vcpkg
uses: lukka/run-vcpkg@v6
with:
# Just install vcpkg for now, do not install any ports in this step yet.
setupOnly: true
# Location of the vcpkg as submodule of the repository.
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
# Since the cache must be invalidated when content of the vcpkg.json file changes, let's
# compute its hash and append this to the computed cache's key.
appendedCacheKey: ${{ hashFiles( '**/vcpkg.json' ) }}
vcpkgTriplet: ${{ matrix.triplet }}
# Ensure the vcpkg artifacts are cached, they are generated in the 'CMAKE_BINARY_DIR/vcpkg_installed'.
additionalCachedPaths: ${{ env.buildDir }}/vcpkg_installed
- name: 'Run CMake with Ninja, install dependencies with vcpkg, build with CMake'
uses: lukka/run-cmake@v3
with:
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
cmakeListsTxtPath: '${{ github.workspace }}/cmakesettings.json/CMakeLists.txt'
useVcpkgToolchainFile: true
cmakeAppendedArgs: '-GNinja'
buildDirectory: ${{ env.buildDir }}
# Or build multiple configurations out of a CMakeSettings.json file created with Visual Studio.
# cmakeListsOrSettingsJson: CMakeSettingsJson
# cmakeSettingsJsonPath: '${{ github.workspace }}/cmakesettings.json/CMakeSettings.json'
# configurationRegexFilter: '${{ matrix.configuration }}'
Features:
- run
cmake
to generate project files and to build the projects. Look to samples and to flowchart for details. - Automatic dump of log files created by
CMake
(e.g.,CMakeOutput.log
) andvcpkg
. The content of those files flow into the workflow output log. - Annotations for CMake errors/warnings and for build (gcc/msvc/clang) errors/warning are created inline in the changed source files the build run for, e.g.:
Description of all input parameters: action.yml
View the workflows based on the run-cmake and run-vcpkg actions.
CMakeLists.txt samples | |
---|---|
Linux/macOS/Windows, hosted runner, basic | |
Linux/macOS/Windows, hosted runner, advanced | |
Linux/macOS/Windows, hosted runner, with cache and vcpkg as submodule |
CMakeSettings.json samples | |
---|---|
Linux/macOS/Windows, hosted runner, with cache and vcpkg as submodule |
gulp 4 globally installed.
run-vcpkg
depends on public NPM packages published by lukka/run-cmake-vcpkg-action-libs in the GitHub Packages registry.
Unexpectedly, a public package still requires authentication when downloading it, hence if you want to npm install
those packages correctly, you need to obtain a token with read:packages
scope. Then create in the root of the repository a .npmrc
file with the following content:
//npm.pkg.github.com/:_authToken=YOURTOKEN @lukka:registry=https://npm.pkg.github.com/
Note: Never commit this .npmrc
file!
Build with tsc
running:
npm run build
Launch lint
by:
npm run lint
To build, lint validate and package the extension for release purpose, run:
npm run pack
To build, pack and test:
npm run test
To run test directly:
jest
Validation tests on various scenarios are run using the workflows of the Samples.
The software is provided as is, there is no warranty of any kind. All users are encouraged to improve the source code with fixes and new features.
All the content in this repository is licensed under the MIT License.
Copyright (c) 2019-2020-2021 Luca Cappa
Other than submitting a pull request, donating is another way to contribute to this project.