Fix sonar-analysis job: Install Python 3.11 instead of 3.10
Some checks failed
CI / lint-and-test (push) Successful in 2m34s
CI / secret-scanning (push) Successful in 1m33s
CI / security-scan (push) Successful in 2m14s
CI / dependency-scan (push) Successful in 1m38s
CI / sast-scan (push) Successful in 2m40s
CI / container-scan (push) Successful in 2m14s
CI / docker-build-test (push) Has been cancelled
CI / workflow-summary (push) Has been cancelled
CI / sonar-analysis (push) Has been cancelled

ISSUE:
======
- Ubuntu 22.04 comes with Python 3.10
- Project requires Python >=3.11 (pyproject.toml)
- Error: Package 'pote' requires a different Python: 3.10.12 not in '>=3.11'

FIX:
====
- Install Python 3.11 from deadsnakes PPA
- Install pip for Python 3.11
- Use python3.11 -m pip explicitly for all pip operations
- Use python3.11 -m pytest for test execution

CHANGES:
========
- Install software-properties-common for add-apt-repository
- Add deadsnakes PPA for Python 3.11
- Install python3.11, python3.11-dev, python3.11-venv, python3.11-distutils
- Install pip via get-pip.py for Python 3.11
- Update all pip/pytest commands to use python3.11 -m

This ensures the sonar-analysis job uses Python 3.11 as required.
This commit is contained in:
ilia 2026-01-10 14:26:19 -05:00
parent bd3f7097bd
commit 64f37ef393

View File

@ -344,16 +344,27 @@ jobs:
echo "⚠️ Warning: Could not verify SonarQube server connectivity (continuing anyway)" echo "⚠️ Warning: Could not verify SonarQube server connectivity (continuing anyway)"
fi fi
- name: Install Python and dependencies - name: Install Python 3.11 and dependencies
run: | run: |
apt-get update && apt-get install -y python3 python3-pip apt-get update
pip3 install --upgrade pip apt-get install -y software-properties-common
add-apt-repository -y ppa:deadsnakes/ppa
apt-get update
apt-get install -y python3.11 python3.11-dev python3.11-venv python3.11-distutils
# Install pip for Python 3.11
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11
# Ensure python3 and pip3 point to 3.11
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 || true
# Use python3.11 -m pip for pip operations
python3.11 -m pip install --upgrade pip
python3 --version
python3.11 -m pip --version
- name: Generate coverage report - name: Generate coverage report
run: | run: |
echo "Generating coverage report for SonarQube..." echo "Generating coverage report for SonarQube..."
pip3 install -e ".[dev]" python3.11 -m pip install -e ".[dev]"
pytest tests/ --cov=src/pote --cov-report=xml --cov-report=term || true python3.11 -m pytest tests/ --cov=src/pote --cov-report=xml --cov-report=term || true
- name: Run SonarScanner - name: Run SonarScanner
run: | run: |