omg cmake.yml #6
This file contains hidden or 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: CI | |
on: | |
pull_request: | |
branches: | |
- master | |
types: [opened, synchronize, labeled] | |
push: | |
branches: | |
- master | |
jobs: | |
clang-format: | |
name: Check clang-format | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install clang-format | |
run: sudo apt-get update && sudo apt-get install -y clang-format | |
- name: Check formatting | |
run: | | |
git fetch --depth=1 origin master | |
FILES=$(git ls-files '*.cpp' '*.hpp' '*.h' '*.ixx') | |
if [ -n "$FILES" ]; then | |
clang-format -style=file -output-replacements-xml $FILES | grep "<replacement " >/dev/null \ | |
&& { echo "Code is not properly formatted"; exit 1; } \ | |
|| echo "All good" | |
else | |
echo "No files to format" | |
fi | |
build: | |
name: Build project | |
runs-on: ${{ matrix.os }} | |
if: github.event_name == 'push' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-ci')) | |
strategy: | |
matrix: | |
include: | |
- os: windows-latest | |
compiler: msvc | |
- os: windows-latest | |
compiler: clang | |
- os: ubuntu-latest | |
compiler: clang | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup CMake | |
uses: jwlawson/actions-setup-cmake@v2 | |
with: | |
cmake-version: '3.29.0' | |
- name: Install compiler on Ubuntu | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
if [ "${{ matrix.compiler }}" == "clang" ]; then | |
sudo apt-get install -y clang | |
fi | |
shell: bash | |
- name: Configure (Ubuntu + clang) | |
if: matrix.os == 'ubuntu-latest' && matrix.compiler == 'clang' | |
run: | | |
mkdir build | |
cd build | |
cmake -G Ninja -DCMAKE_CXX_COMPILER=clang++ .. | |
shell: bash | |
- name: Configure (Windows + msvc) | |
if: matrix.os == 'windows-latest' && matrix.compiler == 'msvc' | |
run: | | |
mkdir build | |
cd build | |
cmake -G "Visual Studio 17 2022" -A x64 .. | |
shell: pwsh | |
- name: Configure (Windows + clang) | |
if: matrix.os == 'windows-latest' && matrix.compiler == 'clang' | |
run: | | |
mkdir build | |
cd build | |
cmake -G Ninja -DCMAKE_CXX_COMPILER=clang++ .. | |
shell: pwsh | |
- name: Build | |
run: cmake --build build --config Release | |
shell: bash |