Skip to content

Hot fix to e2e test on Openshift #1104

Hot fix to e2e test on Openshift

Hot fix to e2e test on Openshift #1104

name: python-code-quality
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
code-quality:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.12.11"
- name: Cache pip dependencies
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install black isort flake pytest
run: |
python -m pip install --upgrade pip
# install black isort flake
pip install black==24.4.2 isort==5.13.2 flake8==7.0.0
# install pytest and other dependencies
pip install pytest==9.0.2 -r inference_server/launcher/requirements-sans-vllm.txt
- name: Check for trailing whitespace
run: |
# Check for trailing whitespace in all files
if grep -r --include="*.py" --include="*.yml" --include="*.yaml" --include="*.json" --include="*.md" --include="*.txt" '[[:space:]]$' .; then
echo "Found trailing whitespace in the above files"
exit 1
fi
- name: Check end of file newlines
run: |
# Check that files end with a newline
find . -name "*.py" -o -name "*.yml" -o -name "*.yaml" -o -name "*.json" -o -name "*.md" | while read file; do
if [ -n "$(tail -c1 "$file")" ]; then
echo "File $file does not end with a newline"
exit 1
fi
done
- name: Check for large files
run: |
# Check for files larger than 600KB
find . -type f -size +600k | grep -v '.git/' | while read file; do
echo "Large file found: $file"
done
if find . -type f -size +600k | grep -v '.git/' | grep -q .; then
echo "Large files found. Consider using Git LFS or removing them."
exit 1
fi
- name: Run Black (code formatting check)
run: |
black --check --diff .
- name: Run isort (import sorting check)
run: |
isort --profile black --check-only --diff .
- name: Run flake8 (linting)
run: |
flake8 --max-line-length=88 --extend-ignore=E203,W503 .
- name: Run pytest launcher
run: |
cd inference_server/launcher
python -m pytest tests/test_launcher.py -v
python -m pytest tests/test_gputranslator.py -v
- name: Summary
if: always()
run: |
echo "Code quality checks completed!"
echo "If any checks failed, please run the following locally to fix issues:"
echo " black ."
echo " isort --profile black ."
echo " flake8 --max-line-length=88 --extend-ignore=E203,W503 ."
echo " python -m pytest tests/test_launcher.py -v"
echo " python -m pytest tests/test_gputranslator.py -v"