feat: Memory Profiler initial implementation #40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [master, develop] | |
| pull_request: | |
| branches: [master] | |
| schedule: | |
| # Run weekly on Mondays to catch upstream changes | |
| - cron: '0 0 * * 1' | |
| env: | |
| FORCE_COLOR: 1 | |
| jobs: | |
| # ============================================================================= | |
| # Lint, format, and type checking | |
| # ============================================================================= | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install ruff mypy | |
| - name: Check formatting (ruff format) | |
| run: ruff format --check src/ tests/ benchmarks/ examples/ | |
| - name: Lint (ruff check) | |
| run: ruff check src/ tests/ benchmarks/ examples/ | |
| - name: Type check (mypy) | |
| run: mypy src/spprof --ignore-missing-imports | |
| # ============================================================================= | |
| # Unified test matrix - Linux, Windows, macOS | |
| # ============================================================================= | |
| test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-15] | |
| python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| allow-prereleases: true | |
| - name: Set up MSVC (Windows) | |
| if: runner.os == 'Windows' | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| - name: Install build tools | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install meson ninja meson-python | |
| - name: Install package in development mode (strict warnings) | |
| run: pip install -e ".[dev]" --config-settings=setup-args="-Dstrict=true" | |
| - name: Run tests with coverage | |
| run: | | |
| python -m pytest tests/test_profiler.py tests/test_output.py tests/test_coverage.py -v --tb=short --cov=spprof --cov-report=xml --cov-report=term-missing | |
| timeout-minutes: 5 | |
| - name: Upload coverage to Codecov | |
| if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: coverage.xml | |
| fail_ci_if_error: false | |
| verbose: true | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| # ============================================================================= | |
| # Free-threaded Python builds (3.13t, 3.14t) | |
| # ============================================================================= | |
| free-threaded: | |
| runs-on: ${{ matrix.os }} | |
| continue-on-error: true | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-15] | |
| python-version: ["3.13t", "3.14t"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} free-threaded | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| allow-prereleases: true | |
| - name: Verify free-threaded build | |
| run: | | |
| python -c "import sys; assert hasattr(sys, '_is_gil_enabled') and not sys._is_gil_enabled(), 'Not a free-threaded build'" | |
| echo "✓ Free-threaded Python confirmed" | |
| - name: Install build tools | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install meson ninja meson-python | |
| - name: Install package in development mode (strict warnings) | |
| run: pip install -e ".[dev]" --config-settings=setup-args="-Dstrict=true" | |
| - name: Run tests | |
| run: | | |
| python -X faulthandler -m pytest tests/test_profiler.py -v --tb=short | |
| timeout-minutes: 5 | |
| # ============================================================================= | |
| # Memory safety testing with sanitizers (Linux only) | |
| # ============================================================================= | |
| sanitizers: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libasan8 libubsan1 | |
| - name: Install build tools | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install meson ninja meson-python pytest pytest-timeout | |
| - name: Build with ASAN+UBSAN and strict warnings | |
| run: | | |
| meson setup builddir --buildtype=debug -Dsanitize=address,undefined -Dstrict=true | |
| meson compile -C builddir | |
| - name: Run tests with sanitizers | |
| env: | |
| PYTHONPATH: ${{ github.workspace }}/builddir/src/spprof:${{ github.workspace }}/src | |
| ASAN_OPTIONS: detect_leaks=1:abort_on_error=1:symbolize=1:halt_on_error=1 | |
| UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1 | |
| run: | | |
| python -m pytest tests/ -v --tb=short -x | |
| timeout-minutes: 10 | |
| # ============================================================================= | |
| # Benchmarks | |
| # ============================================================================= | |
| benchmark: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install build tools | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install meson ninja meson-python | |
| - name: Install package in development mode (strict warnings) | |
| run: pip install -e ".[dev]" --config-settings=setup-args="-Dstrict=true" | |
| - name: Run benchmarks | |
| run: | | |
| python benchmarks/overhead.py --intervals 10 100 --json > benchmark_results.json | |
| timeout-minutes: 5 | |
| - name: Upload benchmark results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmark-results | |
| path: benchmark_results.json |