fix(ci): use pip compat check instead of hardcoded --break-system-packages
- Old runner (Python 3.10 / pip 22.0) doesn't support --break-system-packages - Use runtime check to determine if the flag is needed - Fix pytest-rerunfailures install too
This commit is contained in:
+33
-10
@@ -92,9 +92,15 @@ jobs:
|
||||
shell: sh
|
||||
run: |
|
||||
set -eu
|
||||
python3 -m pip install --break-system-packages -q -r requirements-base.txt
|
||||
python3 -m pip install --break-system-packages -q -r requirements.txt
|
||||
python3 -m pip install --break-system-packages -q -r requirements-dev.txt
|
||||
|
||||
# 兼容Python 3.11+ PEP 668 (externally-managed-environment)
|
||||
PIP_INSTALL="python3 -m pip install -q"
|
||||
if python3 -m pip install --help 2>&1 | grep -q break-system-packages; then
|
||||
PIP_INSTALL="$PIP_INSTALL --break-system-packages"
|
||||
fi
|
||||
eval $PIP_INSTALL -r requirements-base.txt
|
||||
eval $PIP_INSTALL -r requirements.txt
|
||||
eval $PIP_INSTALL -r requirements-dev.txt
|
||||
python3 -m black --version
|
||||
python3 -m isort --version-number
|
||||
python3 -m flake8 --version
|
||||
@@ -221,9 +227,15 @@ jobs:
|
||||
shell: sh
|
||||
run: |
|
||||
set -eu
|
||||
python3 -m pip install --break-system-packages -q -r requirements-base.txt
|
||||
python3 -m pip install --break-system-packages -q -r requirements.txt
|
||||
python3 -m pip install --break-system-packages -q -r requirements-dev.txt
|
||||
|
||||
# 兼容Python 3.11+ PEP 668 (externally-managed-environment)
|
||||
PIP_INSTALL="python3 -m pip install -q"
|
||||
if python3 -m pip install --help 2>&1 | grep -q break-system-packages; then
|
||||
PIP_INSTALL="$PIP_INSTALL --break-system-packages"
|
||||
fi
|
||||
eval $PIP_INSTALL -r requirements-base.txt
|
||||
eval $PIP_INSTALL -r requirements.txt
|
||||
eval $PIP_INSTALL -r requirements-dev.txt
|
||||
pytest --version
|
||||
|
||||
- name: Run unit tests with coverage
|
||||
@@ -320,9 +332,15 @@ jobs:
|
||||
shell: sh
|
||||
run: |
|
||||
set -eu
|
||||
python3 -m pip install --break-system-packages -q -r requirements-base.txt
|
||||
python3 -m pip install --break-system-packages -q -r requirements.txt
|
||||
python3 -m pip install --break-system-packages -q -r requirements-dev.txt
|
||||
|
||||
# 兼容Python 3.11+ PEP 668 (externally-managed-environment)
|
||||
PIP_INSTALL="python3 -m pip install -q"
|
||||
if python3 -m pip install --help 2>&1 | grep -q break-system-packages; then
|
||||
PIP_INSTALL="$PIP_INSTALL --break-system-packages"
|
||||
fi
|
||||
eval $PIP_INSTALL -r requirements-base.txt
|
||||
eval $PIP_INSTALL -r requirements.txt
|
||||
eval $PIP_INSTALL -r requirements-dev.txt
|
||||
pytest --version
|
||||
|
||||
- name: Start Redis
|
||||
@@ -394,7 +412,12 @@ jobs:
|
||||
shell: sh
|
||||
run: |
|
||||
set -eu
|
||||
pip install --break-system-packages -q pytest-rerunfailures
|
||||
# 兼容Python 3.11+ PEP 668
|
||||
PIP_INSTALL="python3 -m pip install -q"
|
||||
if python3 -m pip install --help 2>&1 | grep -q break-system-packages; then
|
||||
PIP_INSTALL="$PIP_INSTALL --break-system-packages"
|
||||
fi
|
||||
eval $PIP_INSTALL pytest-rerunfailures
|
||||
PYTHONPATH="$PWD/apps/api:$PWD" python3 -m coverage run --append \
|
||||
--source=apps/api/app,packages \
|
||||
--omit="*/migrations/*,*/tests/*,*/test_*.py,*/site-packages/*" \
|
||||
|
||||
Reference in New Issue
Block a user