From 89da6d8d85767287b6f36be35b43b4f9ce108d41 Mon Sep 17 00:00:00 2001 From: Tlaloc <156491852+AlexGoodmen@users.noreply.github.com> Date: Fri, 22 Aug 2025 03:12:57 -0500 Subject: [PATCH] Update main.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build step Compiles your solution using MSBuild Adds include path GeneralsMD/Code/GameEngine/Source/GameClient Enables /p:TreatWarningsAsErrors=true so warnings fail the build Shows only errors and summary for clarity Static analysis Runs MSBuild’s built-in code analysis ruleset (you can customize this) Helps catch security and maintainability issues before merging ✔ Tests Automatically runs your executable with --test if it exists Prevents unnecessary failures if no tests are presentHow this helps developers: Detects errors early → Builds fail immediately on any warning or error Reduces debugging time → Catches incorrect includes, type mismatches, and bad code patterns before code lands in main Maintains quality → Static analysis adds an extra safety net --- .github/workflows/main.yml | 57 +++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 73ed51070de..9be1f3bf889 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Windows C++ Build +name: C/C++ CI on: push: @@ -11,18 +11,43 @@ jobs: runs-on: windows-latest steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up MinGW (G++) - uses: egor-tensin/setup-mingw@v2 - with: - version: 12.2.0 - platform: x64 - - - name: Compile with g++ - run: | - g++ -std=c++17 -Wall -Wextra ^ - WinMain.cpp ^ - Generals/Code/Main/*.cpp ^ - -o generals.exe + # ✅ Checkout the repository + - name: Checkout repository + uses: actions/checkout@v4 + + # ✅ Setup MSBuild for Visual Studio + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v1.1 + + # ✅ Compile in Release mode, treat warnings as errors, add new include path + - name: Build with MSBuild + run: | + msbuild #include "GeneralsMD/Code/GameEngine/Source/GameClient/" + + /p:Configuration=Release ` + /p:Platform="Win32" ` + /p:TreatWarningsAsErrors=true ` + /p:AdditionalIncludeDirectories="GeneralsMD/Code/GameEngine/Source/GameClient" ` + /m ` + /clp:ErrorsOnly;Summary + shell: pwsh + + # ✅ Run Static Analysis (optional but recommended) + - name: Run static analysis + run: | + msbuild #include "GeneralsMD/Code/GameEngine/Source/GameClient/" + + /p:RunCodeAnalysis=true ` + /p:CodeAnalysisRuleSet="AllRules.ruleset" ` + /p:AdditionalIncludeDirectories="GeneralsMD/Code/GameEngine/Source/GameClient" + shell: pwsh + + # ✅ Run tests (only if the compiled executable exists) + - name: Run tests + run: | + if (Test-Path ".\bin\Release\YourExecutable.exe") { + .\bin\Release\YourExecutable.exe --test + } else { + Write-Host "No tests found or build failed." + } + shell: pwsh