From d90e7638fb59bffc15f0b333a3591a638bb1b6ec Mon Sep 17 00:00:00 2001 From: Zhi Guan Date: Thu, 28 May 2026 09:17:20 +0800 Subject: [PATCH] Update workflow --- .github/workflows/msvc.yml | 45 +++++--------------------------------- cmake/tlcp_commands.cmake | 43 +++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 57 deletions(-) diff --git a/.github/workflows/msvc.yml b/.github/workflows/msvc.yml index 0606b9ae..06498d47 100644 --- a/.github/workflows/msvc.yml +++ b/.github/workflows/msvc.yml @@ -1,12 +1,4 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# -# Find more information at: -# https://github.com/microsoft/msvc-code-analysis-action - -name: Microsoft C++ Code Analysis +name: MSVC CMake on: push: @@ -24,12 +16,10 @@ permissions: contents: read jobs: - analyze: + build: permissions: - contents: read # for actions/checkout to fetch code - security-events: write # for github/codeql-action/upload-sarif to upload SARIF results - actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status - name: Analyze + contents: read + name: Build runs-on: windows-latest steps: @@ -39,28 +29,5 @@ jobs: - name: Configure CMake run: cmake -B ${{ env.build }} - # Build is not required unless generated source files are used - # - name: Build CMake - # run: cmake --build ${{ env.build }} - - - name: Initialize MSVC Code Analysis - uses: microsoft/msvc-code-analysis-action@04825f6d9e00f87422d6bf04e1a38b1f3ed60d99 - # Provide a unique ID to access the sarif output path - id: run-analysis - with: - cmakeBuildDirectory: ${{ env.build }} - # Ruleset file that will determine what checks will be run - ruleset: NativeRecommendedRules.ruleset - - # Upload SARIF file to GitHub Code Scanning Alerts - - name: Upload SARIF to GitHub - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: ${{ steps.run-analysis.outputs.sarif }} - - # Upload SARIF file as an Artifact to download and view - # - name: Upload SARIF as an Artifact - # uses: actions/upload-artifact@v4 - # with: - # name: sarif-file - # path: ${{ steps.run-analysis.outputs.sarif }} + - name: Build CMake + run: cmake --build ${{ env.build }} diff --git a/cmake/tlcp_commands.cmake b/cmake/tlcp_commands.cmake index 9b8e0e49..80a58a14 100644 --- a/cmake/tlcp_commands.cmake +++ b/cmake/tlcp_commands.cmake @@ -43,25 +43,25 @@ if(NOT ${SERVER_RESULT} EQUAL 0) message(FATAL_ERROR "server failed to start") endif() -execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 2) - - -if (WIN32) - execute_process( - COMMAND cmd /c "start /B bin\\gmssl tlcp_client -host localhost -port ${TLCP_TEST_PORT} -cacert rootcacert.pem > tlcp_client.log 2>&1" - RESULT_VARIABLE CLIENT_RESULT - TIMEOUT 5 - ) -else() - execute_process( - COMMAND bash -c "bin/gmssl tlcp_client -host localhost -port ${TLCP_TEST_PORT} -cacert rootcacert.pem < /dev/null > tlcp_client.log 2>&1 &" - RESULT_VARIABLE CLIENT_RESULT - TIMEOUT 5 - ) -endif() - set(FOUND_INDEX -1) foreach(i RANGE 1 15) + if (WIN32) + execute_process( + COMMAND cmd /c "start /B bin\\gmssl tlcp_client -host 127.0.0.1 -port ${TLCP_TEST_PORT} -cacert rootcacert.pem > tlcp_client.log 2>&1" + RESULT_VARIABLE CLIENT_RESULT + TIMEOUT 5 + ) + else() + execute_process( + COMMAND bash -c "bin/gmssl tlcp_client -host 127.0.0.1 -port ${TLCP_TEST_PORT} -cacert rootcacert.pem < /dev/null > tlcp_client.log 2>&1 &" + RESULT_VARIABLE CLIENT_RESULT + TIMEOUT 5 + ) + endif() + if(NOT ${CLIENT_RESULT} EQUAL 0) + message(FATAL_ERROR "client failed to start") + endif() + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1) if(EXISTS "tlcp_client.log") file(READ "tlcp_client.log" CLIENT_LOG_CONTENT) string(FIND "${CLIENT_LOG_CONTENT}" "Connection established" FOUND_INDEX) @@ -69,7 +69,6 @@ foreach(i RANGE 1 15) break() endif() endif() - execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1) endforeach() if(NOT WIN32) @@ -86,5 +85,13 @@ if(NOT WIN32) endif() if(${FOUND_INDEX} EQUAL -1) + if(EXISTS "tlcp_server.log") + file(READ "tlcp_server.log" SERVER_LOG_CONTENT) + message(STATUS "tlcp_server.log:\n${SERVER_LOG_CONTENT}") + endif() + if(EXISTS "tlcp_client.log") + file(READ "tlcp_client.log" CLIENT_LOG_CONTENT) + message(STATUS "tlcp_client.log:\n${CLIENT_LOG_CONTENT}") + endif() message(FATAL_ERROR "Client did not establish connection with server.") endif()