Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/testing_flask.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Python Flask Tests Workflow

on:
workflow_call:

jobs:
build:
name: Execute Python Flask Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Check for Python files
id: check_py
run: |
if git ls-files "*.py" | grep -q "."; then
echo "Python files found"
echo "found=true" >> "$GITHUB_OUTPUT"
else
echo "No Python files found"
echo "found=false" >> "$GITHUB_OUTPUT"
fi

- name: Set up Python
if: steps.check_py.outputs.found == 'true'
uses: actions/setup-python@v4
with:
python-version: "3.13"

- name: Install dependencies (requirements/test.txt or defaults)
if: steps.check_py.outputs.found == 'true'
run: |
python -m pip install --upgrade pip
if [ -f requirements/test.txt ]; then
echo "Installing from requirements/test.txt"
pip install -r requirements/test.txt
pip install torch torchvision torchaudio pytest coverage
else
echo "requirements/test.txt not found, installing defaults"
pip install torch torchvision torchaudio pytest coverage
fi

- name: Run tests
if: steps.check_py.outputs.found == 'true'
run: |
coverage run -m flask test || EXIT_CODE=$?
coverage xml
if [ "$EXIT_CODE" -eq "5" ]; then
echo "No tests were found. Skipping test phase."
exit 0
elif [ "$EXIT_CODE" -ne "0" ]; then
echo "Tests failed with exit code $EXIT_CODE."
exit $EXIT_CODE
else
echo "All tests passed."
exit 0
fi

- name: Upload coverage report
if: steps.check_py.outputs.found == 'true'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.xml