Skip to content

Commit f939bf8

Browse files
committed
add action for build and test
1 parent a92aee4 commit f939bf8

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

.github/workflows/build_and_test.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Build and test (cmake based build)
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
env:
10+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
11+
BUILD_TYPE: Release
12+
13+
jobs:
14+
build:
15+
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
16+
# You can convert this to a matrix build if you need cross-platform coverage.
17+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
os: [ windows-latest, windows-2019,
23+
ubuntu-latest, ubuntu-20.04,
24+
macos-latest, macos-11, macos-10.15
25+
]
26+
# ubuntu-18.04 does not work due to compile error on asio
27+
# , windows-latest, windows-2019 - wip missing asio lib install
28+
29+
steps:
30+
- uses: actions/checkout@v3
31+
- name: Prepare dependencies
32+
run: |
33+
if [ "$RUNNER_OS" == "Linux" ]; then
34+
sudo apt-get update && \
35+
sudo apt-get install -yq \
36+
libasio-dev \
37+
cmake \
38+
graphviz doxygen
39+
elif [ "$RUNNER_OS" == "Windows" ]; then
40+
vcpkg install;
41+
choco install graphviz doxygen.install
42+
elif [ "$RUNNER_OS" == "macOS" ]; then
43+
brew install asio graphviz doxygen
44+
else
45+
echo "$RUNNER_OS not supported"
46+
exit 1
47+
fi
48+
shell: bash
49+
50+
- name: Configure CMake
51+
run: |
52+
if [ "$RUNNER_OS" == "Windows" ]; then
53+
mkdir build;
54+
cd build;
55+
cmake .. -DCMAKE_TOOLCHAIN_FILE="%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake" ..
56+
else
57+
cmake -B build
58+
fi
59+
# shell: bash
60+
- name: Build
61+
# Build your program with the given configuration
62+
run: cmake --build build --config ${{env.BUILD_TYPE}}
63+
shell: bash
64+
65+
- name: Test
66+
working-directory: ${{github.workspace}}/build
67+
# Execute tests defined by the CMake configuration.
68+
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
69+
run: ctest --output-on-failure -C ${{env.BUILD_TYPE}}
70+
71+
#- name: Package
72+
# working-directory: ${{github.workspace}}/build
73+
# run: |
74+
# cmake --build . --target ALL_BUILD && \
75+
# cmake --build . --target doc && \
76+
# cmake --build . --target package && \
77+
# cpack --config CPackSourceConfig.cmake

0 commit comments

Comments
 (0)