This repository containers three reusable workflows to build and test a C++ project.
- C++ Build
This workflow implements one build & test pipeline. It requires inputs, such as the target operating system and the build type, to control the build. - Build All The Things
This workflow implements a matrix and runs the C++ build workflow for each matrix cell. - Static Analysis
This workflow runs static analysis tools on the C++ code.
To use the C++ Build workflow, just set it in the uses
key of a job in your project's workflow file.
Use the with
key to set the workflow input values.
Here is an example workflow snippet that calls this workflow:
jobs:
build:
name: C++ Build
uses: brobeson/CppWorkflow/.github/workflows/build_all_the_things.yaml@v1
with:
build-type: Debug
os: ubuntu-latest
build-type
- Required yes
- Type string
- Description This value is set as the
CMAKE_BUILD_TYPE
on the configuration command, the--config
option on the build command, and the--build-config
option on the test command. This must be a string that your CMake system understands.
configure-definitions
- Required no
- Type string
- Description This is CMake variable definitions to pass to the
cmake
configure command. This must be a single string, and must include the-D
part. Do not use this to set theCMAKE_BUILD_TYPE
! That is done by thebuild-type
input. - Example
with: configure-definitions: -D BUILD_TESTING:BOOL=on
os
- Required yes
- Type string
- Description This is the runner to use for the build job.
It must be a valid value for the GitHub workflow
runs-on
key.
Here is an example using a build matrix in a calling workflow to control the C++ build inputs:
jobs:
build:
name: C++ Build
strategy:
build-type: [Debug, MinSizeRel, Release, RelWithDebInfo]
os: [ubuntu-latest, macos-lates]
uses: brobeson/CppWorkflow/.github/workflows/build_all_the_things.yaml@v1
with:
build-type: ${{matrix.build-type}}
os: ${{matrix.os}}
The workflow runs the following steps.
- Configure the Build System
The workflow runs CMake to configure the build system. - Build the Project
The workflow runs CMake to invoke the underlying build tool (GCC, MSVC, etc.). - Run Tests
The workflow runs tests via CTest.
This workflow uses the following matrix to run the build workflow for multiple configurations. This is an easy way to get all these combinations without reimplementing the matrix in multiple C++ projects.
Debug | Release | |
---|---|---|
macos-latest | ✅ | ✅ |
ubuntu-latest | ✅ | ✅ |
windows-latest | ✅ | ✅ |
To use the Build All The Things workflow, just set it in the uses
key of a job in your project's workflow file.
Here is an example workflow snippet that calls this workflow:
jobs:
build:
name: C++ Build
uses: brobeson/CppWorkflow/.github/workflows/build_all_the_things.yaml@v1
configure-definitions
This is passed through to the C++ Build workflow. See that workflow's input documentation for details.
This workflow does not implement any steps. It invokes the C++ Build workflow for each cell in the matrix described above. See the C++ Build steps for details.
To use the C++ static analysis workflow, just set it in the uses
key of a job in your project's workflow file.
Here is an example workflow snippet that calls this workflow:
jobs:
build:
name: C++ Code Quality
uses: brobeson/CppWorkflow/.github/workflows/cpp_static_analysis.yaml@v1
This workflow does not have any input options.
- Check C++ Code Format
This steps runs clang-format. It does not reformat and commit your code; it just reports files are incorrectly formatted.