name: smoketests

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
  workflow_dispatch: # manual execution

jobs:
  smoketests:
    runs-on: ${{ matrix.os }}
    timeout-minutes: 15
    strategy:
      matrix:
        os: [ ubuntu-latest, macos-13 ] # disabling windows-latest for now
        python: [ '3.8', '3.9', '3.10', '3.11', '3.12']

    steps:
    - uses: actions/checkout@v4

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

    - name: Work around arm64 support on MacOS
      # https://github.com/actions/virtual-environments/issues/2557
      if: matrix.os == 'macos-latest'
      run: sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*

    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        python -m pip install -r requirements.txt
        python -m pip install numpy

    - name: Build scalene
      run: pip -v install -e .

    - name: cpu-only smoke test
      run: python test/smoketest.py test/testme.py --cpu-only

    - name: multiprocessing smoke test
      run: python test/smoketest.py test/multiprocessing_test.py

      # Note: test/smoketest.py only handles single JSON, rather than multiple in sequence.
    - name: profile-interval smoke test
      run: python -m scalene --cli --profile-interval=2 test/testme.py

    - name: decorator smoke test
      run: python test/smoketest_profile_decorator.py

    # Note: This test doesn't need to read an output,
    # it is meant to determine if there is an ImportError
    # or anything related if relative imports are used.
    - name: -m invocation smoketest
      run: |
        python -m pip install git+https://github.com/sternj/import_stress_test
        python -m scalene --cli --- -m import_stress_test
