-
-
Notifications
You must be signed in to change notification settings - Fork 0
230 lines (219 loc) · 8.15 KB
/
builds.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
name: Builds
on:
push:
branches:
- "**"
tags:
- "*.*.*"
pull_request:
types: [opened, reopened]
defaults:
run:
shell: bash
env:
VCPKG_FETCH_DEPTH: 1 # Depth to fetch vcpkg commits, must include the baseline.
jobs:
CMake:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-24.04
triplet: x64-linux
shared: dynamic
config: Debug
- os: ubuntu-24.04
triplet: x64-linux
shared: static
config: Debug
- os: ubuntu-24.04
triplet: x64-linux
shared: dynamic
config: Release
- os: macos-14
triplet: arm64-osx
shared: static
config: Debug
- os: macos-14
triplet: arm64-osx
shared: dynamic
config: Release
- os: windows-2022
triplet: x64-windows
shared: static
config: Debug
- os: windows-2022
triplet: x64-windows
shared: dynamic
config: Release
env:
CMAKE_BUILD_DIR: build
VCPKG_ROOT: ${{github.workspace}}/vcpkg
VCPKG_LIBRARY_LINKAGE: ${{matrix.shared}}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Fetch Vcpkg commits
working-directory: vcpkg
run: git fetch --depth=${{env.VCPKG_FETCH_DEPTH}}
# Install latest CMake.
- uses: lukka/get-cmake@latest
# Restore both vcpkg and its artifacts from the GitHub cache service.
- name: Restore vcpkg and its artifacts.
uses: actions/cache@v4
with:
# The first path is where vcpkg generates artifacts while consuming the vcpkg.json manifest file.
# The second path is the location of vcpkg (it contains the vcpkg executable and data files).
# The other paths starting with '!' are exclusions: they contain temporary files generated during the build of the installed packages.
path: |
${{ env.CMAKE_BUILD_DIR }}/vcpkg_installed/
${{ env.VCPKG_ROOT }}
!${{ env.VCPKG_ROOT }}/buildtrees
!${{ env.VCPKG_ROOT }}/packages
!${{ env.VCPKG_ROOT }}/downloads
# The key is composed in a way that it gets properly invalidated: this must happen whenever vcpkg's Git commit id changes, or the list of packages changes. In this case a cache miss must happen and a new entry with a new key with be pushed to GitHub the cache service.
# The key includes: hash of the vcpkg.json file, the hash of the vcpkg Git commit id, and the used vcpkg's triplet. The vcpkg's commit id would suffice, but computing an hash out it does not harm.
# Note: given a key, the cache content is immutable. If a cache entry has been created improperly, in order the recreate the right content the key must be changed as well, and it must be brand new (i.e. not existing already).
key: |
${{ hashFiles( 'vcpkg_manifest/vcpkg.json', '.git/modules/vcpkg/HEAD' )}}-${{ matrix.triplet }}-invalidate
# On Windows runners, let's ensure to have the Developer Command Prompt environment setup correctly. As used here the Developer Command Prompt created is targeting x64 and using the default the Windows SDK.
- uses: ilammy/msvc-dev-cmd@v1
- name: CMake configure
run: |
cmake -S . -B ${{env.CMAKE_BUILD_DIR}} -GNinja \
-DVCPKG_TARGET_TRIPLET="${{ matrix.triplet }}" \
-DCMAKE_BUILD_TYPE=${{matrix.config}} \
-DCMAKE_INSTALL_PREFIX=local \
-DBUILD_SHARED_LIBS=${{ matrix.shared == 'dynamic' && 'TRUE' || 'FALSE' }} \
-DLIBTCODFOV_TESTS=ON \
-Wdev \
${{ matrix.cmake_extra_args }}
- name: CMake build
run: |
cmake --build ${{env.CMAKE_BUILD_DIR}}
- name: List build files
run: find ${{env.CMAKE_BUILD_DIR}}
- name: Run tests
env:
LD_LIBRARY_PATH: ${{env.CMAKE_BUILD_DIR}}/lib
run: |
${{env.CMAKE_BUILD_DIR}}/bin/unittest ~[!nonportable] ${{ matrix.config != 'Release' && '~[benchmark]' || '' }}
- name: CMake test install
run: |
cmake --install ${{env.CMAKE_BUILD_DIR}} --config ${{matrix.config}}
coverage:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-24.04
triplet: x64-linux
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Fetch Vcpkg commits
working-directory: vcpkg
run: git fetch --depth=${{env.VCPKG_FETCH_DEPTH}}
- name: Install the latest CMake
uses: lukka/get-cmake@latest
- name: Restore vcpkg and its artifacts.
uses: actions/cache@v4
with:
path: |
${{ env.CMAKE_BUILD_DIR }}/vcpkg_installed/
${{ env.VCPKG_ROOT }}
!${{ env.VCPKG_ROOT }}/buildtrees
!${{ env.VCPKG_ROOT }}/packages
!${{ env.VCPKG_ROOT }}/downloads
key: |
${{ hashFiles( 'vcpkg_manifest/vcpkg.json', '.git/modules/vcpkg/HEAD' )}}-${{ matrix.triplet }}-invalidate
- name: CMake configure
run: |
cmake . -GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="--coverage" \
-DCMAKE_C_FLAGS="--coverage" \
-DLIBTCODFOV_TESTS=ON \
-Wdev
- name: CMake build
run: |
cmake --build .
- name: Run tests
env:
LD_LIBRARY_PATH: lib
run: |
bin/unittest ~[!nonportable] ~[benchmark]
- name: List coverage files
run: find . | grep -e ".gc..$"
- name: Generate coverage data
run: gcov CMakeFiles/libtcod-fov.dir/src/libtcod-fov/**.o tests/CMakeFiles/unittest.dir/*.o
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
Autotools:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-24.04, macos-14]
steps:
- uses: actions/checkout@v4
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install APT dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install libsdl2-dev
- name: Install Brew dependencies
if: runner.os == 'macOS'
run: |
brew install automake sdl2 libtool
- name: libtoolize
run: ${{ runner.os == 'macOS' && 'glibtoolize' || 'libtoolize' }} --install
working-directory: buildsys/autotools
- name: Configure package
working-directory: buildsys/autotools
run: |
autoreconf --install
./configure --prefix=$HOME/.local
- name: Build package
working-directory: buildsys/autotools
run: |
make -j 3 install
- name: Run tests
working-directory: buildsys/autotools
run: |
make check
amalgam:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install cpp-amalgamate
run: |
wget --no-verbose https://github.com/Felerius/cpp-amalgamate/releases/download/1.0.1/cpp-amalgamate-x86_64-unknown-linux-gnu -O ~/cpp-amalgamate
chmod +x ~/cpp-amalgamate
- name: Generate source amalgam
run: ~/cpp-amalgamate -v src/libtcod-fov/*.c --dir-quote include/libtcod-fov --unresolvable-quote-include error -o libtcod-fov.c
- name: Generate header amalgam
run: ~/cpp-amalgamate -v include/libtcod-fov.h --unresolvable-quote-include error -o libtcod-fov.h
- name: Upload amalgams
uses: actions/upload-artifact@v4
with:
name: amalgams
path: |
libtcod-fov.h
libtcod-fov.c
if-no-files-found: error
- name: Test compile sources
run: gcc -c --std=c99 -Wall -Wextra libtcod-fov.c
- name: Test compile headers (C99)
run: gcc -c --std=c99 -Wall -Wextra libtcod-fov.h
- name: Test compile headers (C++17)
run: g++ -c --std=c++17 -Wall -Wextra libtcod-fov.h