Chore/coverage collection #16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Test | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| generate-data: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| submodules: recursive | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - name: Install dependencies | |
| run: | | |
| pip install modelscope transformers | |
| - name: Generate Tests Data | |
| run: | | |
| cd tests | |
| python generate_assets.py | |
| - name: Upload models | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: models | |
| path: tests/models/ | |
| build-and-test: | |
| needs: generate-data | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| ujson_use_rapidjson: ["OFF", "ON"] | |
| runs-on: ${{ matrix.os }} | |
| name: build-test (${{ matrix.os }}, RapidJSON=${{ matrix.ujson_use_rapidjson }}) | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| submodules: recursive | |
| - name: Download models | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: models | |
| path: tests/models/ | |
| - name: Install build dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake g++ | |
| - name: Configure | |
| run: | | |
| cmake -B build -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON -DUJSON_USE_RAPIDJSON=${{ matrix.ujson_use_rapidjson }} | |
| - name: Build | |
| run: | | |
| cmake --build build --config Debug -j 4 | |
| - name: Run Tests | |
| shell: bash | |
| run: | | |
| cd build | |
| if [[ "${{ runner.os }}" == "Windows" ]]; then | |
| ./Debug/test_main | |
| else | |
| ./test_main | |
| fi | |
| - name: Collect Coverage (Linux/Mac) | |
| if: runner.os != 'Windows' | |
| run: | | |
| # 创建覆盖率存放目录 | |
| mkdir -p coverage_data | |
| # 查找所有生成的 .gcda 和 .gcno 文件并复制(保持目录结构平铺或打包) | |
| find build -name "*.gcda" -exec cp {} coverage_data/ \; | |
| find build -name "*.gcno" -exec cp {} coverage_data/ \; | |
| - name: Upload Coverage Artifacts | |
| if: runner.os != 'Windows' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-${{ matrix.os }}-${{ matrix.ujson_use_rapidjson }} | |
| path: coverage_data/ |