Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub actions #172

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: CMake

on: [push, pull_request]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}

strategy:
fail-fast: false
matrix:
config:
- {
name: "Linux g++ 10.2",
os: ubuntu-20.04,
cxx: "g++-10",
}
- {
name: "Linux clang-10",
os: ubuntu-20.04,
cxx: "clang++-10",
cxx_flags: -stdlib=libc++,
exe_linker_flags: -lc++,
}
- {
name: "Linux clang-11",
os: ubuntu-20.04,
cxx: "clang++-11",
cxx_flags: -stdlib=libc++,
exe_linker_flags: -lc++,
}
- {
name: "Windows MSVC 2017 (x64)",
os: windows-2016,
cxx: "cl",
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Auxiliary/Build/vcvars64.bat",
}
- {
name: "Windows MSVC 2019 (x64)",
os: windows-latest,
cxx: "cl",
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat",
}

steps:
- uses: actions/checkout@v2

- name: Install Clang 10
id: install_clang_10
if: startsWith(matrix.config.os, 'ubuntu') && ( matrix.config.cxx == 'clang++-10' )
shell: bash
working-directory: ${{ env.HOME }}
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 10
sudo apt-get install libc++-10-dev libc++abi-10-dev

- name: Install Clang 11
id: install_clang_11
if: startsWith(matrix.config.os, 'ubuntu') && ( matrix.config.cxx == 'clang++-11' )
shell: bash
working-directory: ${{ env.HOME }}
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 11
sudo apt-get install libc++-11-dev libc++abi-11-dev

- name: Install g++ 10
id: install_gcc_10
if: startsWith(matrix.config.os, 'ubuntu') && ( matrix.config.cxx == 'g++-10' )
shell: bash
working-directory: ${{ env.HOME }}
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
sudo apt-get install g++-10

- 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
env:
CXX: ${{ matrix.config.cxx }}
# 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: |
# run environment setup script if any
[ -n "${{ matrix.config.environment_script }}" ] && "${{ matrix.config.environment_script }}"

cmake $GITHUB_WORKSPACE \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DCMAKE_CXX_STANDARD=20 \
-DBUILD_TESTING=ON \
-DCMAKE_CXX_FLAGS=${{ matrix.config.cxx_flags }} \
-DCMAKE_EXE_LINKER_FLAGS=${{ matrix.config.exe_linker_flags }} \
-DCMAKE_VERBOSE_MAKEFILE=ON

- 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 $BUILD_TYPE

- 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 --output-on-failure -C $BUILD_TYPE