Skip to content

Commit c171dc6

Browse files
Merge pull request llm-d-incubation#203 from diegocastanibm/python_test_workflow
[TEST]: workflow python tests
2 parents a776487 + 0b208dd commit c171dc6

File tree

1 file changed

+69
-58
lines changed

1 file changed

+69
-58
lines changed

.github/workflows/python-code-quality.yml

Lines changed: 69 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -12,73 +12,84 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v5.0.0
15+
- name: Checkout code
16+
uses: actions/checkout@v5.0.0
1717

18-
- name: Set up Python
19-
uses: actions/setup-python@v4
20-
with:
21-
python-version: '3.12.11'
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: "3.12.11"
2222

23-
- name: Cache pip dependencies
24-
uses: actions/cache@v4.2.4
25-
with:
26-
path: ~/.cache/pip
27-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
28-
restore-keys: |
29-
${{ runner.os }}-pip-
23+
- name: Cache pip dependencies
24+
uses: actions/cache@v4.2.4
25+
with:
26+
path: ~/.cache/pip
27+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
28+
restore-keys: |
29+
${{ runner.os }}-pip-
3030
31-
- name: Install black isort flake
32-
run: |
33-
python -m pip install --upgrade pip
34-
pip install black==24.4.2 isort==5.13.2 flake8==7.0.0
31+
- name: Install black isort flake pytest
32+
run: |
33+
python -m pip install --upgrade pip
34+
# install black isort flake
35+
pip install black==24.4.2 isort==5.13.2 flake8==7.0.0
36+
# install pytest and its dependencies
37+
pip install pytest==9.0.2 fastapi==0.116.1 pydantic==2.11.7 uvicorn==0.35.0 uvloop==0.21.0 httpx==0.28.1 pynvml==13.0.1
3538
36-
- name: Check for trailing whitespace
37-
run: |
38-
# Check for trailing whitespace in all files
39-
if grep -r --include="*.py" --include="*.yml" --include="*.yaml" --include="*.json" --include="*.md" --include="*.txt" '[[:space:]]$' .; then
40-
echo "Found trailing whitespace in the above files"
41-
exit 1
42-
fi
39+
- name: Check for trailing whitespace
40+
run: |
41+
# Check for trailing whitespace in all files
42+
if grep -r --include="*.py" --include="*.yml" --include="*.yaml" --include="*.json" --include="*.md" --include="*.txt" '[[:space:]]$' .; then
43+
echo "Found trailing whitespace in the above files"
44+
exit 1
45+
fi
46+
47+
- name: Check end of file newlines
48+
run: |
49+
# Check that files end with a newline
50+
find . -name "*.py" -o -name "*.yml" -o -name "*.yaml" -o -name "*.json" -o -name "*.md" | while read file; do
51+
if [ -n "$(tail -c1 "$file")" ]; then
52+
echo "File $file does not end with a newline"
53+
exit 1
54+
fi
55+
done
4356
44-
- name: Check end of file newlines
45-
run: |
46-
# Check that files end with a newline
47-
find . -name "*.py" -o -name "*.yml" -o -name "*.yaml" -o -name "*.json" -o -name "*.md" | while read file; do
48-
if [ -n "$(tail -c1 "$file")" ]; then
49-
echo "File $file does not end with a newline"
57+
- name: Check for large files
58+
run: |
59+
# Check for files larger than 600KB
60+
find . -type f -size +600k | grep -v '.git/' | while read file; do
61+
echo "Large file found: $file"
62+
done
63+
if find . -type f -size +600k | grep -v '.git/' | grep -q .; then
64+
echo "Large files found. Consider using Git LFS or removing them."
5065
exit 1
5166
fi
52-
done
5367
54-
- name: Check for large files
55-
run: |
56-
# Check for files larger than 600KB
57-
find . -type f -size +600k | grep -v '.git/' | while read file; do
58-
echo "Large file found: $file"
59-
done
60-
if find . -type f -size +600k | grep -v '.git/' | grep -q .; then
61-
echo "Large files found. Consider using Git LFS or removing them."
62-
exit 1
63-
fi
68+
- name: Run Black (code formatting check)
69+
run: |
70+
black --check --diff .
6471
65-
- name: Run Black (code formatting check)
66-
run: |
67-
black --check --diff .
72+
- name: Run isort (import sorting check)
73+
run: |
74+
isort --profile black --check-only --diff .
6875
69-
- name: Run isort (import sorting check)
70-
run: |
71-
isort --profile black --check-only --diff .
76+
- name: Run flake8 (linting)
77+
run: |
78+
flake8 --max-line-length=88 --extend-ignore=E203,W503 .
7279
73-
- name: Run flake8 (linting)
74-
run: |
75-
flake8 --max-line-length=88 --extend-ignore=E203,W503 .
80+
- name: Run pytest launcher
81+
run: |
82+
cd inference_server/launcher
83+
python -m pytest tests/test_launcher.py -v
84+
python -m pytest tests/test_gputranslator.py -v
7685
77-
- name: Summary
78-
if: always()
79-
run: |
80-
echo "Code quality checks completed!"
81-
echo "If any checks failed, please run the following locally to fix issues:"
82-
echo " black ."
83-
echo " isort --profile black ."
84-
echo " flake8 --max-line-length=88 --extend-ignore=E203,W503 ."
86+
- name: Summary
87+
if: always()
88+
run: |
89+
echo "Code quality checks completed!"
90+
echo "If any checks failed, please run the following locally to fix issues:"
91+
echo " black ."
92+
echo " isort --profile black ."
93+
echo " flake8 --max-line-length=88 --extend-ignore=E203,W503 ."
94+
echo " python -m pytest tests/test_launcher.py -v"
95+
echo " python -m pytest tests/test_gputranslator.py -v"

0 commit comments

Comments
 (0)