-
-
Notifications
You must be signed in to change notification settings - Fork 240
Establish an e2e backend instance locally and in CI/CD #2429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b5c57b4
1e9254b
69092ce
4002a19
0a05fdf
58507cc
36258b5
4119c73
0688a77
a66029c
9846482
f8be096
fbac331
837c665
143ce39
1a42d21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,9 +27,16 @@ exec-backend-command: | |||||||||||||||
| exec-backend-command-it: | ||||||||||||||||
| @docker exec -it nest-backend $(CMD) 2>/dev/null | ||||||||||||||||
|
|
||||||||||||||||
| exec-backend-e2e-command: | ||||||||||||||||
| @docker exec -it nest-backend-e2e $(CMD) | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| exec-db-command-it: | ||||||||||||||||
| @docker exec -it nest-db $(CMD) | ||||||||||||||||
|
|
||||||||||||||||
| exec-db-e2e-command: | ||||||||||||||||
| @docker exec -it nest-db-e2e $(CMD) | ||||||||||||||||
|
|
||||||||||||||||
| clear-cache: | ||||||||||||||||
| @CMD="python manage.py clear_cache" $(MAKE) exec-backend-command | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -53,13 +60,18 @@ dump-data: | |||||||||||||||
| @CMD="sed -E -i 's/\"email\": *\"([^\"]|\\\")*\"/\"email\": \"\"/g' data/nest.json" $(MAKE) exec-backend-command | ||||||||||||||||
| @CMD="gzip -f data/nest.json" $(MAKE) exec-backend-command | ||||||||||||||||
|
|
||||||||||||||||
| dump-db-data-e2e: | ||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use consistent naming
Suggested change
|
||||||||||||||||
| @echo "Dumping Nest e2e data" | ||||||||||||||||
| @CMD="pg_dumpall -U nest_user_e2e --clean | gzip -9 > backend/data/nest-e2e-data.sql.gz" $(MAKE) exec-db-e2e-command | ||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's already under the
Suggested change
|
||||||||||||||||
|
|
||||||||||||||||
|
Comment on lines
+63
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. db dump is broken (shell metacharacters not interpreted; redirection inside container). Run the exec pipeline from the host and avoid TTY. dump-db-data-e2e:
@echo "Dumping Nest e2e data"
- @CMD="pg_dumpall -U nest_user_e2e --clean | gzip -9 > backend/data/nest-e2e-data.sql.gz" $(MAKE) exec-db-e2e-command
+ @mkdir -p backend/data
+ @docker exec -i nest-db-e2e pg_dumpall -U nest_user_e2e --clean | gzip -9 > backend/data/nest-e2e-data.sql.gzNotes:
📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
| enrich-data: \ | ||||||||||||||||
| github-enrich-issues \ | ||||||||||||||||
| owasp-enrich-chapters \ | ||||||||||||||||
| owasp-enrich-committees \ | ||||||||||||||||
| owasp-enrich-events \ | ||||||||||||||||
| owasp-enrich-projects | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| generate-sitemap: | ||||||||||||||||
| @CMD="python manage.py generate_sitemap" $(MAKE) exec-backend-command | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -69,6 +81,10 @@ index-data: | |||||||||||||||
| @CMD="python manage.py algolia_update_replicas" $(MAKE) exec-backend-command | ||||||||||||||||
| @CMD="python manage.py algolia_update_synonyms" $(MAKE) exec-backend-command | ||||||||||||||||
|
|
||||||||||||||||
| load-data-e2e: | ||||||||||||||||
| @echo "Loading Nest e2e data" | ||||||||||||||||
| @CMD="python manage.py load_data" $(MAKE) exec-backend-e2e-command | ||||||||||||||||
|
|
||||||||||||||||
| load-data: | ||||||||||||||||
| @echo "Loading Nest data" | ||||||||||||||||
| @CMD="python manage.py load_data" $(MAKE) exec-backend-command | ||||||||||||||||
|
|
@@ -96,6 +112,10 @@ restore-backup: | |||||||||||||||
| @echo "Restoring Nest backup" | ||||||||||||||||
| @CMD="python manage.py restore_backup" $(MAKE) exec-backend-command | ||||||||||||||||
|
|
||||||||||||||||
| run-backend-e2e: | ||||||||||||||||
| @DOCKER_BUILDKIT=1 \ | ||||||||||||||||
| docker compose --project-name nest-e2e -f docker-compose/backend.e2e.yaml up --build --remove-orphans | ||||||||||||||||
|
|
||||||||||||||||
|
Comment on lines
+115
to
+118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Prevents pipelines from proceeding. run-backend-e2e:
@DOCKER_BUILDKIT=1 \
- docker compose --project-name nest-e2e -f docker-compose/backend.e2e.yaml up --build --remove-orphans
+ docker compose --project-name nest-e2e -f docker-compose/backend.e2e.yaml up -d --build --wait --remove-orphansRequires a backend healthcheck (see compose review). 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
| save-backup: | ||||||||||||||||
| @echo "Saving Nest backup" | ||||||||||||||||
| @CMD="python manage.py dumpdata --natural-primary --natural-foreign --indent=2" $(MAKE) exec-backend-command > backend/data/backup.json | ||||||||||||||||
|
|
||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The backend image should not contain non-production code |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,50 @@ | ||||||||
| services: | ||||||||
| backend: | ||||||||
| container_name: nest-backend-e2e | ||||||||
| command: > | ||||||||
| sh -c ' | ||||||||
| python manage.py migrate && | ||||||||
| python manage.py runserver 0.0.0.0:8000 | ||||||||
| ' | ||||||||
| build: | ||||||||
| context: ../backend | ||||||||
| dockerfile: docker/Dockerfile | ||||||||
| depends_on: | ||||||||
| db: | ||||||||
| condition: service_healthy | ||||||||
| env_file: ../backend/.env | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. env_file path likely breaks CI; use an example/e2e file or drop it. CI runners may not have ../backend/.env; compose will fail. Either point to a committed example (or e2e‑specific) env file or rely on explicit environment defaults. Apply one of: - env_file: ../backend/.env
+ # Use a committed example env for e2e
+ env_file: ../backend/.env.exampleOr remove and rely on explicit env: - env_file: ../backend/.env📝 Committable suggestion
Suggested change
|
||||||||
| environment: | ||||||||
| DJANGO_DB_HOST: ${DJANGO_DB_HOST:-db} | ||||||||
| DJANGO_DB_NAME: ${DJANGO_DB_NAME:-nest_db_e2e} | ||||||||
| DJANGO_DB_PASSWORD: ${DJANGO_DB_PASSWORD:-nest_user_e2e_password} | ||||||||
| DJANGO_DB_PORT: ${DJANGO_DB_PORT:-5432} | ||||||||
| DJANGO_DB_USER: ${DJANGO_DB_USER:-nest_user_e2e} | ||||||||
| networks: | ||||||||
| - nest-network | ||||||||
| ports: | ||||||||
| - 8000:8000 | ||||||||
| db: | ||||||||
| container_name: nest-db-e2e | ||||||||
| image: pgvector/pgvector:pg16 | ||||||||
| environment: | ||||||||
| POSTGRES_DB: ${DJANGO_DB_NAME:-nest_db_e2e} | ||||||||
| POSTGRES_PASSWORD: ${DJANGO_DB_PASSWORD:-nest_user_e2e_password} | ||||||||
| POSTGRES_USER: ${DJANGO_DB_USER:-nest_user_e2e} | ||||||||
| healthcheck: | ||||||||
| interval: 5s | ||||||||
| retries: 5 | ||||||||
| test: [CMD-SHELL, pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB -h localhost -p 5432] | ||||||||
| timeout: 5s | ||||||||
| networks: | ||||||||
| - nest-network | ||||||||
| volumes: | ||||||||
| - db-e2e-data:/var/lib/postgresql/data | ||||||||
| ports: | ||||||||
| - 5433:5432 | ||||||||
|
|
||||||||
|
|
||||||||
| volumes: | ||||||||
| db-e2e-data: | ||||||||
|
|
||||||||
| networks: | ||||||||
| nest-network: | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use non‑TTY exec for CI‑safety.
-tfails on non‑TTY runners; switch to-i.If you still need interactive shells locally, add separate
*-itvariants.Also applies to: 37-39
🤖 Prompt for AI Agents