Skip to content

Update files

Update files #38

Workflow file for this run

name: CI
on:
push:
branches: [ main, fiddling ]
pull_request:
branches: [ main ]
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 dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 black
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Check code formatting with black
run: |
black --check .
test:
needs: lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests with coverage
run: |
set -e
python -m pytest --cov=. --cov-report=xml --cov-report=term-missing --cov-report=html -v
- name: Run coverage tracker
run: |
set -e
python coverage_tracker.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate coverage summary
if: matrix.python-version == '3.11'
run: |
# Create coverage summary for job summary
echo "## 📊 Coverage Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Get current coverage
CURRENT_COV=$(python -m pytest --cov=. --cov-report=term --quiet | grep TOTAL | awk '{print $4}' | sed 's/%//')
if [ -f .coverage_baseline.json ]; then
# Get baseline coverage
BASELINE_COV=$(python -c "import json; print(json.load(open('.coverage_baseline.json'))['total_coverage'])")
# Calculate difference
DIFF=$(echo "$CURRENT_COV - $BASELINE_COV" | bc 2>/dev/null || echo "0")
echo "- **Current Coverage**: ${CURRENT_COV}%" >> $GITHUB_STEP_SUMMARY
echo "- **Baseline Coverage**: ${BASELINE_COV}%" >> $GITHUB_STEP_SUMMARY
echo "- **Change**: ${DIFF}%" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Add status based on difference
if (( $(echo "$DIFF >= 0" | bc -l) )); then
echo "✅ Coverage maintained or improved" >> $GITHUB_STEP_SUMMARY
elif (( $(echo "$DIFF >= -2" | bc -l) )); then
echo "📊 Coverage within acceptable tolerance (2%)" >> $GITHUB_STEP_SUMMARY
else
echo "⚠️ Significant coverage decline detected" >> $GITHUB_STEP_SUMMARY
fi
else
echo "- **Current Coverage**: ${CURRENT_COV}%" >> $GITHUB_STEP_SUMMARY
echo "- **Baseline**: Not available" >> $GITHUB_STEP_SUMMARY
fi
- name: Upload coverage to Codecov
if: matrix.python-version == '3.11'
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
continue-on-error: true
- name: Archive coverage reports
if: matrix.python-version == '3.11'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: htmlcov/
- name: Upload coverage baseline
if: matrix.python-version == '3.11' && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: coverage-baseline
path: .coverage_baseline.json
retention-days: 30