Skip to content

Windows Build and Unit Tests with MinGW #3

Windows Build and Unit Tests with MinGW

Windows Build and Unit Tests with MinGW #3

name: Windows Build and Unit Tests with MinGW
on:
workflow_dispatch:
jobs:
build_and_test_windows_mingw_64bit:
runs-on: windows-latest
name: Build and Test (64-bit MinGW)
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download and Setup MinGW-w64 (64-bit)
shell: pwsh
run: |
$MingwVersion = "x86_64-14.2.0-release-win32-seh-ucrt-rt_v12-rev0"
$MingwUrl = "https://github.com/niXman/mingw-builds-binaries/releases/download/14.2.0-rt_v12-rev0/$MingwVersion.7z"
$MingwDir = "$env:RUNNER_TEMP\mingw-w64"
# Download and extract MinGW-w64
Invoke-WebRequest -Uri $MingwUrl -OutFile "$env:RUNNER_TEMP\$MingwVersion.7z"
7z x "$env:RUNNER_TEMP\$MingwVersion.7z" -o$MingwDir
# Add MinGW to PATH
"$MingwDir\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Setup GTest
shell: bash
run: |
mkdir -p gtest-build
cd gtest-build
curl -L -o googletest-release-1.11.0.zip https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip
unzip googletest-release-1.11.0.zip
cd googletest-release-1.11.0
cmake -G "MinGW Makefiles" \
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX="C:/googletest"
cmake --build . --config Debug
cmake --install . --config Debug
cd ../..
- name: Build Project (64-bit MinGW)
shell: bash
run: |
cmake -G "MinGW Makefiles" \
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_PREFIX_PATH="C:/googletest/lib/cmake/GTest" \
-DTESTING_ENABLED=ON \
.
cmake --build . --config Debug
- name: Run Unit Tests (64-bit MinGW)
shell: bash
run: |
ctest -C Debug --output-on-failure
build_and_test_windows_mingw_32bit:
runs-on: windows-latest
name: Build and Test (32-bit MinGW)
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download and Setup MinGW-w64 (32-bit)
shell: pwsh
run: |
$MingwVersion = "i686-14.2.0-release-win32-dwarf-msvcrt-rt_v12-rev0"
$MingwUrl = "https://github.com/niXman/mingw-builds-binaries/releases/download/14.2.0-rt_v12-rev0/$MingwVersion.7z"
$MingwDir = "$env:RUNNER_TEMP\mingw-w64"
# Download and extract MinGW-w64
Invoke-WebRequest -Uri $MingwUrl -OutFile "$env:RUNNER_TEMP\$MingwVersion.7z"
7z x "$env:RUNNER_TEMP\$MingwVersion.7z" -o$MingwDir
# Add MinGW to PATH
"$MingwDir\mingw32\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Setup GTest
shell: bash
run: |
mkdir -p gtest-build
cd gtest-build
curl -L -o googletest-release-1.11.0.zip https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip
unzip googletest-release-1.11.0.zip
cd googletest-release-1.11.0
cmake -G "MinGW Makefiles" \
-DCMAKE_C_COMPILER=i686-w64-mingw32-gcc \
-DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++ \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX="C:/googletest"
cmake --build . --config Debug
cmake --install . --config Debug
cd ../..
- name: Build Project (32-bit MinGW)
shell: bash
run: |
cmake -G "MinGW Makefiles" \
-DCMAKE_C_COMPILER=i686-w64-mingw32-gcc \
-DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++ \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_PREFIX_PATH="C:/googletest/lib/cmake/GTest" \
-DTESTING_ENABLED=ON \
.
cmake --build . --config Debug
- name: Run Unit Tests (32-bit MinGW)
shell: bash
run: |
ctest -C Debug --output-on-failure