|
| 1 | +name: build-macos-latest |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +env: |
| 6 | + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) |
| 7 | + BUILD_TYPE: Release |
| 8 | + |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + # The CMake configure and build commands are platform agnostic and should work equally |
| 13 | + # well on Windows or Mac. You can convert this to a matrix build if you need |
| 14 | + # cross-platform coverage. |
| 15 | + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix |
| 16 | + runs-on: macos-latest |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + compiler: [gcc, clang] |
| 20 | + include: |
| 21 | + - compiler: gcc |
| 22 | + cc: gcc |
| 23 | + cxx: g++ |
| 24 | + - compiler: clang |
| 25 | + cc: clang |
| 26 | + cxx: clang++ |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v2 |
| 29 | + with: |
| 30 | + submodules: 'recursive' |
| 31 | + |
| 32 | + - name: Install libraries |
| 33 | + run: | |
| 34 | + checkPkgAndInstall() |
| 35 | + { |
| 36 | + while [ $# -ne 0 ] |
| 37 | + do |
| 38 | + rm -f '/usr/local/bin/2to3' |
| 39 | + if brew ls --versions $1 ; then |
| 40 | + brew upgrade $1 |
| 41 | + else |
| 42 | + brew install $1 |
| 43 | + fi |
| 44 | + shift |
| 45 | + done |
| 46 | + } |
| 47 | + checkPkgAndInstall ccache cmake cunit |
| 48 | +
|
| 49 | + - name: Create Build Environment |
| 50 | + # Some projects don't allow in-source building, so create a separate build directory |
| 51 | + # We'll use this as our working directory for all subsequent commands |
| 52 | + run: cmake -E make_directory ${{github.workspace}}/build |
| 53 | + |
| 54 | + - name: Configure CMake |
| 55 | + # Use a bash shell so we can use the same syntax for environment variable |
| 56 | + # access regardless of the host operating system |
| 57 | + shell: bash |
| 58 | + working-directory: ${{github.workspace}}/build |
| 59 | + # Note the current convention is to use the -S and -B options here to specify source |
| 60 | + # and build directories, but this is only available with CMake 3.13 and higher. |
| 61 | + # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 |
| 62 | + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE |
| 63 | + |
| 64 | + - name: Build |
| 65 | + working-directory: ${{github.workspace}}/build |
| 66 | + shell: bash |
| 67 | + # Execute the build. You can specify a specific target with "--target <NAME>" |
| 68 | + run: cmake --build . --config $BUILD_TYPE |
| 69 | + |
| 70 | + - name: Test |
| 71 | + working-directory: ${{github.workspace}}/build |
| 72 | + shell: bash |
| 73 | + # Execute tests defined by the CMake configuration. |
| 74 | + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail |
| 75 | + run: ctest -C $BUILD_TYPE --output-on-failure --test-dir tests |
0 commit comments