Repository navigation
114 lines (90 loc) · 3.99 KB
/
Copy pathpython-app.yml
File metadata and controls
114 lines (90 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python application
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch: # Allow manual triggering
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov pytest-html
# Install movie_idea_generator dependencies
if [ -d "movie_idea_generator" ]; then
pip install -e "./movie_idea_generator[dev]"
pip install openai requests python-dotenv crewai langchain
fi
# Install recommender_api dependencies
if [ -d "recommender_api" ]; then
pip install fastapi uvicorn scikit-learn numpy httpx
fi
# Install any additional requirements
if [ -f requirements.txt ]; then
pip install -r requirements.txt
fi
- name: Create test directories
run: |
mkdir -p test_results/movie_idea_generator
mkdir -p test_results/recommender_api
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test movie_idea_generator
if: always() && hashFiles('movie_idea_generator/**/*.py') != ''
run: |
echo "::group::Running tests for movie_idea_generator"
cd movie_idea_generator
# Create dummy secrets file for testing if needed
mkdir -p src/config
echo "OPENAI_API_KEY = 'dummy_key_for_testing'" > src/config/secrets.py
# Run tests with coverage and generate report
python -m pytest tests/ -v --cov=src --html=../test_results/movie_idea_generator/report.html --self-contained-html | tee ../test_results/movie_idea_generator/test_output.txt
# Store the exit code to determine if tests passed
TEST_EXIT_CODE=${PIPESTATUS[0]}
# Display summary
echo "----------------------------------------"
echo "📊 Test Results Summary:"
grep -E "collected|PASSED|FAILED|ERROR" ../test_results/movie_idea_generator/test_output.txt || true
echo "----------------------------------------"
# Exit with the test exit code
exit $TEST_EXIT_CODE
- name: Test recommender_api
if: always() && hashFiles('recommender_api/**/*.py') != ''
run: |
echo "::group::Running tests for recommender_api"
cd recommender_api
# Run tests with coverage and generate report
python -m pytest tests/ -v --cov=app --html=../test_results/recommender_api/report.html --self-contained-html | tee ../test_results/recommender_api/test_output.txt
# Store the exit code to determine if tests passed
TEST_EXIT_CODE=${PIPESTATUS[0]}
# Display summary
echo "----------------------------------------"
echo "📊 Test Results Summary:"
grep -E "collected|PASSED|FAILED|ERROR" ../test_results/recommender_api/test_output.txt || true
echo "----------------------------------------"
# Exit with the test exit code
exit $TEST_EXIT_CODE
- name: Archive test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
test_results/