Skip to content

Commit 54357ac

Browse files
committed
add ci
1 parent ca0e2cc commit 54357ac

File tree

4 files changed

+280
-1
lines changed

4 files changed

+280
-1
lines changed

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Checks: >
1414
-cppcoreguidelines-pro-type-union-access,
1515
-cppcoreguidelines-pro-type-vararg,
1616
misc-*,
17+
-misc-include-cleaner,
1718
-misc-non-private-member-variables-in-classes,
1819
-misc-no-recursion,
1920
modernize-*,

.clangd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Turn off include cleaner for now, since it can't handle exports yet, required to use a pch
2+
Diagnostics:
3+
UnusedIncludes: None
4+
---
15
If:
26
PathMatch: src/pch.h
37
CompileFlags:

.cruft.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "[email protected]:bl-sdk/common_dotfiles.git",
3-
"commit": "c6cad57d450e0b696fb8586daaf29814427ef7c1",
3+
"commit": "a66f9767ed477bfa89d6ca505392d226ebdd4275",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {

.github/workflows/build.yml

Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
name: CI
2+
3+
on: [
4+
push,
5+
pull_request,
6+
workflow_dispatch
7+
]
8+
9+
env:
10+
# Important to pin the clang version, cause we also use it for linting
11+
CLANG_VERSION: 17
12+
CLANG_TIDY_JOBS: 4
13+
# Since we use rather new c++ features, we need a rather new version of MinGW
14+
# LLVM MinGW seems to be the newest prebuilt binaries around
15+
LLVM_MINGW_VERSION: llvm-mingw-20230919-msvcrt-ubuntu-20.04-x86_64
16+
LLVM_MINGW_DOWNLOAD: https://github.com/mstorsjo/llvm-mingw/releases/download/20230919/llvm-mingw-20230919-msvcrt-ubuntu-20.04-x86_64.tar.xz
17+
# xwin settings
18+
XWIN_VERSION: xwin-0.3.1-x86_64-unknown-linux-musl
19+
XWIN_DOWNLOAD: https://github.com/Jake-Shadle/xwin/releases/download/0.3.1/xwin-0.3.1-x86_64-unknown-linux-musl.tar.gz
20+
21+
jobs:
22+
cache-clang:
23+
runs-on: windows-latest
24+
25+
steps:
26+
- name: Cache Clang
27+
uses: actions/cache@v3
28+
id: cache-clang
29+
with:
30+
path: C:\Program Files\LLVM
31+
key: ${{ runner.os }}-clang-${{ env.CLANG_VERSION }}
32+
lookup-only: true
33+
34+
- name: Setup Clang
35+
if: steps.cache-clang.outputs.cache-hit != 'true'
36+
uses: egor-tensin/setup-clang@v1
37+
with:
38+
version: ${{ env.CLANG_VERSION }}
39+
40+
# ==============================================================================
41+
42+
build-windows:
43+
runs-on: windows-latest
44+
needs: cache-clang
45+
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
preset: [
50+
"clang-x86-release",
51+
"clang-x64-release",
52+
"msvc-x86-release",
53+
"msvc-x64-release",
54+
]
55+
56+
steps:
57+
- name: Restore Clang Cache
58+
if: contains(matrix.preset, 'clang')
59+
uses: actions/cache/restore@v3
60+
with:
61+
path: C:\Program Files\LLVM
62+
key: ${{ runner.os }}-clang-${{ env.CLANG_VERSION }}
63+
fail-on-cache-miss: true
64+
65+
- name: Add MSVC to PATH
66+
if: contains(matrix.preset, 'msvc')
67+
uses: TheMrMilchmann/setup-msvc-dev@v2
68+
with:
69+
arch: ${{ fromJSON('["x86", "x64"]')[contains(matrix.preset, 'x64')] }}
70+
71+
- name: Setup CMake and Ninja
72+
uses: lukka/get-cmake@latest
73+
74+
- name: Checkout repository and submodules
75+
uses: actions/checkout@v3
76+
with:
77+
submodules: recursive
78+
79+
- name: Configure CMake
80+
working-directory: ${{ env.GITHUB_WORKSPACE }}
81+
run: cmake . --preset ${{ matrix.preset }}
82+
83+
- name: Build
84+
working-directory: ${{ env.GITHUB_WORKSPACE }}
85+
run: cmake --build out/build/${{ matrix.preset }} --target install
86+
87+
- name: Upload artifact
88+
uses: actions/upload-artifact@v3
89+
with:
90+
name: ${{ matrix.preset }}
91+
path: out/install/${{ matrix.preset }}/
92+
93+
build-ubuntu:
94+
runs-on: ubuntu-latest
95+
96+
strategy:
97+
fail-fast: false
98+
matrix:
99+
preset: [
100+
"mingw-x86-release",
101+
"mingw-x64-release",
102+
"clang-cross-x86-release",
103+
"clang-cross-x64-release",
104+
]
105+
106+
steps:
107+
- name: Setup CMake and Ninja
108+
uses: lukka/get-cmake@latest
109+
110+
# Both Clang and MinGW install quick enough that it's not worth caching
111+
# Caching would also lose the +x - so we'd have to tar before caching/untar after, making it
112+
# even slower
113+
- name: Setup Clang
114+
if: contains(matrix.preset, 'clang')
115+
run: |
116+
wget https://apt.llvm.org/llvm.sh
117+
chmod +x llvm.sh
118+
sudo ./llvm.sh ${{ env.CLANG_VERSION }}
119+
120+
sudo update-alternatives --install \
121+
/usr/bin/clang \
122+
clang \
123+
/usr/bin/clang-${{ env.CLANG_VERSION }} \
124+
200
125+
sudo update-alternatives --install \
126+
/usr/bin/clang++ \
127+
clang++ \
128+
/usr/bin/clang++-${{ env.CLANG_VERSION }} \
129+
200
130+
sudo update-alternatives --install \
131+
/usr/bin/llvm-rc \
132+
llvm-rc \
133+
/usr/bin/llvm-rc-${{ env.CLANG_VERSION }} \
134+
200
135+
136+
- name: Setup MinGW
137+
if: contains(matrix.preset, 'mingw')
138+
run: |
139+
wget -nv ${{ env.LLVM_MINGW_DOWNLOAD }}
140+
tar -xf ${{ env.LLVM_MINGW_VERSION }}.tar.xz -C ~/
141+
echo $(readlink -f ~/${{ env.LLVM_MINGW_VERSION }}/bin) >> $GITHUB_PATH
142+
143+
# xwin does take long enough that caching's worth it
144+
- name: Restore xwin cache
145+
if: contains(matrix.preset, 'cross')
146+
uses: actions/cache@v3
147+
id: cache-xwin
148+
with:
149+
path: ~/xwin
150+
key: ${{ runner.os }}-xwin
151+
152+
- name: Setup xwin
153+
if: contains(matrix.preset, 'cross') && steps.cache-xwin.outputs.cache-hit != 'true'
154+
run: |
155+
wget -nv ${{ env.XWIN_DOWNLOAD }}
156+
tar -xf ${{ env.XWIN_VERSION }}.tar.gz
157+
${{ env.XWIN_VERSION }}/xwin \
158+
--accept-license \
159+
--arch x86,x86_64 \
160+
splat \
161+
--include-debug-libs \
162+
--output ~/xwin
163+
164+
- name: Checkout repository and submodules
165+
uses: actions/checkout@v3
166+
with:
167+
submodules: recursive
168+
169+
- name: Configure CMake
170+
working-directory: ${{ env.GITHUB_WORKSPACE }}
171+
# The extra xwin dir arg won't do anything if we're not cross compiling
172+
run: >
173+
cmake .
174+
--preset ${{ matrix.preset }}
175+
-G Ninja
176+
-DXWIN_DIR=$(readlink -f ~)/xwin
177+
178+
- name: Build
179+
working-directory: ${{ env.GITHUB_WORKSPACE }}
180+
run: cmake --build out/build/${{ matrix.preset }} --target install
181+
182+
- name: Upload artifact
183+
uses: actions/upload-artifact@v3
184+
with:
185+
name: ${{ matrix.preset }}
186+
path: out/install/${{ matrix.preset }}/
187+
188+
# ==============================================================================
189+
190+
clang-tidy:
191+
runs-on: windows-latest
192+
needs: cache-clang
193+
194+
strategy:
195+
fail-fast: false
196+
matrix:
197+
preset: [
198+
"clang-x86-release",
199+
"clang-x64-release",
200+
]
201+
202+
steps:
203+
- name: Restore Clang Cache
204+
uses: actions/cache/restore@v3
205+
with:
206+
path: C:\Program Files\LLVM
207+
key: ${{ runner.os }}-clang-${{ env.CLANG_VERSION }}
208+
fail-on-cache-miss: true
209+
210+
- name: Setup CMake and Ninja
211+
uses: lukka/get-cmake@latest
212+
213+
# Needed for clang tidy to enable `-export-fixes`
214+
- name: Install pyyaml
215+
run: pip install pyyaml
216+
217+
- name: Checkout repository and submodules
218+
uses: actions/checkout@v3
219+
with:
220+
submodules: recursive
221+
222+
- name: Configure CMake
223+
working-directory: ${{ env.GITHUB_WORKSPACE }}
224+
run: cmake . --preset ${{ matrix.preset }} -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On
225+
226+
- name: Run clang-tidy
227+
working-directory: ${{ env.GITHUB_WORKSPACE }}
228+
run: |
229+
python (Get-Command run-clang-tidy).Source `
230+
-j ${{ env.CLANG_TIDY_JOBS }} `
231+
-p "out\build\${{ matrix.preset }}" `
232+
-export-fixes clang-tidy-fixes.yml `
233+
$([Regex]::Escape("$pwd\src") + ".+\.(c|cpp|h|hpp)$")
234+
235+
- name: Process clang-tidy warnings
236+
uses: asarium/clang-tidy-action@v1
237+
with:
238+
fixesFile: clang-tidy-fixes.yml
239+
240+
clang-format:
241+
runs-on: windows-latest
242+
needs: cache-clang
243+
244+
steps:
245+
- name: Restore Clang Cache
246+
uses: actions/cache/restore@v3
247+
with:
248+
path: C:\Program Files\LLVM
249+
key: ${{ runner.os }}-clang-${{ env.CLANG_VERSION }}
250+
fail-on-cache-miss: true
251+
252+
- name: Checkout repository
253+
uses: actions/checkout@v3
254+
255+
- name: Run clang-format
256+
run: |
257+
clang-format `
258+
-n -Werror `
259+
$(Get-ChildItem `
260+
src `
261+
-File `
262+
-Recurse `
263+
-Include ("*.c", "*.cpp", "*.h", "*.hpp") `
264+
| % FullName)
265+
266+
spelling:
267+
runs-on: ubuntu-latest
268+
269+
steps:
270+
- name: Checkout repository
271+
uses: actions/checkout@v3
272+
273+
- name: Check spelling
274+
uses: crate-ci/typos@master

0 commit comments

Comments
 (0)