@@ -144,14 +144,75 @@ jobs:
144144 with :
145145 file : ./backend/coverage.xml
146146 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+ python -m pytest api/ --cov=api --cov-report=xml:api-coverage.xml --junitxml=api-junit.xml -o junit_family=legacy || true
171+
172+ - name : Upload API coverage to Codecov
173+ uses : codecov/codecov-action@v3
174+ with :
175+ file : ./backend/api-coverage.xml
176+ slug : " TechWithTy/django-supabase-template"
177+ flags : api
178+ fail_ci_if_error : false
179+
180+ - name : Run Integration Tests
181+ env :
182+ DJANGO_SECRET_KEY : ${{ secrets.DJANGO_SECRET_KEY || 'test_secret_key' }}
183+ DJANGO_DEBUG : " ${{ secrets.DJANGO_DEBUG || 'True' }}"
184+ DB_ENGINE : ${{ secrets.DB_ENGINE || 'django.db.backends.postgresql' }}
185+ DB_NAME : ${{ secrets.DB_NAME || 'test_db' }}
186+ DB_USER : ${{ secrets.DB_USER || 'postgres' }}
187+ DB_PASSWORD : ${{ secrets.DB_PASSWORD || 'postgres' }}
188+ DB_HOST : ${{ secrets.DB_HOST || 'localhost' }}
189+ DB_PORT : ${{ secrets.DB_PORT || '5432' }}
190+ SUPABASE_URL : ${{ secrets.SUPABASE_URL || 'http://localhost:54321' }}
191+ SUPABASE_ANON_KEY : ${{ secrets.SUPABASE_ANON_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0' }}
192+ SUPABASE_SERVICE_ROLE_KEY : ${{ secrets.SUPABASE_SERVICE_ROLE_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU' }}
193+ SUPABASE_JWT_SECRET : ${{ secrets.SUPABASE_JWT_SECRET || 'your-super-secret-jwt-token-with-at-least-32-characters-long' }}
194+ REDIS_PASSWORD : ${{ secrets.REDIS_PASSWORD || 'redis_default_password_for_ci' }}
195+ REDIS_DB : ${{ secrets.REDIS_DB || '0' }}
196+ REDIS_PORT : ${{ secrets.REDIS_PORT || '6379' }}
197+ REDIS_URL : " redis://:${{ secrets.REDIS_PASSWORD || 'redis_default_password_for_ci' }}@localhost:${{ secrets.REDIS_PORT || '6379' }}/${{ secrets.REDIS_DB || '0' }}"
198+ run : |
199+ cd backend
200+ python -m pytest tests/test_integration.py --cov=. --cov-report=xml:integration-coverage.xml --junitxml=integration-junit.xml -o junit_family=legacy || true
201+
202+ - name : Upload Integration coverage to Codecov
203+ uses : codecov/codecov-action@v3
204+ with :
205+ file : ./backend/integration-coverage.xml
206+ slug : " TechWithTy/django-supabase-template"
207+ flags : integration
147208 fail_ci_if_error : false
148209
149210 - name : Upload test results to Codecov
150211 if : ${{ !cancelled() }}
151212 uses : codecov/test-results-action@v1
152213 with :
153214 token : ${{ secrets.CODECOV_TOKEN }}
154- file : ./backend/junit.xml
215+ file : ./backend/junit.xml,./backend/api-junit.xml,./backend/integration-junit.xml
155216
156217 build :
157218 name : Build Docker Image
@@ -191,15 +252,24 @@ jobs:
191252 echo "cache_tag=staging" >> $GITHUB_OUTPUT
192253 fi
193254
255+ - name : Set repository variables
256+ id : repo-vars
257+ run : |
258+ # Convert any uppercase characters to lowercase in the repository name
259+ REPO_OWNER="$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')"
260+ REPO_NAME="$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]')"
261+ echo "repo_owner=$REPO_OWNER" >> $GITHUB_OUTPUT
262+ echo "repo_name=$REPO_NAME" >> $GITHUB_OUTPUT
263+
194264 - name : Build and push Docker image
195265 uses : docker/build-push-action@v4
196266 with :
197267 context : .
198268 file : ./docker/Dockerfile
199269 push : true
200270 tags : |
201- ghcr.io/${{ github.repository }}:${{ steps.set-env.outputs.env }}
202- ghcr.io/${{ github.repository }}:${{ github.sha }}
271+ ghcr.io/${{ steps.repo-vars.outputs.repo_owner }}/${{ steps.repo-vars.outputs.repo_name }}:${{ steps.set-env.outputs.env }}
272+ ghcr.io/${{ steps.repo-vars.outputs.repo_owner }}/${{ steps.repo-vars.outputs.repo_name }}:${{ github.sha }}
203273 cache-from : type=local,src=/tmp/.buildx-cache
204274 cache-to : type=local,dest=/tmp/.buildx-cache-new,mode=max
205275 build-args : |
0 commit comments