Compress pytest output with LogStrip
Python tracebacks span many indented lines. Run with -m python so each
traceback is treated as a single logical event during scoring and
deduplication.
File in, file out (GitHub Actions)
Section titled “File in, file out (GitHub Actions)”- uses: actions/setup-python@v5 with: python-version: '3.12'
- run: pip install -r requirements.txt
- name: Run pytest run: pytest -ra > raw_logs.txt 2>&1 || true
- name: Compress logs run: npx -y logstrip raw_logs.txt -m python -o clean.log --stats
- name: Analyze run: your-ai-agent analyze --file clean.logOne step with stdin
Section titled “One step with stdin”pytest -ra 2>&1 | npx -y logstrip -m python > clean.log || trueGitLab CI
Section titled “GitLab CI”test: image: python:3.12 script: - pip install -r requirements.txt - pytest -ra > raw_logs.txt 2>&1 || true - npx -y logstrip raw_logs.txt -m python -o clean.log --stats artifacts: when: always paths: - clean.log expire_in: 1 weekLocal pre-push hook
Section titled “Local pre-push hook”#!/usr/bin/env bashset -euo pipefail
pytest -ra > .pytest.raw.log 2>&1 || PYTEST_EXIT=$?npx -y logstrip .pytest.raw.log -m python -o .pytest.clean.log --stats
if [[ ${PYTEST_EXIT:-0} -ne 0 ]]; then echo "Tests failed. Compact log: .pytest.clean.log" exit 1fiTox / multi-env
Section titled “Tox / multi-env”tox -p auto 2>&1 | npx -y logstrip -m python --severity warn > clean.log || true--severity warn drops INFO/DEBUG chatter from coverage and plugin
discovery, leaving warnings, errors, and tracebacks.