11# *********************************************************************/
2- # CI Pipeline - .NET + API Integration Tests */
3- # */
4- # Purpose : Orchestrates the compilation of native C++ assets and */
5- # executes the .NET integration test suite. */
6- # Trigger : Push to main/develop | Pull Request to main */
7- # Runtime : Ubuntu Latest */
8- # */
9- # Notes : - Manages the critical injection of .so artifacts into */
10- # the .NET bin directory for P/Invoke resolution. */
11- # - Updated for Monorepo (backend/ subdirectory). */
12- # */
13- # Revision History: */
14- # ------------------------------------------------------------------ */
15- # Version Date Author Description */
16- # ------------------------------------------------------------------ */
17- # 1.0 2026-04-14 Nitish Singh Initial .NET Integration CI */
18- # 1.1 2026-04-15 Nitish Singh Updated for /backend path */
2+ # CI Pipeline - .NET + API Integration Tests (Multi-Platform) */
3+ # */
4+ # Purpose : Validates the P/Invoke bridge and API logic across */
5+ # Ubuntu, macOS, and Windows environments. */
6+ # Trigger : Push to main/develop | Pull Request to main */
7+ # Runtime : Matrix (Ubuntu, macOS, Windows) */
8+ # */
9+ # Notes : - Synchronizes Native & Managed build cycles. */
10+ # - Implements cross-platform artifact injection. */
11+ # - Fixes Windows C2491 via PROCESSSTRING_EXPORTS. */
12+ # */
13+ # Revision History: */
14+ # ------------------------------------------------------------------ */
15+ # Version Date Author Description */
16+ # ------------------------------------------------------------------ */
17+ # 1.0 2026-04-14 Nitish Singh Initial .NET Integration CI*/
18+ # 1.1 2026-04-15 Nitish Singh Updated for /backend path */
19+ # 1.2 2026-04-16 Nitish Singh Multi-Platform Matrix Fix */
1920# *********************************************************************/
2021
2122name : .NET Tests
2829
2930jobs :
3031 test :
31- runs-on : ubuntu-latest
32+ name : Test on ${{ matrix.os }}
33+ strategy :
34+ fail-fast : false
35+ matrix :
36+ os : [ubuntu-latest, macos-latest, windows-latest]
37+ runs-on : ${{ matrix.os }}
3238
3339 steps :
3440 # ======================================================
35- # 1. REPOSITORY & NATIVE TOOLCHAIN
41+ # 1. REPOSITORY & TOOLCHAIN SETUP
3642 # ======================================================
37-
3843 - name : Checkout code
3944 uses : actions/checkout@v4
4045
41- - name : Build C++ Library
42- working-directory : backend/CaseConversionAPI/CppLib
43- run : |
44- mkdir -p build
45- cd build
46- cmake ..
47- cmake --build . --config Release
48-
49- # ======================================================
50- # 2. MANAGED ENVIRONMENT SETUP
51- # ======================================================
52-
5346 - name : Setup .NET Environment
5447 uses : actions/setup-dotnet@v4
5548 with :
5649 dotnet-version : " 8.0.x"
5750
51+ # ======================================================
52+ # 2. NATIVE LAYER BUILD (C++17)
53+ # ======================================================
54+ - name : Build C++ Library (Unix)
55+ if : runner.os != 'Windows'
56+ working-directory : backend/CaseConversionAPI/CppLib
57+ run : |
58+ cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
59+ cmake --build build --config Release --parallel
60+
61+ - name : Build C++ Library (Windows)
62+ if : runner.os == 'Windows'
63+ working-directory : backend/CaseConversionAPI/CppLib
64+ # -DPROCESSSTRING_EXPORTS is critical to resolve Error C2491 on MSVC
65+ run : |
66+ cmake -S . -B build `
67+ -DCMAKE_BUILD_TYPE=Release `
68+ -DPROCESSSTRING_EXPORTS=ON `
69+ -D_CRT_SECURE_NO_WARNINGS=ON `
70+ -G "Visual Studio 17 2022" -A x64
71+ cmake --build build --config Release --parallel
72+
73+ # ======================================================
74+ # 3. MANAGED LAYER BUILD (.NET 8)
75+ # ======================================================
5876 - name : Build .NET Tests
5977 working-directory : backend/CaseConversionAPI/tests/DotNetTests
6078 run : |
6179 dotnet restore
6280 dotnet build --configuration Release
6381
6482 # ======================================================
65- # 3 . ARTIFACT INJECTION (P/INVOKE PREPARATION )
83+ # 4 . ARTIFACT INJECTION (ABI BRIDGE PREP )
6684 # ======================================================
67-
6885 - name : Inject Native Library to Test Folder
86+ shell : bash
6987 run : |
70- # Locate the native binary
71- LIB_PATH=$(find backend/CaseConversionAPI/CppLib/build -name "libProcessStringDLL.so")
72-
73- # Destination path within the .NET build output
88+ # Set target path within the .NET build output
7489 DEST_PATH="backend/CaseConversionAPI/tests/DotNetTests/bin/Release/net8.0/"
90+ mkdir -p $DEST_PATH
91+
92+ # Find the library based on platform extension
93+ if [ "${{ runner.os }}" == "Linux" ]; then
94+ LIB_FILE=$(find backend/CaseConversionAPI/CppLib/build -name "libProcessStringDLL.so" | head -n 1)
95+ elif [ "${{ runner.os }}" == "macOS" ]; then
96+ LIB_FILE=$(find backend/CaseConversionAPI/CppLib/build -name "libProcessStringDLL.dylib" | head -n 1)
97+ elif [ "${{ runner.os }}" == "Windows" ]; then
98+ # MSVC often puts binaries in /Release/ or /Debug/ subfolders
99+ LIB_FILE=$(find backend/CaseConversionAPI/CppLib/build -name "ProcessStringDLL.dll" | head -n 1)
100+ fi
101+
102+ if [ -z "$LIB_FILE" ]; then
103+ echo "[ERROR] Native library not found for ${{ runner.os }}"
104+ exit 1
105+ fi
106+
107+ echo "[INFO] Injecting $LIB_FILE into $DEST_PATH"
108+ cp "$LIB_FILE" "$DEST_PATH"
75109
76- echo "[INFO] Injecting $LIB_PATH into $DEST_PATH"
77- cp $LIB_PATH $DEST_PATH
78-
79- # Secondary copy for runner root fallback
80- cp $LIB_PATH backend/CaseConversionAPI/tests/DotNetTests/
110+ # Secondary copy for local P/Invoke resolution fallback
111+ cp "$LIB_FILE" "backend/CaseConversionAPI/tests/DotNetTests/"
81112
82113 # ======================================================
83- # 4 . TEST EXECUTION (INTEGRATION LAYER )
114+ # 5 . TEST EXECUTION (INTEGRATION SUITE )
84115 # ======================================================
85-
86116 - name : Run Integration Tests
87117 working-directory : backend/CaseConversionAPI/tests/DotNetTests
88118 run : dotnet test --no-build --configuration Release --verbosity normal
0 commit comments