Skip to content

Commit

Permalink
Add build and test GitHub Action
Browse files Browse the repository at this point in the history
  • Loading branch information
jkurdek authored Aug 16, 2024
2 parents 5a1d7ff + f35004f commit b4d28ac
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 13 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/cmake-single-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
name: CMake on a single platform

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build-and-test:
runs-on: ubuntu-latest
env:
VCPKG_ROOT: ${{ github.workspace }}/vcpkg

steps:
- uses: actions/checkout@v4

- name: Set up CMake
uses: lukka/get-cmake@latest

- name: Restore from cache and install vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: 73964f854d0d6424f335e9515b61b3a2dad5e15b
vcpkgJsonGlob: '**/vcpkg.json'

- name: Run CMake consuming CMakePreset.json and run vcpkg to build packages
uses: lukka/run-cmake@v10
with:
configurePreset: 'linux-x64'

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest --output-on-failure
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)

add_compile_options(-Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic)

find_package(gtest CONFIG REQUIRED)
find_package(rapidjson CONFIG REQUIRED)
find_package(GTest CONFIG REQUIRED)
find_package(RapidJSON CONFIG REQUIRED)

enable_testing()

Expand Down
45 changes: 34 additions & 11 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
{
"version": 2,
"configurePresets": [
{
"name": "default",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
"version": 3,
"configurePresets": [
{
"name": "base",
"hidden": true,
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"type": "FILEPATH"
}
},
"binaryDir": "${sourceDir}/build"

},
{
"name": "macos-arm",
"inherits": "base",
"description": "Preset for ARM macOS",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_SYSTEM_NAME": "Darwin",
"VCPKG_TARGET_TRIPLET": "arm64-osx"
}
]
}

},
{
"name": "linux-x64",
"inherits": "base",
"description": "Preset for x64 Linux",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_SYSTEM_NAME": "Linux",
"VCPKG_TARGET_TRIPLET": "x64-linux"
}
}
]
}

0 comments on commit b4d28ac

Please sign in to comment.