Skip to content

A reusable workflow to build and test C++ projects

License

Notifications You must be signed in to change notification settings

brobeson/CppWorkflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ Workflows

Workflow Quality GitHub Release

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.

C++ Build

Getting Started

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

Inputs

  • 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 the CMAKE_BUILD_TYPE! That is done by the build-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}}

Steps

The workflow runs the following steps.

  1. Configure the Build System
    The workflow runs CMake to configure the build system.
  2. Build the Project
    The workflow runs CMake to invoke the underlying build tool (GCC, MSVC, etc.).
  3. Run Tests
    The workflow runs tests via CTest.

Build All The Things

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

Getting Started

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

Inputs

Steps

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.

Static Analysis

Getting Started

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

Inputs

This workflow does not have any input options.

Steps

  1. Check C++ Code Format
    This steps runs clang-format. It does not reformat and commit your code; it just reports files are incorrectly formatted.

Issue Tracking

GitHub Issues or Pull Requests by label GitHub Issues or Pull Requests by label GitHub Issues or Pull Requests by label GitHub milestone details

Report a bug | Request a new step | Update an existing step

About

A reusable workflow to build and test C++ projects

Topics

Resources

License

Stars

Watchers

Forks