chore(rust-deps): bump pyo3 from 0.24.1 to 0.27.0 #39
Workflow file for this run
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: Memory Check | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| schedule: | |
| - cron: '0 0 * * 0' # Weekly on Sunday | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| memory-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy, rustfmt | |
| - name: Install Valgrind | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y valgrind | |
| - name: Setup uv | |
| uses: astral-sh/setup-uv@v3 | |
| - name: Install dependencies | |
| run: | | |
| uv sync --dev | |
| uv add --dev maturin memory_profiler | |
| - name: Build Rust extension | |
| run: | | |
| uv run maturin develop --release | |
| - name: Run Rust memory checks with Valgrind | |
| run: | | |
| # Run Rust tests under valgrind | |
| cargo test --release 2>&1 | tee rust-test.log | |
| # Check for memory leaks in Rust code | |
| valgrind --leak-check=full \ | |
| --show-leak-kinds=all \ | |
| --track-origins=yes \ | |
| --log-file=valgrind-rust.log \ | |
| cargo test --release --quiet || true | |
| # Parse valgrind output | |
| if grep -q "definitely lost:" valgrind-rust.log; then | |
| echo "::warning::Memory leaks detected in Rust code" | |
| grep "definitely lost:" valgrind-rust.log | |
| fi | |
| - name: Python memory profiling | |
| run: | | |
| # Create memory profiling script | |
| cat > profile_memory.py << 'EOF' | |
| import tracemalloc | |
| import pytest | |
| import sys | |
| # Start tracing | |
| tracemalloc.start() | |
| # Run a subset of tests | |
| exit_code = pytest.main([ | |
| 'tests/unit/test_client.py', | |
| 'tests/unit/test_main.py', | |
| '-v', '--tb=short' | |
| ]) | |
| # Get memory snapshot | |
| snapshot = tracemalloc.take_snapshot() | |
| top_stats = snapshot.statistics('lineno') | |
| print("\n=== Top 10 memory allocations ===") | |
| for stat in top_stats[:10]: | |
| print(stat) | |
| current, peak = tracemalloc.get_traced_memory() | |
| print(f"\nCurrent memory usage: {current / 10**6:.2f} MB") | |
| print(f"Peak memory usage: {peak / 10**6:.2f} MB") | |
| # Stop tracing | |
| tracemalloc.stop() | |
| # Warn if peak memory is too high | |
| if peak > 500 * 10**6: # 500 MB | |
| print("::warning::High memory usage detected (>500MB)") | |
| sys.exit(1) | |
| sys.exit(exit_code) | |
| EOF | |
| uv run python profile_memory.py | |
| - name: Check for memory leaks in Python | |
| run: | | |
| # Run Python tests under valgrind (if available) | |
| valgrind --leak-check=full \ | |
| --suppressions=/usr/share/doc/python3.12/valgrind-python.supp \ | |
| --log-file=valgrind-python.log \ | |
| uv run python -m pytest tests/unit/test_edge_cases.py -v || true | |
| # Check for Python memory leaks | |
| if [ -f valgrind-python.log ]; then | |
| if grep -q "definitely lost:" valgrind-python.log; then | |
| echo "::warning::Potential memory leaks detected in Python code" | |
| grep "definitely lost:" valgrind-python.log | head -5 | |
| fi | |
| fi | |
| - name: Upload memory reports | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: memory-reports | |
| path: | | |
| valgrind-*.log | |
| rust-test.log | |
| retention-days: 7 | |
| - name: Memory usage summary | |
| if: always() | |
| run: | | |
| echo "=== Memory Check Summary ===" | |
| if [ -f valgrind-rust.log ]; then | |
| echo "Rust memory check:" | |
| tail -10 valgrind-rust.log | grep -E "(ERROR SUMMARY|definitely lost|indirectly lost)" || echo "No issues found" | |
| fi | |
| if [ -f valgrind-python.log ]; then | |
| echo "Python memory check:" | |
| tail -10 valgrind-python.log | grep -E "(ERROR SUMMARY|definitely lost|indirectly lost)" || echo "No issues found" | |
| fi |