# GitHub Actions workflow for testing and continuous integration.
#
# This file performs testing using tox and tox.ini to define and configure the test environments.

name: CI Tests

on:
  push:
    branches:
    - main  # GitHub now defaults to 'main' as the name of the primary branch. Change this as needed.
  #  tags: # run CI if specific tags are pushed
  pull_request:
    # branches: # only build on PRs against 'main' if you need to further limit when CI is run.
    #    - main

jobs:
  # Github Actions supports ubuntu, windows, and macos virtual environments:
  # https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
  ci_tests:
    name: ${{ matrix.name }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:

           - name: Python 3.9
             os: ubuntu-22.04
             python: 3.9

           - name: Python 3.12
             os: ubuntu-22.04
             python: 3.12

    steps:
    - name: Checkout code
      uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - uses: mamba-org/setup-micromamba@v1
      with:
        environment-name: test-env
        create-args: >-
          python=${{ matrix.python }}
          netcdf4
        init-shell: >-
          bash
        cache-environment: true
        post-cleanup: 'all'
    - name: Install package
      run: pip install .[test]
      shell: bash -el {0}
    - name: Run Pytest
      run: |
        pytest -v
      shell: bash -el {0}

#    - name: MPI test
#      run: |
#        mpirun -np 2 --oversubscribe .tox/${{ matrix.toxenv}}/bin/python -m pytest pysm3/tests/test_read_map_mpi.py;