3232 vcpkg-windows-${{ hashFiles('vcpkg.json') }}-
3333 vcpkg-windows-
3434
35- - name : Prepare build.ps1 from build.default.ps1
36- shell : pwsh
37- run : |
38- Copy-Item build.default.ps1 build.ps1
39- (Get-Content build.ps1) -replace '^\$VCPKG_PATH\s*=.*', '$VCPKG_PATH = "${{ env.VCPKG_ROOT }}"' | Set-Content build.ps1
40-
41- - name : Build Project (PowerShell)
42- shell : pwsh
43- run : ./build.ps1
44-
45- - name : Run Game Executable Test
46- working-directory : build/bin/Debug
47- run : |
48- # Keep --test flag for now to avoid audio issues in CI
49- ./meowstro.exe --test
50-
51- - name : Run cppcheck (static analysis)
35+ - name : Run cppcheck (static analysis - fail fast)
5236 run : |
5337 if (!(Get-Command cppcheck -ErrorAction SilentlyContinue)) {
5438 choco install cppcheck -y
5943 -I "${{ env.VCPKG_ROOT }}/installed/x64-windows/include" `
6044 src
6145
62- - name : Run clang-tidy (static analysis)
46+ - name : Cache CMake build directory
47+ uses : actions/cache@v4
48+ with :
49+ path : build
50+ key : cmake-windows-${{ hashFiles('**/CMakeLists.txt', 'vcpkg.json') }}-${{ hashFiles('src/**', 'include/**') }}
51+ restore-keys : |
52+ cmake-windows-${{ hashFiles('**/CMakeLists.txt', 'vcpkg.json') }}-
53+ cmake-windows-
54+
55+ - name : Prepare build.ps1 from build.default.ps1
56+ shell : pwsh
57+ run : |
58+ Copy-Item build.default.ps1 build.ps1
59+ (Get-Content build.ps1) -replace '^\$VCPKG_PATH\s*=.*', '$VCPKG_PATH = "${{ env.VCPKG_ROOT }}"' | Set-Content build.ps1
60+
61+ - name : Configure CMake for clang-tidy
62+ shell : pwsh
63+ run : |
64+ # Configure CMake to generate compile_commands.json for clang-tidy
65+ cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug
66+
67+ - name : Run clang-tidy (static analysis after CMake configure)
6368 run : |
6469 if (!(Get-Command clang-tidy -ErrorAction SilentlyContinue)) {
6570 choco install llvm -y
@@ -70,10 +75,11 @@ jobs:
7075 Write-Host "No compilation database found, skipping clang-tidy"
7176 }
7277
73- - name : Run Unit Tests
78+ - name : Build and Test via Script
79+ shell : pwsh
7480 run : |
75- cd build
76- ctest --output-on-failure -C Debug
81+ # Run the test script which handles build, test execution, and CTest
82+ ./test.ps1
7783
7884 - name : Upload Executable Artifact (main branch only)
7985 if : github.ref == 'refs/heads/main'
8894 - name : Checkout Repository
8995 uses : actions/checkout@v4
9096
97+ - name : Cache APT packages
98+ uses : actions/cache@v4
99+ with :
100+ path : /var/cache/apt/archives
101+ key : apt-${{ runner.os }}-${{ hashFiles('**/CMakeLists.txt') }}
102+ restore-keys : |
103+ apt-${{ runner.os }}-
104+
91105 - name : Install SDL2 system packages and build tools
92106 run : |
93107 sudo apt-get update
@@ -99,120 +113,117 @@ jobs:
99113 libsdl2-image-dev \
100114 libsdl2-mixer-dev \
101115 libsdl2-ttf-dev \
116+ libgtest-dev \
117+ googletest \
102118 cppcheck \
103119 clang-tidy
104120
121+ - name : Run cppcheck (static analysis - fail fast)
122+ run : |
123+ cppcheck --enable=all --inconclusive --std=c++17 --quiet \
124+ -I include \
125+ src
126+
127+ - name : Cache CMake build directory
128+ uses : actions/cache@v4
129+ with :
130+ path : build
131+ key : cmake-linux-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('src/**', 'include/**') }}
132+ restore-keys : |
133+ cmake-linux-${{ hashFiles('**/CMakeLists.txt') }}-
134+ cmake-linux-
135+
105136 - name : Configure CMake (using system packages, NOT vcpkg)
106137 run : |
107138 # Explicitly avoid vcpkg by not setting CMAKE_TOOLCHAIN_FILE
108139 cmake -B build -S . \
109140 -DCMAKE_BUILD_TYPE=Debug \
110141 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
111142
112- - name : Build Project
113- run : cmake --build build --parallel $(nproc)
114-
115- - name : Run Game Executable Test
116- run : |
117- # Keep --test flag for now to avoid audio issues in CI
118- # Find the executable location (Linux builds to build/bin, not build/bin/Debug)
119- if [ -f "build/bin/Debug/meowstro" ]; then
120- build/bin/Debug/meowstro --test
121- elif [ -f "build/bin/meowstro" ]; then
122- build/bin/meowstro --test
123- else
124- echo "Main executable not found, checking build directory..."
125- find build -name "meowstro" -type f
126- exit 1
127- fi
128-
129- - name : Run cppcheck (static analysis)
130- run : |
131- cppcheck --enable=all --inconclusive --std=c++17 --quiet \
132- -I include \
133- src
134-
135- - name : Run clang-tidy (static analysis)
143+ - name : Run clang-tidy (static analysis after CMake configure)
136144 run : |
137145 if [ -f "build/compile_commands.json" ]; then
138146 find src -name '*.cpp' -exec clang-tidy -p build {} \;
139147 else
140148 echo "No compilation database found, skipping clang-tidy"
141149 fi
142150
143- - name : Run Unit Tests
151+ - name : Build and Test via Script
144152 run : |
145- cd build
146- ctest --output-on-failure
153+ # Make script executable and run it
154+ chmod +x ./test.sh
155+ ./test.sh
147156
148157 - name : Upload Executable Artifact (main branch only)
149158 if : github.ref == 'refs/heads/main'
150159 uses : actions/upload-artifact@v4
151160 with :
152161 name : meowstro-linux
153- path : |
154- build/bin/
155- !build/bin/**/*.o
156- !build/bin/**/*.a
162+ path : build/bin/Debug/
157163
158164 build-macos :
159165 runs-on : macos-latest
160166 steps :
161167 - name : Checkout Repository
162168 uses : actions/checkout@v4
163169
170+ - name : Cache Homebrew packages
171+ uses : actions/cache@v4
172+ with :
173+ path : |
174+ ~/Library/Caches/Homebrew
175+ /opt/homebrew/var/homebrew/locks
176+ key : brew-${{ runner.os }}-${{ hashFiles('**/CMakeLists.txt') }}
177+ restore-keys : |
178+ brew-${{ runner.os }}-
179+
164180 - name : Install SDL2 via Homebrew
165181 run : |
166182 brew install \
167183 sdl2 \
168184 sdl2_image \
169185 sdl2_mixer \
170186 sdl2_ttf \
187+ googletest \
171188 cppcheck \
172189 llvm
173190
191+ - name : Run cppcheck (static analysis - fail fast)
192+ run : |
193+ cppcheck --enable=all --inconclusive --std=c++17 --quiet \
194+ -I include \
195+ src
196+
197+ - name : Cache CMake build directory
198+ uses : actions/cache@v4
199+ with :
200+ path : build
201+ key : cmake-macos-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('src/**', 'include/**') }}
202+ restore-keys : |
203+ cmake-macos-${{ hashFiles('**/CMakeLists.txt') }}-
204+ cmake-macos-
205+
174206 - name : Configure CMake (Homebrew packages)
175207 run : |
176208 HOMEBREW_PREFIX=$(brew --prefix)
177209 cmake -B build -S . \
178210 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
211+ -DCMAKE_BUILD_TYPE=Debug \
179212 -DCMAKE_PREFIX_PATH="$HOMEBREW_PREFIX"
180213
181- - name : Build Project
182- run : cmake --build build --parallel $(sysctl -n hw.logicalcpu)
183-
184- - name : Run Game Executable Test
185- run : |
186- # Keep --test flag for now to avoid audio issues in CI
187- # Find the executable location for macOS
188- if [ -f "build/bin/Debug/meowstro" ]; then
189- build/bin/Debug/meowstro --test
190- elif [ -f "build/bin/meowstro" ]; then
191- build/bin/meowstro --test
192- else
193- echo "Main executable not found, checking build directory..."
194- find build -name "meowstro" -type f
195- exit 1
196- fi
197-
198- - name : Run cppcheck (static analysis)
199- run : |
200- cppcheck --enable=all --inconclusive --std=c++17 --quiet \
201- -I include \
202- src
203-
204- - name : Run clang-tidy (static analysis)
214+ - name : Run clang-tidy (static analysis after CMake configure)
205215 run : |
206216 if [ -f "build/compile_commands.json" ]; then
207217 $(brew --prefix llvm)/bin/clang-tidy -p build $(find src -name '*.cpp')
208218 else
209219 echo "No compilation database found, skipping clang-tidy"
210220 fi
211221
212- - name : Run Unit Tests
222+ - name : Build and Test via Script
213223 run : |
214- cd build
215- ctest --output-on-failure
224+ # Make script executable and run it
225+ chmod +x ./test.sh
226+ ./test.sh
216227
217228 - name : Upload Executable Artifact (main branch only)
218229 if : github.ref == 'refs/heads/main'
0 commit comments