name: Test installation

on:
  workflow_dispatch:
  schedule:
    # * is a special character in YAML so you have to quote this string
    - cron:  '0 0 * * 3'

jobs:
  test-pypi-install:
    name: Test PyPI install (${{ matrix.python-version }}, ${{ matrix.os }})
    runs-on: "${{ matrix.os }}"
    strategy:
      fail-fast: false
      matrix:
        os: ["ubuntu-latest", "macos-latest", "windows-latest"]
        python-version: [ "3.9", "3.10", "3.11" ]
    steps:
    - name: Set up Python "${{ matrix.python-version }}"
      id: setup-python
      uses: actions/setup-python@v4
      with:
        python-version: "${{ matrix.python-version }}"
    - name: Install
      run: |
        pip install --upgrade pip
        pip install unfccc-ghg-data
    - name: Checkout repository
      uses: actions/checkout@v3
    - name: Test installation
      run: |
        which python
        python scripts/test-install.py

  test-micromamba-installation:
    name: Test (micro)mamba install (${{ matrix.python-version }}, ${{ matrix.os }})
    runs-on: "${{ matrix.os }}"
    strategy:
      fail-fast: false
      matrix:
        os: ["ubuntu-latest", "macos-latest", "windows-latest"]
        python-version: [ "3.9", "3.10", "3.11" ]

    steps:
    - name: Setup (micro)mamba and install package
      uses: mamba-org/setup-micromamba@v1
      with:
        environment-name: test-mamba-install
        create-args: >-
          python=${{ matrix.python-version }}
          -c conda-forge
          unfccc-ghg-data
        init-shell: bash
    - name: Checkout repository
      uses: actions/checkout@v3
    - name: Test installation
      shell: bash -leo pipefail {0}
      run: |
        which python
        python scripts/test-install.py
