name: Unit Tests for latest Qiskit
on:
  schedule:
    - cron: '0 5 * * *'
concurrency:
  group: ${{ github.repository }}-${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }}
  cancel-in-progress: true
jobs:
  unit-tests-latest-qiskit:
    runs-on: ubuntu-latest
    timeout-minutes: 60
    env:
      AER_THRUST_BACKEND: OMP
      QISKIT_TEST_CAPTURE_STREAMS: 1
      # Needed to suppress a warning in jupyter-core 5.x by eagerly migrating to
      # a new internal interface that will be the default in jupyter-core 6.x.
      # This variable should become redundant on release of jupyter-core 6.
      JUPYTER_PLATFORM_DIRS: 1
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python 3.11
        uses: actions/setup-python@v5
        with:
          python-version: 3.11
      - name: Pip cache
        uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-${{ matrix.python-version}}-pip-test-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }}
          restore-keys: |
            ${{ runner.os }}-${{ matrix.python-version}}-pip-test-
            ${{ runner.os }}-${{ matrix.python-version}}-pip-
            ${{ runner.os }}-${{ matrix.python-version}}-
      - name: Install openblas
        run: |
          set -e
          sudo apt-get update
          sudo apt-get install -y libopenblas-dev
        shell: bash
      - name: Install dependencies and Aer
        run: |
          python -m pip install -U setuptools setuptools-rust wheel
          python -m pip install -U \
            -c constraints.txt \
            -r requirements-dev.txt \
            'git+https://github.com/Qiskit/qiskit.git@main' \
            .
      - name: Run Tests
        run: |
          set -e
          pip check
          rm -rf qiskit_aer
          stestr run --slowest
        shell: bash
        
