|
| 1 | +name: Build and test (cmake based build) |
| 2 | + |
| 3 | +#on: push |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [ "master" ] |
| 7 | + pull_request: |
| 8 | + branches: [ "master" ] |
| 9 | + |
| 10 | +env: |
| 11 | + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) |
| 12 | + BUILD_TYPE: Release |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. |
| 17 | + # You can convert this to a matrix build if you need cross-platform coverage. |
| 18 | + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix |
| 19 | + runs-on: ${{ matrix.os }} |
| 20 | + strategy: |
| 21 | + fail-fast: true |
| 22 | + matrix: |
| 23 | + os: [ ubuntu-latest, ubuntu-20.04, |
| 24 | + macos-latest, macos-11, |
| 25 | + windows-latest |
| 26 | + ] |
| 27 | + # ubuntu-18.04 does not work due to compile error on asio |
| 28 | + # windows-2019 not included to spare free minutes |
| 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 | + elif [ "$RUNNER_OS" == "Windows" ]; then |
| 39 | + VCPKG_DEFAULT_TRIPLET=x64-windows vcpkg install |
| 40 | + elif [ "$RUNNER_OS" == "macOS" ]; then |
| 41 | + brew install asio |
| 42 | + else |
| 43 | + echo "$RUNNER_OS not supported" |
| 44 | + exit 1 |
| 45 | + fi |
| 46 | + shell: bash |
| 47 | + |
| 48 | + - name: Configure CMake |
| 49 | + run: | |
| 50 | + if [ "$RUNNER_OS" == "Windows" ]; then |
| 51 | + cmake -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -B build |
| 52 | + else |
| 53 | + cmake -B build |
| 54 | + fi |
| 55 | + shell: bash |
| 56 | + - name: Build |
| 57 | + # Build your program with the given configuration |
| 58 | + run: cmake --build build --config ${{env.BUILD_TYPE}} |
| 59 | + shell: bash |
| 60 | + |
| 61 | + - name: Test |
| 62 | + working-directory: ${{github.workspace}}/build |
| 63 | + # Execute tests defined by the CMake configuration. |
| 64 | + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail |
| 65 | + run: ctest --output-on-failure -C ${{env.BUILD_TYPE}} |
| 66 | + |
| 67 | + #- name: Package |
| 68 | + # working-directory: ${{github.workspace}}/build |
| 69 | + # run: | |
| 70 | + # cmake --build . --target ALL_BUILD && \ |
| 71 | + # cmake --build . --target doc && \ |
| 72 | + # cmake --build . --target package && \ |
| 73 | + # cpack --config CPackSourceConfig.cmake |
0 commit comments