Skip to content

Commit

Permalink
Merge pull request #240 from openziti/add-mingw-ci-build
Browse files Browse the repository at this point in the history
Add mingw ci build
  • Loading branch information
ekoby authored Sep 27, 2024
2 parents 697532a + 53808eb commit 53a2cf0
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 90 deletions.
93 changes: 60 additions & 33 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,50 @@ on:

jobs:
build:

runs-on: ${{ matrix.os }}-latest
name: ${{ matrix.target }}-${{ matrix.tls }}
runs-on: ${{ matrix.image }}-latest
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu
- image: ubuntu
tls: openssl
- os: ubuntu
target: x64-linux
- image: ubuntu
tls: mbedtls
- os: macOS
target: x64-linux
- image: macOS
tls: openssl
- os: macOS
target: arm64-osx
- image: macOS
tls: mbedtls
- os: windows
target: arm64-osx
- image: windows
tls: openssl
target: x64-windows-static-md
- image: windows
tls: openssl
triplet: x64-windows-static-md
- os: windows
target: x64-mingw-static
- image: windows
tls: mbedtls
triplet: x64-windows-static-md
target: x64-windows-static-md

steps:
- name: Install tools
if: matrix.os == 'ubuntu'
if: matrix.image == 'ubuntu'
run: |
sudo apt update
sudo apt install -y valgrind softhsm
- name: Install tools
if: matrix.os == 'macOS'
if: matrix.image == 'macOS'
run: |
brew install pkg-config softhsm
- name: Add msbuild to PATH
if: matrix.image == 'windows'
uses: microsoft/setup-msbuild@v2

- uses: actions/checkout@v4
with:
fetch-depth: '0'
Expand All @@ -52,19 +63,31 @@ jobs:
id: cache
uses: actions/cache@v4
with:
save-always: 'true'
path: vcpkg/packages
key: dependencies-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('./vcpkg.json') }}
key: dependencies-${{ matrix.target }}-${{ hashFiles('./vcpkg.json') }}

- uses: lukka/run-vcpkg@v11
env:
VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}
VCPKG_DEFAULT_TRIPLET: ${{ matrix.target }}
with:
doNotCache: true
runVcpkgInstall: true
runVcpkgFormatString: '[`install`, `--x-install-root`, `$[env.VCPKG_INSTALLED_DIR]`, `--x-feature=all-deps`]'

- uses: lukka/run-cmake@v10
name: Configure build
with:
configurePreset: ${{ matrix.target }}
configurePresetAdditionalArgs: "[ `-DTLSUV_TLSLIB=${{ matrix.tls }}`, `-DVCPKG_MANIFEST_FEATURES='test;samples;${{ matrix.tls }}'` ]"

- name: Build
id: build
run: |
cmake --build build
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v4
uses: actions/setup-go@v5
with:
go-version: ~1.20

Expand All @@ -74,37 +97,41 @@ jobs:
go build -o ${{ github.workspace }}/build/ .
- name: start test server
if: matrix.os != 'windows'
if: matrix.image != 'windows'
run: |
${{ github.workspace }}/build/test-server -ca-key ./tests/certs/ca.key -ca ./tests/certs/ca.pem &
- name: start test server
if: matrix.os == 'windows'
if: matrix.image == 'windows'
run: |
Start-Process -FilePath ${{ github.workspace }}/build/test-server -ArgumentList "-ca-key","./tests/certs/ca.key","-ca","./tests/certs/ca.pem"
- uses: lukka/run-cmake@v10
name: Build and Test
with:
configurePreset: ci-${{ matrix.os }}
configurePresetAdditionalArgs: "[ `-DTLSUV_TLSLIB=${{ matrix.tls }}`, `-DVCPKG_MANIFEST_FEATURES='test;samples;${{ matrix.tls }}'` ]"
buildPreset: ci-${{ matrix.os }}
testPreset: ci-${{ matrix.os }}
testPresetAdditionalArgs: "[ `--output-on-failure`, `--no-compress-output` ]"
- name: Test
env:
TLSUV_TEST_LOG: 7
if: steps.build.outcome == 'success'
run: |
cd build
ctest --output-on-failure --no-compress-output -T test
- name: Memory Check
uses: lukka/run-cmake@v10
if: always() && matrix.os == 'ubuntu'
if: steps.build.outcome == 'success' && matrix.image == 'ubuntu'
env:
TLSUV_TEST_LOG: 7
run: |
cd build
ctest --output-on-failure --no-compress-output -T memcheck
- name: upload test summary
if: always()
uses: mikepenz/action-junit-report@v4
with:
configurePreset: ci-${{ matrix.os }}
configurePresetAdditionalArgs: "[ `-DTLSUV_TLSLIB=${{ matrix.tls }}`,`-DVCPKG_MANIFEST_FEATURES='${{ matrix.tls }};test;samples'` ]"
buildPreset: ci-${{ matrix.os }}
testPreset: ci-${{ matrix.os }}
testPresetAdditionalArgs: "[ `--test-dir`, `${{ github.workspace }}/build`, `--output-on-failure`, `--no-compress-output`, `-T`, `MemCheck` ]"
detailed_summary: 'true'
report_paths: ${{ github.workspace }}/build/**/TEST-*.xml

