Build and test CMake #665
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and test CMake | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
schedule: | |
- cron: "30 8 * * *" | |
# From https://github.com/actions/starter-workflows/pull/47 | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-20.04, ubuntu-latest, macOS-latest, windows-latest] | |
python-version: [3.9] | |
build-type: [Release, Debug] | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install numpy scipy | |
- name: Create Build Environment | |
# Some projects don't allow in-source building, so create a separate build directory | |
# We'll use this as our working directory for all subsequent commands | |
run: cmake -E make_directory ${{runner.workspace}}/build | |
- name: Configure CMake | |
# Use a bash shell so we can use the same syntax for environment variable | |
# access regardless of the host operating system | |
shell: bash | |
working-directory: ${{runner.workspace}}/build | |
# Note the current convention is to use the -S and -B options here to specify source | |
# and build directories, but this is only available with CMake 3.13 and higher. | |
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12 | |
run: | | |
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DPython3_ROOT_DIR=${Python3_ROOT_DIR} | |
cat CMakeCache.txt | |
- name: Build | |
working-directory: ${{runner.workspace}}/build | |
shell: bash | |
# Execute the build. You can specify a specific target with "--target <NAME>" | |
run: cmake --build . --config ${{ matrix.build-type }} --parallel 2 | |
- name: List files | |
working-directory: ${{runner.workspace}}/build | |
shell: bash | |
run: find . | |
- name: Test | |
working-directory: ${{runner.workspace}}/build | |
shell: bash | |
# Execute tests defined by the CMake configuration. | |
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail | |
run: ctest -C ${{ matrix.build-type }} --parallel 2 --output-on-failure --repeat until-pass:3 | |