name: Pull-Request-CI

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main

jobs:
  Build-and-Test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
       os: [ubuntu-latest, macos-latest]
       python-version: ["3.8", "3.9", "3.10", "3.11"]
    defaults:
      run:
        shell: bash -l {0}
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true
      - uses: conda-incubator/setup-miniconda@v2
        with:
          miniconda-version: "latest"
          activate-environment: usgscsm
          environment-file: environment.yml
          auto-activate-base: false
          auto-update-conda: true
          python-version: ${{ matrix.python-version }}
      - name: Check build environment
        run: |
          conda list
      - name: Build Package
        run: |
          mkdir -p build
          cd build
          cmake -DCMAKE_BUILD_TYPE=RELEASE -DUSGSCSM_EXTERNAL_DEPS=ON ..
          cmake --build .
      - name: Test Package
        run: |
          cd build
          ctest -VV
