|
name: Python application |
|
|
|
on: |
|
push: |
|
branches: [ "main" ] |
|
pull_request: |
|
branches: [ "main" ] |
|
|
|
permissions: |
|
contents: read |
|
|
|
jobs: |
|
build: |
|
runs-on: ubuntu-latest |
|
|
|
steps: |
|
- uses: actions/checkout@v4 |
|
|
|
- name: Set up Python 3.10 |
|
uses: actions/setup-python@v3 |
|
with: |
|
python-version: "3.10" |
|
|
|
- name: Install dependencies |
|
run: | |
|
python -m pip install --upgrade pip setuptools wheel |
|
pip install flake8 pytest pytest-flask |
|
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
|
|
|
- name: Verify model and template files |
|
run: | |
|
if [ ! -f "models/lr_regg.pkl" ] || [ ! -f "models/feature_names.pkl" ]; then |
|
echo "Model files missing!" |
|
exit 1 |
|
fi |
|
if [ ! -d "templates" ] || [ ! -f "templates/index.html" ]; then |
|
echo "Template files missing!" |
|
exit 1 |
|
fi |
|
|
|
- name: Lint with flake8 |
|
run: | |
|
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
|
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
|
|
|
- name: Test with pytest |
|
run: python -m pytest tests/ -v |
|
|
|
- name: Start and Test Flask App |
|
run: | |
|
python app.py & |
|
sleep 10 |
|
curl --retry 5 --retry-delay 5 --retry-connrefused http://127.0.0.1:5000/ || exit 1 |
|
pkill -f "python app.py" |
|
env: |
|
FLASK_ENV: testing |
|
FLASK_DEBUG: 0 |
|
|
|
- name: Check setup.py |
|
run: | |
|
if [ -f setup.py ]; then |
|
python setup.py check |
|
python setup.py sdist bdist_wheel |
|
pip install -e . |
|
else |
|
echo "setup.py not found!" |
|
fi |
|
|