name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  build:
    runs-on: windows-latest

    strategy:
      matrix:
        python-version: ['3.9', '3.10', '3.11', '3.12']

    steps:
    - name: Checkout repository
      uses: actions/checkout@v2

    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install Miniconda on Windows
      uses: conda-incubator/setup-miniconda@v2
      with:
        auto-update-conda: true

    - name: Create Conda environment
      run: |
        conda env create -f environment.yaml

    - name: Activate Conda environment and run tests
      run: |
        conda activate MED3pa
        python -m unittest discover -s tests
      shell: cmd

    - name: Install dependencies for documentation
      run: |
        conda activate MED3pa
        conda install sphinx sphinx_rtd_theme
      shell: cmd

    - name: Build documentation
      run: |
        conda activate MED3pa
        cd docs
        make html
      shell: cmd