From 60cbd2de1fbbc693dbed4a44c480c73fcb4ed6ec Mon Sep 17 00:00:00 2001 From: Evan Hu Date: Sat, 5 Sep 2026 14:19:26 +0900 Subject: [PATCH] ci: build and test on Windows for every pull request MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Server 端此前没有 CI。tests/ 下已有几十个测试文件并通过 add_test 注册,但从来没有在 PR 上跑过,回归只能靠人工在本机复现。 workflow 不走 preset:preset 指定 Visual Studio 18 2026 生成器和 C:/Users/sonnycalcr 的 vcpkg 路径,在 runner 上都不成立。Boost 也不能来自 manifest——CMakeLists.txt 要求 Boost locale 和 json 且按静态链接,但 vcpkg.json 里没有声明它,README 让用 Scoop 单独安装。这里改用 classic 模式装静态 Boost,再通过 CMakeLists.txt 已经支持的 BOOST_ROOT 环境变量指过去,不改动 vcpkg.json。 --- server/.github/workflows/ci.yml | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 server/.github/workflows/ci.yml diff --git a/server/.github/workflows/ci.yml b/server/.github/workflows/ci.yml new file mode 100644 index 00000000..6dc4601b --- /dev/null +++ b/server/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + +permissions: + contents: read + +jobs: + build: + name: Windows x64 + runs-on: windows-2025 + steps: + - name: Check out source + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + with: + submodules: recursive + - name: Install Boost + shell: pwsh + # CMakeLists.txt links Boost statically but does not declare it in + # vcpkg.json, so it cannot come from the manifest. Install it in classic + # mode from the vcpkg installation root and point BOOST_ROOT at it, which + # is the override CMakeLists.txt already supports. + run: | + Push-Location $env:VCPKG_INSTALLATION_ROOT + ./vcpkg install boost-locale:x64-windows-static boost-json:x64-windows-static + Pop-Location + "BOOST_ROOT=$env:VCPKG_INSTALLATION_ROOT/installed/x64-windows-static" >> $env:GITHUB_ENV + - name: Configure + shell: pwsh + run: > + cmake -S . -B build -A x64 + -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" + -DVCPKG_TARGET_TRIPLET=x64-windows + - name: Build + shell: pwsh + run: cmake --build build --config Release --parallel + - name: Test + shell: pwsh + run: ctest --test-dir build -C Release --output-on-failure --timeout 120