- name: upload test report
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.tls }}-TestReport
name: ${{ matrix.target }}-${{ matrix.tls }}-TestReport
path: ${{ github.workspace }}/build/Testing/
78 changes: 32 additions & 46 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
}
},
{
"name": "vcpkg-win64-static",
"name": "vs-2022",
"hidden": true,
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-windows-static-md"
}
"generator": "Visual Studio 17 2022"
},
{
"name": "ninja",
Expand Down Expand Up @@ -78,67 +76,55 @@
},
{
"name": "ci-win64",
"inherits": ["flags-windows", "ci-std", "ninja"],
"inherits": ["flags-windows", "ci-std", "vs-2022"],
"architecture": {
"value": "x64",
"strategy": "external"
},
"hidden": true
},
{
"name": "ci-build",
"binaryDir": "${sourceDir}/build",
"name": "ci-win-mingw",
"inherits": ["ci-std", "ninja"],
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_EXE_LINKER_FLAGS": "-Wl,-Bstatic -lpthread"
},
"hidden": true
},
{
"name": "ci-macOS",
"inherits": ["ci-build", "ci-unix", "dev-mode", "vcpkg"]
},
{
"name": "ci-ubuntu",
"inherits": ["ci-build", "ci-unix", "vcpkg", "dev-mode"]
},
{
"name": "ci-windows",
"inherits": ["ci-build", "ci-win64", "dev-mode", "vcpkg", "vcpkg-win64-static"]
}
],
"buildPresets": [
{
"name": "ci-ubuntu",
"configurePreset": "ci-ubuntu"
},
{
"name": "ci-macOS",
"configurePreset": "ci-macOS"
"name": "ci-build",
"binaryDir": "${sourceDir}/build",
"hidden": true
},
{
"name": "ci-windows",
"configurePreset": "ci-windows"
}
],
"testPresets": [
{
"name": "test-env",
"hidden": true,
"environment": {
"TLSUV_TEST_LOG": "7"
"name": "arm64-osx",
"inherits": ["ci-build", "ci-unix", "dev-mode", "vcpkg"],
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "arm64-osx"
}
},
{
"name": "ci-ubuntu",
"configurePreset": "ci-ubuntu",
"inherits": [ "test-env" ]
"name": "x64-linux",
"inherits": ["ci-build", "ci-unix", "vcpkg", "dev-mode"],
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-linux"
}
},
{
"name": "ci-macOS",
"configurePreset": "ci-macOS",
"inherits": [ "test-env" ]
"name": "x64-windows-static-md",
"inherits": ["ci-build", "ci-win64", "dev-mode", "vcpkg"],
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-windows-static-md"
}
},
{
"name": "ci-windows",
"configurePreset": "ci-windows",
"inherits": [ "test-env" ]
"name": "x64-mingw-static",
"inherits": [ "ci-build", "ci-win-mingw", "dev-mode", "vcpkg" ],
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-mingw-static"
}
}
]
}
4 changes: 2 additions & 2 deletions sample/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (WIN32)
if (MSVC)
find_package(unofficial-getopt-win32 REQUIRED)
endif()

Expand All @@ -19,7 +19,7 @@ target_link_libraries(sample-cf PUBLIC tlsuv common)

if (TLSUV_HTTP)
add_executable(um-curl um-curl.c)
if (WIN32)
if (MSVC)
target_link_libraries(um-curl PRIVATE unofficial::getopt-win32::getopt)
endif()
target_link_libraries(um-curl PUBLIC tlsuv common)
Expand Down
1 change: 0 additions & 1 deletion src/win32/win32_keychain.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ static int gen_key(keychain_key_t *key, enum keychain_key_type type, const char
NCRYPT_ECDSA_P521_ALGORITHM,
NCRYPT_ECDSA_P384_ALGORITHM,
NCRYPT_ECDSA_P256_ALGORITHM,
NCRYPT_ECDSA_ALGORITHM,
};

if (type != keychain_key_ec) {
Expand Down
14 changes: 9 additions & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,16 @@ add_custom_target(run-tests
COMMAND $<TARGET_FILE:all_tests> -r xml -o ${PROJECT_BINARY_DIR}/Testing/results.xml)

include(CTest)
add_test(key_tests all_tests [key])
add_test(engine_tests all_tests [engine])
add_test(stream_tests all_tests [stream])
macro(mk_test tag)
add_test(${tag}_tests all_tests [${tag}] -r junit::out=TEST-${tag}.xml -r console)
endmacro()

mk_test(key)
mk_test(engine)
mk_test(stream)

if (TLSUV_HTTP)
add_test(http_tests all_tests [http])
add_test(ws_tests all_tests [websocket])
mk_test(http)
mk_test(websocket)
endif (TLSUV_HTTP)

4 changes: 2 additions & 2 deletions tests/key_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ TEST_CASE("keychain", "[key]") {
char *pem = nullptr;
size_t pem_len = 0;
CHECK(pub->to_pem(pub, &pem, &pem_len) == 0);
CHECK(pem != NULL);
CHECK(pem != nullptr);
if (pem) {
CHECK_THAT(pem, Catch::Matchers::StartsWith("-----BEGIN PUBLIC KEY-----"));
std::cout << std::string(pem, pem_len) << std::endl;
Expand Down Expand Up @@ -398,7 +398,7 @@ TEST_CASE("keychain-manual", "[.]") {
char *pem = nullptr;
size_t pem_len = 0;
CHECK(pub->to_pem(pub, &pem, &pem_len) == 0);
CHECK(pem != NULL);
CHECK(pem != nullptr);
if (pem) {
CHECK_THAT(pem, Catch::Matchers::StartsWith("-----BEGIN PUBLIC KEY-----"));
std::cout << std::string(pem, pem_len) << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"dependencies": [
{
"name": "getopt-win32",
"platform": "windows"
"platform": "windows & !mingw"
}
]
},
Expand Down

0 comments on commit 53a2cf0

Please sign in to comment.