build: update packaging for MinAn 2.0 #19
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: Python Tests | |
| on: [push, pull_request] | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install linting tools | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install black==23.12.1 isort==5.13.2 flake8==6.1.0 | |
| - name: Check code format (Black) | |
| run: black --check src/ tests/ | |
| - name: Check import order (isort) | |
| run: isort --check-only src/ tests/ | |
| - name: Lint with flake8 | |
| run: flake8 src/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics | |
| security: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install security tools | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pip-audit | |
| - name: Scan dependencies for vulnerabilities | |
| run: pip-audit -r requirements.txt | |
| tests: | |
| runs-on: ubuntu-latest | |
| needs: [lint, security] | |
| strategy: | |
| matrix: | |
| python-version: ['3.11'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install system dependencies (Qt offscreen) | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y --no-install-recommends \ | |
| libgl1 libegl1 libglib2.0-0 libxkbcommon-x11-0 \ | |
| libdbus-1-3 libxcb-icccm4 libxcb-image0 \ | |
| libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 \ | |
| libxcb-xinerama0 libxcb-xfixes0 | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pytest-cov | |
| - name: Run tests | |
| env: | |
| QT_QPA_PLATFORM: offscreen | |
| run: | | |
| set -o pipefail | |
| pytest tests/ --cov=src --cov-report=xml -v 2>&1 | tee pytest-output.txt | |
| status=${PIPESTATUS[0]} | |
| if [ "$status" -ne 0 ]; then | |
| pytest tests/ -v 2>&1 | tee -a pytest-output.txt | |
| status=${PIPESTATUS[0]} | |
| fi | |
| exit "$status" | |
| - name: Summarize test failure | |
| if: failure() | |
| run: | | |
| python - <<'PY' | |
| from pathlib import Path | |
| output_path = Path("pytest-output.txt") | |
| if not output_path.exists(): | |
| print("::error title=pytest-failure::pytest-output.txt missing") | |
| raise SystemExit(0) | |
| text = output_path.read_text(encoding="utf-8", errors="replace") | |
| interesting = [] | |
| for line in text.splitlines(): | |
| line = line.strip() | |
| if not line: | |
| continue | |
| if line.startswith("ERROR ") or " FAILED" in line or line.startswith("FAILED "): | |
| interesting.append(line) | |
| elif line.startswith("E "): | |
| interesting.append(line) | |
| elif "pytest: error:" in line: | |
| interesting.append(line) | |
| message = " | ".join(interesting[:8])[:1500] if interesting else "Tests failed; inspect pytest-output.txt" | |
| print(f"::error title=pytest-failure::{message}") | |
| PY |