@@ -117,7 +117,7 @@ jobs:
117117 SUPABASE_AUTH_EXTERNAL_GITHUB_CLIENT_ID : fake
118118 SUPABASE_AUTH_EXTERNAL_GITHUB_SECRET : fake
119119
120- - name : Run tests
120+ - name : Run Tests
121121 env :
122122 DJANGO_SECRET_KEY : ${{ secrets.DJANGO_SECRET_KEY || 'test_secret_key' }}
123123 DJANGO_DEBUG : " ${{ secrets.DJANGO_DEBUG || 'True' }}"
@@ -131,90 +131,38 @@ jobs:
131131 SUPABASE_ANON_KEY : ${{ secrets.SUPABASE_ANON_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0' }}
132132 SUPABASE_SERVICE_ROLE_KEY : ${{ secrets.SUPABASE_SERVICE_ROLE_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU' }}
133133 SUPABASE_JWT_SECRET : ${{ secrets.SUPABASE_JWT_SECRET || 'your-super-secret-jwt-token-with-at-least-32-characters-long' }}
134- REDIS_PASSWORD : ${{ secrets.REDIS_PASSWORD || 'redis_default_password_for_ci' }}
135- REDIS_DB : ${{ secrets.REDIS_DB || '0' }}
136- REDIS_PORT : ${{ secrets.REDIS_PORT || '6379' }}
137134 REDIS_URL : " redis://:${{ secrets.REDIS_PASSWORD || 'redis_default_password_for_ci' }}@localhost:${{ secrets.REDIS_PORT || '6379' }}/${{ secrets.REDIS_DB || '0' }}"
138135 run : |
139136 cd backend
140- python -m pytest --cov=. --cov-report=xml --junitxml=junit.xml -o junit_family=legacy || true
141-
142- - name : Upload coverage to Codecov
143- uses : codecov/codecov-action@v3
144- with :
145- file : ./backend/coverage.xml
146- slug : " TechWithTy/django-supabase-template"
147- flags : backend
148- fail_ci_if_error : false
149-
150- - name : Run API Tests
151- env :
152- DJANGO_SECRET_KEY : ${{ secrets.DJANGO_SECRET_KEY || 'test_secret_key' }}
153- DJANGO_DEBUG : " ${{ secrets.DJANGO_DEBUG || 'True' }}"
154- DB_ENGINE : ${{ secrets.DB_ENGINE || 'django.db.backends.postgresql' }}
155- DB_NAME : ${{ secrets.DB_NAME || 'test_db' }}
156- DB_USER : ${{ secrets.DB_USER || 'postgres' }}
157- DB_PASSWORD : ${{ secrets.DB_PASSWORD || 'postgres' }}
158- DB_HOST : ${{ secrets.DB_HOST || 'localhost' }}
159- DB_PORT : ${{ secrets.DB_PORT || '5432' }}
160- SUPABASE_URL : ${{ secrets.SUPABASE_URL || 'http://localhost:54321' }}
161- SUPABASE_ANON_KEY : ${{ secrets.SUPABASE_ANON_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0' }}
162- SUPABASE_SERVICE_ROLE_KEY : ${{ secrets.SUPABASE_SERVICE_ROLE_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU' }}
163- SUPABASE_JWT_SECRET : ${{ secrets.SUPABASE_JWT_SECRET || 'your-super-secret-jwt-token-with-at-least-32-characters-long' }}
164- REDIS_PASSWORD : ${{ secrets.REDIS_PASSWORD || 'redis_default_password_for_ci' }}
165- REDIS_DB : ${{ secrets.REDIS_DB || '0' }}
166- REDIS_PORT : ${{ secrets.REDIS_PORT || '6379' }}
167- REDIS_URL : " redis://:${{ secrets.REDIS_PASSWORD || 'redis_default_password_for_ci' }}@localhost:${{ secrets.REDIS_PORT || '6379' }}/${{ secrets.REDIS_DB || '0' }}"
168- run : |
169- cd backend
170- # Clear cache before test to ensure proper isolation
137+ # Clear cache before tests to ensure proper isolation
171138 python -c "import django; django.setup(); from django.core.cache import cache; cache.clear()"
172- # Run API tests with more robust coverage configuration
139+
140+ # Run all backend tests and generate combined coverage
141+ python -m pytest --cov=. --cov-report=xml:coverage.xml --junitxml=junit.xml -o junit_family=legacy
142+
143+ # Run API-specific tests
173144 python -m pytest api/ --cov=api --cov-report=xml:api-coverage.xml --junitxml=api-junit.xml -o junit_family=legacy
174- # Ensure the coverage file exists (create empty if needed)
175- if [ ! -f api-coverage.xml ]; then
176- echo "<?xml version='1.0' encoding='utf-8'?><coverage version='1.0'><packages></packages></coverage>" > api-coverage.xml
177- fi
178-
179- - name : Upload API coverage to Codecov
180- uses : codecov/codecov-action@v3
181- with :
182- file : ./backend/api-coverage.xml
183- slug : " TechWithTy/django-supabase-template"
184- flags : api
185- fail_ci_if_error : false
186-
187- - name : Run Integration Tests
188- env :
189- DJANGO_SECRET_KEY : ${{ secrets.DJANGO_SECRET_KEY || 'test_secret_key' }}
190- DJANGO_DEBUG : " ${{ secrets.DJANGO_DEBUG || 'True' }}"
191- DB_ENGINE : ${{ secrets.DB_ENGINE || 'django.db.backends.postgresql' }}
192- DB_NAME : ${{ secrets.DB_NAME || 'test_db' }}
193- DB_USER : ${{ secrets.DB_USER || 'postgres' }}
194- DB_PASSWORD : ${{ secrets.DB_PASSWORD || 'postgres' }}
195- DB_HOST : ${{ secrets.DB_HOST || 'localhost' }}
196- DB_PORT : ${{ secrets.DB_PORT || '5432' }}
197- SUPABASE_URL : ${{ secrets.SUPABASE_URL || 'http://localhost:54321' }}
198- SUPABASE_ANON_KEY : ${{ secrets.SUPABASE_ANON_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0' }}
199- SUPABASE_SERVICE_ROLE_KEY : ${{ secrets.SUPABASE_SERVICE_ROLE_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU' }}
200- SUPABASE_JWT_SECRET : ${{ secrets.SUPABASE_JWT_SECRET || 'your-super-secret-jwt-token-with-at-least-32-characters-long' }}
201- REDIS_PASSWORD : ${{ secrets.REDIS_PASSWORD || 'redis_default_password_for_ci' }}
202- REDIS_DB : ${{ secrets.REDIS_DB || '0' }}
203- REDIS_PORT : ${{ secrets.REDIS_PORT || '6379' }}
204- REDIS_URL : " redis://:${{ secrets.REDIS_PASSWORD || 'redis_default_password_for_ci' }}@localhost:${{ secrets.REDIS_PORT || '6379' }}/${{ secrets.REDIS_DB || '0' }}"
205- run : |
206- cd backend
207- python -m pytest tests/test_integration.py --cov=. --cov-report=xml:integration-coverage.xml --junitxml=integration-junit.xml -o junit_family=legacy || true
145+
146+ # Run integration tests
147+ python -m pytest tests/test_integration.py --cov=. --cov-report=xml:integration-coverage.xml --junitxml=integration-junit.xml -o junit_family=legacy
148+
149+ # Ensure all coverage files exist (create empty if needed)
150+ for file in coverage.xml api-coverage.xml integration-coverage.xml; do
151+ if [ ! -f $file ]; then
152+ echo "<?xml version='1.0' encoding='utf-8'?><coverage version='1.0'><packages></packages></coverage>" > $file
153+ fi
154+ done
208155
209- - name : Upload Integration coverage to Codecov
156+ - name : Upload Coverage to Codecov
210157 uses : codecov/codecov-action@v3
211158 with :
212- file : ./backend/integration-coverage.xml
159+ files : ./backend/coverage.xml,./backend/api-coverage.xml, ./backend/integration-coverage.xml
213160 slug : " TechWithTy/django-supabase-template"
214- flags : integration
215161 fail_ci_if_error : false
162+ flags : backend,api,integration
163+ name : codecov-umbrella
216164
217- - name : Upload test results to Codecov
165+ - name : Upload Test Results to Codecov
218166 if : ${{ !cancelled() }}
219167 uses : codecov/test-results-action@v1
220168 with :
0 commit comments