on: 
  pull_request:
    paths:
      - .github/actions/extism/**
      - .github/workflows/ci-cpp.yml
      - manifest/**
      - runtime/**
      - libextism/**
      - cpp/**
  workflow_dispatch:

name: C++ CI

jobs:
  cpp:
    name: C++
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
        rust:
          - stable
    steps:
      - name: Checkout sources
        uses: actions/checkout@v3
      - uses: ./.github/actions/extism
      - name: Install C++ SDK deps
        if: ${{ matrix.os == 'macos-latest' }}
        run: |
          brew install jsoncpp googletest pkg-config
      - name: Install C++ SDK deps
        if: ${{ matrix.os == 'ubuntu-latest' }}
        run: |
          sudo apt-get install g++ libjsoncpp-dev libgtest-dev pkg-config
      - name: Run C++ tests
        run: |
          cd cpp
          LD_LIBRARY_PATH=/usr/local/lib make example
          LD_LIBRARY_PATH=/usr/local/lib make test
