Repository navigation
fix git action #17
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, refactor] | |
| pull_request: | |
| branches: [main, refactor] | |
| env: | |
| BUILD_TYPE: Release | |
| # Enable vcpkg binary caching via GitHub Actions cache backend. | |
| # Compiled packages (e.g. ffmpeg) are stored in the GH Actions cache and | |
| # restored on subsequent runs, avoiding lengthy rebuilds. | |
| VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" | |
| jobs: | |
| build-and-test: | |
| name: ${{ matrix.os }} | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: Windows | |
| runner: windows-latest | |
| - os: Linux | |
| runner: ubuntu-latest | |
| - os: macOS | |
| runner: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| # Export the GH Actions cache URL and token so that vcpkg's x-gha | |
| # binary source can read/write compiled packages. | |
| - name: Export GitHub Actions cache variables | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); | |
| core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); | |
| - name: Install system dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y nasm yasm pkg-config | |
| - name: Install system dependencies (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install nasm yasm pkg-config | |
| # Use the pre-installed vcpkg on GitHub-hosted runners. | |
| # GitHub-hosted runners expose VCPKG_INSTALLATION_ROOT (not VCPKG_ROOT), | |
| # so we detect the installation path and export VCPKG_ROOT for subsequent | |
| # steps. This avoids the lukka/run-vcpkg action which sets up an isolated | |
| # environment that may not inherit the system PATH (where nasm/yasm were | |
| # installed), causing vcpkg_find_acquire_program to fail finding nasm. | |
| - name: Set up vcpkg | |
| shell: bash | |
| run: | | |
| # Detect vcpkg root: prefer VCPKG_ROOT, then VCPKG_INSTALLATION_ROOT | |
| # (set by GitHub-hosted runners), then OS-specific default paths. | |
| if [ -n "${VCPKG_ROOT}" ] && [ -d "${VCPKG_ROOT}" ]; then | |
| : # VCPKG_ROOT already set and valid | |
| elif [ -n "${VCPKG_INSTALLATION_ROOT}" ] && [ -d "${VCPKG_INSTALLATION_ROOT}" ]; then | |
| VCPKG_ROOT="${VCPKG_INSTALLATION_ROOT}" | |
| else | |
| case "${RUNNER_OS}" in | |
| Windows) VCPKG_ROOT="C:/vcpkg" ;; | |
| Linux) VCPKG_ROOT="/usr/local/share/vcpkg" ;; | |
| macOS) VCPKG_ROOT="/usr/local/share/vcpkg" ;; | |
| *) VCPKG_ROOT="" ;; | |
| esac | |
| fi | |
| if [ -z "${VCPKG_ROOT}" ] || [ ! -d "${VCPKG_ROOT}" ]; then | |
| echo "Error: vcpkg directory not found." | |
| echo " VCPKG_ROOT=${VCPKG_ROOT}" | |
| echo " VCPKG_INSTALLATION_ROOT=${VCPKG_INSTALLATION_ROOT}" | |
| echo " RUNNER_OS=${RUNNER_OS}" | |
| exit 1 | |
| fi | |
| # Export VCPKG_ROOT for subsequent steps (e.g. Configure CMake). | |
| echo "VCPKG_ROOT=${VCPKG_ROOT}" >> "$GITHUB_ENV" | |
| echo "VCPKG_ROOT=${VCPKG_ROOT}" | |
| # Ensure vcpkg executable exists (bootstrap if missing). | |
| if [ ! -x "${VCPKG_ROOT}/vcpkg" ] && [ ! -x "${VCPKG_ROOT}/vcpkg.exe" ]; then | |
| echo "Bootstrapping vcpkg..." | |
| if [ "${RUNNER_OS}" = "Windows" ]; then | |
| "${VCPKG_ROOT}/bootstrap-vcpkg.bat" -disableMetrics | |
| else | |
| "${VCPKG_ROOT}/bootstrap-vcpkg.sh" -disableMetrics | |
| fi | |
| fi | |
| echo "vcpkg version:" | |
| if [ "${RUNNER_OS}" = "Windows" ]; then | |
| "${VCPKG_ROOT}/vcpkg.exe" version || true | |
| else | |
| "${VCPKG_ROOT}/vcpkg" version || true | |
| fi | |
| - name: Cache ONNX Runtime | |
| id: cache-ort | |
| uses: actions/cache@v4 | |
| with: | |
| path: build/onnxruntime | |
| key: onnxruntime-${{ matrix.os }}-${{ runner.arch }}-1.17.3-v1 | |
| - name: Download ONNX Runtime | |
| if: steps.cache-ort.outputs.cache-hit != 'true' | |
| shell: cmake -P {0} | |
| run: | | |
| set(ws [=[${{ github.workspace }}]=]) | |
| file(TO_CMAKE_PATH "${ws}" ws) | |
| set(CMAKE_BINARY_DIR "${ws}/build") | |
| include(${ws}/scripts/setup-onnxruntime.cmake) | |
| - name: Configure CMake | |
| shell: bash | |
| run: | | |
| cmake -B build -S . \ | |
| -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ | |
| -DSYNTHRT_BUILD_TESTS=ON \ | |
| -DSYNTHRT_ORT_DIR="${{ github.workspace }}/build/onnxruntime" \ | |
| -DCMAKE_TOOLCHAIN_FILE="${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" \ | |
| -DVCPKG_MANIFEST_DIR="${{ github.workspace }}/scripts/vcpkg-manifest" \ | |
| -DVCPKG_OVERLAY_PORTS="${{ github.workspace }}/scripts/vcpkg/ports" \ | |
| -DVCPKG_OVERLAY_TRIPLETS="${{ github.workspace }}/scripts/vcpkg/triplets" | |
| - name: Build | |
| run: cmake --build build --config ${{ env.BUILD_TYPE }} --parallel | |
| - name: Test | |
| shell: bash | |
| run: | | |
| ctest --test-dir build --build-config ${{ env.BUILD_TYPE }} \ | |
| --output-on-failure --parallel 4 --timeout 300 |