From 40c3cccfb2d177d566971cecbb307f8dacec3d07 Mon Sep 17 00:00:00 2001 From: MistEO Date: Sun, 14 Sep 2025 20:22:15 +0800 Subject: [PATCH] ci: try macos for smoke_test (#14104) * ci: try macos for smoke_test * ci: Remove concurrency from smoke-testing workflow * ci: use ninjga build for macos testing * ci: add trigger * ci: fix macos parallel * ci: update bash * fix: zsh script * fix: perms * fix: zsh script regular array * ci: add resource link for cache hit * test: enable dev for testing * test: revert test --------- Co-authored-by: Constrat <56174894+Constrat@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- .github/workflows/smoke-testing.yml | 49 ++++++++++++++--------------- tools/SmokeTesting/run_tests.zsh | 47 +++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 27 deletions(-) create mode 100755 tools/SmokeTesting/run_tests.zsh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 77baa45af2..d62242b989 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -366,7 +366,7 @@ jobs: - name: Build run: | - cmake --build build --config Release --parallel $(nproc) + cmake --build build --config Release --parallel $(sysctl -n hw.logicalcpu) - name: Install run: | diff --git a/.github/workflows/smoke-testing.yml b/.github/workflows/smoke-testing.yml index f588aeceaa..806d6f875e 100644 --- a/.github/workflows/smoke-testing.yml +++ b/.github/workflows/smoke-testing.yml @@ -3,6 +3,7 @@ name: smoke-testing on: push: paths: + - ".github/workflows/smoke-testing.yml" - "3rdparty/include/**" - "include/**" - "src/Cpp/**" @@ -14,6 +15,7 @@ on: - "tools/maadeps-download.py" pull_request: paths: + - ".github/workflows/smoke-testing.yml" - "3rdparty/include/**" - "include/**" - "src/Cpp/**" @@ -25,17 +27,13 @@ on: - "tools/maadeps-download.py" workflow_dispatch: -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - jobs: smoke-testing: # Prevent duplicate runs on organization branches with PRs if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name - runs-on: ubuntu-latest + runs-on: macos-latest steps: - name: Checkout code uses: actions/checkout@v5 @@ -53,13 +51,10 @@ jobs: with: key: ${{ steps.cache_key.outputs.key }} path: | - ./install/libc++.so.1 - ./install/libc++abi.so.1 - ./install/libfastdeploy_ppocr.so - ./install/libMaaCore.so - ./install/libonnxruntime.so.1 - ./install/libopencv_world4.so.411 - ./install/libunwind.so.1 + ./install/libfastdeploy_ppocr.dylib + ./install/libMaaCore.dylib + ./install/libonnxruntime.1.19.2.dylib + ./install/libopencv_world4.4.11.0.dylib ./install/smoke_test - name: Fetch submodules @@ -73,29 +68,29 @@ jobs: uses: actions/cache@v4 with: path: ./MaaDeps - key: ${{ runner.os }}-x64-maadeps-${{ hashFiles('tools/maadeps-download.py') }} + key: ${{ runner.os }}-arm64-maadeps-${{ hashFiles('tools/maadeps-download.py') }} - name: Bootstrap MaaDeps if: steps.smoke-cache.outputs.cache-hit != 'true' && steps.maadeps-cache.outputs.cache-hit != 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - python3 tools/maadeps-download.py x64-linux + python3 tools/maadeps-download.py arm64-osx - name: Config cmake if: steps.smoke-cache.outputs.cache-hit != 'true' run: | mkdir -p build - cmake -B build \ + cmake -B build -GNinja \ -DCMAKE_BUILD_TYPE=Debug \ - -DMAADEPS_TRIPLET='maa-x64-linux' \ + -DMAADEPS_TRIPLET='maa-arm64-osx' \ -DBUILD_SMOKE_TEST=ON \ - -DCMAKE_TOOLCHAIN_FILE=MaaDeps/cmake/maa-x64-linux-toolchain.cmake + -DINSTALL_RESOURCE=ON - name: Build if: steps.smoke-cache.outputs.cache-hit != 'true' run: | - cmake --build build --config Debug --parallel $(nproc) + cmake --build build --config Debug --parallel $(sysctl -n hw.logicalcpu) - name: Install if: steps.smoke-cache.outputs.cache-hit != 'true' @@ -103,9 +98,14 @@ jobs: mkdir -p install cmake --install build --prefix install --config Debug + - name: Make link for cache smoke-testing + if: steps.smoke-cache.outputs.cache-hit == 'true' + run: | + ln -s "$(pwd)/resource" install/resource + - name: Run tests run: | - ./tools/SmokeTesting/run_tests.sh + ./tools/SmokeTesting/run_tests.zsh - name: Save cache smoke-testing (only in dev) if: steps.smoke-cache.outputs.cache-hit != 'true' && github.ref == 'refs/heads/dev' @@ -113,13 +113,10 @@ jobs: with: key: ${{ steps.cache_key.outputs.key }} path: | - ./install/libc++.so.1 - ./install/libc++abi.so.1 - ./install/libfastdeploy_ppocr.so - ./install/libMaaCore.so - ./install/libonnxruntime.so.1 - ./install/libopencv_world4.so.411 - ./install/libunwind.so.1 + ./install/libfastdeploy_ppocr.dylib + ./install/libMaaCore.dylib + ./install/libonnxruntime.1.19.2.dylib + ./install/libopencv_world4.4.11.0.dylib ./install/smoke_test - name: Upload logs diff --git a/tools/SmokeTesting/run_tests.zsh b/tools/SmokeTesting/run_tests.zsh new file mode 100755 index 0000000000..cb6b013cab --- /dev/null +++ b/tools/SmokeTesting/run_tests.zsh @@ -0,0 +1,47 @@ +#!/usr/bin/env zsh + +set -e + +clients=("Official" "YoStarJP" "YoStarEN" "YoStarKR" "txwy") +error_clients=() +log_dir="./install/debug" +mkdir -p "$log_dir" + +pids=() +client_map=() + +for client in "${clients[@]}"; do + echo "Starting test for $client" + ./install/smoke_test "$client" > "$log_dir/asst_${client}.log" 2>&1 & + pids+=($!) + client_map+=("$client") +done + +for i in {1..${#pids}}; do + pid=${pids[$i]} + client=${client_map[$i]} + + if ! wait $pid; then + error_clients+=("$client") + fi +done + +rm -f "$log_dir/asst.log" +for client in "${clients[@]}"; do + cat "$log_dir/asst_${client}.log" >> "$log_dir/asst.log" +done + +if [[ ${#error_clients} -gt 0 ]]; then + for client in "${error_clients[@]}"; do + while IFS= read -r line; do + if [[ "$line" =~ "\[ERR\]" ]]; then + print -P "%F{red}${line}%f" + else + echo "$line" + fi + done < "$log_dir/asst_${client}.log" + done + exit 1 +fi + +print -P "%F{green}All tests passed%f"