added more logging #83
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
| # This workflow will install Python dependencies, run tests and lint with a single version of Python | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
| name: CI | |
| on: | |
| push: | |
| # Use ["main", "master"] for CI only on the default branch. | |
| # Use ["**"] for CI on all branches. | |
| branches: ["main", "master"] | |
| pull_request: | |
| branches: ["main", "master"] | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| # Update this as needed: | |
| # Common platforms: ["ubuntu-latest", "macos-latest", "windows-latest"] | |
| os: ["ubuntu-latest"] | |
| python-version: ["3.11", "3.12", "3.13"] | |
| # Linux only by default. Use ${{ matrix.os }} for other OSes. | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| # Generally following uv docs: | |
| # https://docs.astral.sh/uv/guides/integration/github/ | |
| - name: Checkout (official GitHub action) | |
| uses: actions/checkout@v4 | |
| with: | |
| # Important for versioning plugins: | |
| fetch-depth: 0 | |
| - name: Install uv (official Astral action) | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| # Update this as needed: | |
| version: "0.9.5" | |
| enable-cache: true | |
| python-version: ${{ matrix.python-version }} | |
| - name: Set up Python (using uv) | |
| run: uv python install | |
| # Alternately can use the official Python action: | |
| # - name: Set up Python (using actions/setup-python) | |
| # uses: actions/setup-python@v5 | |
| # with: | |
| # python-version: ${{ matrix.python-version }} | |
| - name: Install all dependencies | |
| run: uv sync --all-extras | |
| - name: Check formatting | |
| continue-on-error: true | |
| run: uv run ruff format --check . | |
| - name: Run type checking | |
| run: uv run basedpyright src/ || true | |
| - name: Run tests with coverage | |
| run: uv run pytest --cov=src/python_package_folder --cov-report=xml --cov-report=term tests/ | |
| - name: Generate coverage badge | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' | |
| run: | | |
| python -c " | |
| import xml.etree.ElementTree as ET | |
| import re | |
| # Parse coverage.xml | |
| tree = ET.parse('coverage.xml') | |
| root = tree.getroot() | |
| # Get coverage percentage | |
| line_rate = float(root.get('line-rate', 0)) | |
| coverage_percent = int(line_rate * 100) | |
| # Determine color based on coverage | |
| if coverage_percent >= 80: | |
| color = '44cc11' | |
| elif coverage_percent >= 60: | |
| color = 'dfb317' | |
| elif coverage_percent >= 40: | |
| color = 'fe7d37' | |
| else: | |
| color = 'e05d44' | |
| # Generate SVG badge | |
| svg = f'''<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"99\" height=\"20\"> | |
| <linearGradient id=\"b\" x2=\"0\" y2=\"100%\"> | |
| <stop offset=\"0\" stop-color=\"#bbb\" stop-opacity=\".1\"/> | |
| <stop offset=\"1\" stop-opacity=\".1\"/> | |
| </linearGradient> | |
| <mask id=\"a\"> | |
| <rect width=\"99\" height=\"20\" rx=\"3\" fill=\"#fff\"/> | |
| </mask> | |
| <g mask=\"url(#a)\"> | |
| <path fill=\"#555\" d=\"M0 0h63v20H0z\"/> | |
| <path fill=\"#{color}\" d=\"M63 0h36v20H63z\"/> | |
| <path fill=\"url(#b)\" d=\"M0 0h99v20H0z\"/> | |
| </g> | |
| <g fill=\"#fff\" text-anchor=\"middle\" font-family=\"DejaVu Sans,Verdana,Geneva,sans-serif\" font-size=\"11\"> | |
| <text x=\"31.5\" y=\"15\" fill=\"#010101\" fill-opacity=\".3\">coverage</text> | |
| <text x=\"31.5\" y=\"14\">coverage</text> | |
| <text x=\"81\" y=\"15\" fill=\"#010101\" fill-opacity=\".3\">{coverage_percent}%</text> | |
| <text x=\"81\" y=\"14\">{coverage_percent}%</text> | |
| </g> | |
| </svg>''' | |
| with open('coverage.svg', 'w') as f: | |
| f.write(svg) | |
| " | |
| - name: Commit coverage badge | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add coverage.svg || true | |
| git diff --staged --quiet || git commit -m "Update coverage badge [skip ci]" | |
| git push || true |