Skip to content

Commit c0ae543

Browse files
authored
Create cmake.yml
1 parent f87f59c commit c0ae543

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/cmake.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
types: [opened, synchronize, labeled]
8+
push:
9+
branches:
10+
- main
11+
12+
jobs:
13+
clang-format:
14+
name: Check clang-format
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Install clang-format
20+
run: sudo apt-get update && sudo apt-get install -y clang-format
21+
22+
- name: Check formatting
23+
run: |
24+
git fetch --depth=1 origin main
25+
clang-format -style=file -output-replacements-xml $(git ls-files '*.cpp' '*.h' '*.ixx' '*.hpp') | grep "<replacement " && echo "Code is not properly formatted" && exit 1 || echo "All good"
26+
27+
build:
28+
name: Build project
29+
runs-on: ${{ matrix.os }}
30+
if: github.event_name == 'push' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-ci'))
31+
strategy:
32+
matrix:
33+
os: [windows-latest, ubuntu-latest]
34+
compiler: [msvc, clang, gcc]
35+
36+
steps:
37+
- uses: actions/checkout@v3
38+
39+
- name: Setup CMake
40+
uses: jwlawson/actions-setup-cmake@v2
41+
42+
- name: Setup compiler
43+
run: |
44+
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
45+
if [ "${{ matrix.compiler }}" == "clang" ]; then
46+
sudo apt-get install -y clang
47+
elif [ "${{ matrix.compiler }}" == "gcc" ]; then
48+
sudo apt-get install -y g++
49+
fi
50+
fi
51+
shell: bash
52+
53+
- name: Configure CMake
54+
run: |
55+
mkdir build
56+
cd build
57+
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
58+
if [ "${{ matrix.compiler }}" == "clang" ]; then
59+
cmake -DCMAKE_CXX_COMPILER=clang++ ..
60+
elif [ "${{ matrix.compiler }}" == "gcc" ]; then
61+
cmake -DCMAKE_CXX_COMPILER=g++ ..
62+
else
63+
cmake ..
64+
fi
65+
else
66+
cmake ..
67+
fi
68+
shell: bash
69+
70+
- name: Build
71+
run: cmake --build build --config Release
72+
shell: bash

0 commit comments

Comments
 (0)