Update workflow

This commit is contained in:
Zhi Guan
2026-05-28 09:17:20 +08:00
parent 672737f953
commit d90e7638fb
2 changed files with 31 additions and 57 deletions

View File

@@ -1,12 +1,4 @@
# This workflow uses actions that are not certified by GitHub. name: MSVC CMake
# 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
on: on:
push: push:
@@ -24,12 +16,10 @@ permissions:
contents: read contents: read
jobs: jobs:
analyze: build:
permissions: permissions:
contents: read # for actions/checkout to fetch code contents: read
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results name: Build
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
name: Analyze
runs-on: windows-latest runs-on: windows-latest
steps: steps:
@@ -39,28 +29,5 @@ jobs:
- name: Configure CMake - name: Configure CMake
run: cmake -B ${{ env.build }} run: cmake -B ${{ env.build }}
# Build is not required unless generated source files are used - name: Build CMake
# - name: Build CMake run: cmake --build ${{ env.build }}
# 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 }}

View File

@@ -43,25 +43,25 @@ if(NOT ${SERVER_RESULT} EQUAL 0)
message(FATAL_ERROR "server failed to start") message(FATAL_ERROR "server failed to start")
endif() endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 2) set(FOUND_INDEX -1)
foreach(i RANGE 1 15)
if (WIN32) if (WIN32)
execute_process( 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" 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 RESULT_VARIABLE CLIENT_RESULT
TIMEOUT 5 TIMEOUT 5
) )
else() else()
execute_process( 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 &" 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 RESULT_VARIABLE CLIENT_RESULT
TIMEOUT 5 TIMEOUT 5
) )
endif() endif()
if(NOT ${CLIENT_RESULT} EQUAL 0)
set(FOUND_INDEX -1) message(FATAL_ERROR "client failed to start")
foreach(i RANGE 1 15) endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1)
if(EXISTS "tlcp_client.log") if(EXISTS "tlcp_client.log")
file(READ "tlcp_client.log" CLIENT_LOG_CONTENT) file(READ "tlcp_client.log" CLIENT_LOG_CONTENT)
string(FIND "${CLIENT_LOG_CONTENT}" "Connection established" FOUND_INDEX) string(FIND "${CLIENT_LOG_CONTENT}" "Connection established" FOUND_INDEX)
@@ -69,7 +69,6 @@ foreach(i RANGE 1 15)
break() break()
endif() endif()
endif() endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1)
endforeach() endforeach()
if(NOT WIN32) if(NOT WIN32)
@@ -86,5 +85,13 @@ if(NOT WIN32)
endif() endif()
if(${FOUND_INDEX} EQUAL -1) 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.") message(FATAL_ERROR "Client did not establish connection with server.")
endif() endif()