qutip/qutip-qip

View on GitHub
.github/workflows/test.yml

Summary

Maintainability
Test Coverage
name: Tests

on:
  push:
    branches: [ master ]
  pull_request:

jobs:
  cases:
    name: ${{ matrix.os }}, python${{ matrix.python-version }}, ${{ matrix.case-name }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false # Continue running jobs even if a previous job fails
      matrix:
        include:
          - case-name: qutip@5
            os: ubuntu-latest
            qutip-version: '==5.*'
            python-version: '3.11'
          - case-name: qutip@qutip-4.7.X
            os: ubuntu-latest
            qutip-version: '@qutip-4.7.X'
            python-version: '3.10'
          - case-name: qutip@master
            os: ubuntu-latest
            qutip-version: '@master'
            python-version: '3.12'
          - case-name: qutip@4.7
            os: macOS-latest
            qutip-version: '==4.7.*'
            qiskit-version: ''
            python-version: '3.11'
          - case-name: qiskit
            os: windows-latest
            qutip-version: ''
            qiskit-version: '==0.46.*'
            python-version: '3.9'
          - case-name: qiskit
            os: macOS-latest
            qutip-version: ''
            qiskit-version: '==0.46.*'
            python-version: '3.9'
          - case-name: qiskit
            os: ubuntu-latest
            qutip-version: ''
            qiskit-version: '==0.46.*'
            python-version: '3.9'

    steps:
    - uses: actions/checkout@v4
    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install QuTiP from PyPI
      if: ${{ matrix.qutip-version != '' && ! startsWith( matrix.qutip-version, '@') }}
      run: python -m pip install 'qutip${{ matrix.qutip-version }}'

    - name: Install QuTiP from GitHub
      if: ${{ startsWith( matrix.qutip-version, '@') }}
      run: |
        python -m pip install 'git+https://github.com/qutip/qutip.git${{ matrix.qutip-version }}'
        
    - name: Install qutip-qtrl from GitHub
      if: ${{ matrix.qutip-version == '@master' }}
      run: |
        python -m pip install 'git+https://github.com/qutip/qutip-qtrl.git${{ matrix.qutip-version }}'

    - name: Install Qiskit from PyPI
      if: ${{ matrix.qiskit-version != '' }}
      run: python -m pip install 'qiskit${{ matrix.qiskit-version }}' 'qiskit-aer==0.14.0.1'

    - name: Install qutip-qip
      # Installing in-place so that coveralls can locate the source code.
      run: |
        pip install matplotlib pytest
        pip install -e .
    - name: Test with pytest and generate coverage report
      run: |
        pip install pytest-cov coveralls
        pytest tests --strict-markers --cov=qutip_qip --cov-report= --color=yes
    - name: Upload to Coveralls
      env:
        GITHUB_TOKEN: ${{ secrets.github_token }}
        COVERALLS_PARALLEL: true
      run: coveralls --service=github

  doctest:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v4
    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: 3.11
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        python -mpip install -r doc/requirements.txt
        pip install .
    - name: Test code snippets in the documentation
      run: |
        cd doc
        make doctest
    - name: Test code examples for the pulse paper
      run: |
        python -m pip install joblib pytest pytest-custom_exit_code
        cd doc/pulse-paper
        pytest *.py --suppress-no-test-exit-code

  finalise:
    name: Finalise coverage reporting
    needs: [cases]
    runs-on: ubuntu-latest
    container: python:3-slim
    steps:
      - name: Finalise coverage reporting
        env:
          GITHUB_TOKEN: ${{ secrets.github_token }}
        run: |
          python -m pip install coveralls
          coveralls --service=github --finish