Skip to content
Draft
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b5c57b4
Add dockerfile and compose and update makefile
ahmedxgouda Oct 14, 2025
1e9254b
Dump db-data
ahmedxgouda Oct 15, 2025
69092ce
Reorder makefile
ahmedxgouda Oct 15, 2025
4002a19
Dump db-data
ahmedxgouda Oct 15, 2025
0a05fdf
Remove e2e dockerfile
ahmedxgouda Oct 18, 2025
58507cc
Add CI/CD
ahmedxgouda Oct 18, 2025
36258b5
Merge branch 'main' into feature/e2e-backend
ahmedxgouda Oct 18, 2025
4119c73
Apply rabbit's suggestions
ahmedxgouda Oct 18, 2025
0688a77
Add postgres instead of pgvector
ahmedxgouda Oct 18, 2025
a66029c
Remove needs
ahmedxgouda Oct 18, 2025
9846482
Update envs
ahmedxgouda Oct 18, 2025
f8be096
Fix migrations step
ahmedxgouda Oct 18, 2025
fbac331
Add envs to docker
ahmedxgouda Oct 18, 2025
837c665
Remove migrations step
ahmedxgouda Oct 18, 2025
143ce39
Remove --without test from dockerfile
ahmedxgouda Oct 18, 2025
1a42d21
Copy tests in dockerfile and add needs to gh workflow
ahmedxgouda Oct 18, 2025
f619928
Update dockerfile
ahmedxgouda Oct 26, 2025
93f3180
Merge branch 'main' into feature/e2e-backend
ahmedxgouda Oct 26, 2025
8893db1
Apply suggestion
ahmedxgouda Oct 26, 2025
1e39448
Use the e2e instance in the frontend e2e tests
ahmedxgouda Oct 26, 2025
a659f0a
Update CI/CD
ahmedxgouda Oct 26, 2025
009b32c
Update CI/CD
ahmedxgouda Oct 26, 2025
54f09ee
Update CI/CD
ahmedxgouda Oct 26, 2025
f1b0af0
Update CI/CD
ahmedxgouda Oct 26, 2025
3376a65
Update CI/CD and dockerfile
ahmedxgouda Oct 26, 2025
3f76de1
Update CI/CD
ahmedxgouda Oct 26, 2025
0300e4e
Update CI/CD
ahmedxgouda Oct 26, 2025
89ad0a6
Update CI/CD
ahmedxgouda Oct 26, 2025
ee3055f
Update CI/CD
ahmedxgouda Oct 26, 2025
8c73507
Update CI/CD
ahmedxgouda Oct 26, 2025
e2f1162
Update CI/CD
ahmedxgouda Oct 26, 2025
bf347ef
Update CI/CD
ahmedxgouda Oct 26, 2025
c5909b3
Update CI/CD
ahmedxgouda Oct 26, 2025
fae06b4
Update CI/CD
ahmedxgouda Oct 26, 2025
78cd6c8
Update CI/CD
ahmedxgouda Oct 26, 2025
d054d25
Update CI/CD
ahmedxgouda Oct 26, 2025
dcd91be
Update CI/CD
ahmedxgouda Oct 26, 2025
913ffcb
Update CI/CD
ahmedxgouda Oct 26, 2025
ba9671b
Restore needs for the job
ahmedxgouda Oct 26, 2025
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
67 changes: 67 additions & 0 deletions .github/workflows/run-ci-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,73 @@ jobs:
run: |
docker run -e DJANGO_SETTINGS_MODULE=settings.test --env-file backend/.env.example owasp/nest:test-backend-latest pytest

run-backend-e2e:
name: Run backend end-to-end tests
needs:
- scan-code
- scan-ci-dependencies
runs-on: ubuntu-latest
services:
db:
image: pgvector/pgvector:pg16
env:
POSTGRES_DB: nest_db_e2e
POSTGRES_PASSWORD: nest_user_e2e_password
POSTGRES_USER: nest_user_e2e
options: >-
--health-cmd="pg_isready -U nest_user_e2e -d nest_db_e2e -h localhost -p 5432"
--health-interval=5s
--health-timeout=5s
--health-retries=5
ports:
- 5432:5432
steps:
- name: Check out repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8

- name: Set up Docker buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435

- name: Wait for database to be ready
run: |
until docker exec ${{ job.services.db.id }} pg_isready -U nest_user_e2e -d nest_db_e2e; do
echo "Waiting for database..."
sleep 5
done

- name: Install PostgreSQL client
run: sudo apt-get install -y postgresql-client

- name: Load Postgres data
env:
PGPASSWORD: nest_user_e2e_password
run: |
gunzip -c backend/data/nest-e2e-data.sql.gz | psql -h localhost -U nest_user_e2e -d nest_db_e2e

- name: Build backend e2e test image
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83
with:
cache-from: |
type=gha
cache-to: |
type=gha,compression=zstd
context: backend
file: backend/docker/Dockerfile
load: true
platforms: linux/amd64
tags: owasp/nest:test-backend-e2e-latest

- name: Run backend end-to-end tests
run: |
docker run --network host \
-e DJANGO_DB_HOST=localhost \
-e DJANGO_DB_NAME=nest_db_e2e \
-e DJANGO_DB_PASSWORD=nest_user_e2e_password \
-e DJANGO_DB_PORT=5432 \
-e DJANGO_DB_USER=nest_user_e2e \
-e DJANGO_SETTINGS_MODULE=settings.test \
--env-file backend/.env.example owasp/nest:test-backend-e2e-latest pytest

run-frontend-unit-tests:
name: Run frontend unit tests
needs:
Expand Down
20 changes: 20 additions & 0 deletions backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
@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

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

Expand All @@ -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
Expand Down Expand Up @@ -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

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
Expand Down
Binary file added backend/data/nest-e2e-data.sql.gz
Binary file not shown.
5 changes: 2 additions & 3 deletions backend/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ USER owasp

COPY --chmod=444 --chown=root:root poetry.lock pyproject.toml ./
RUN --mount=type=cache,target=${POETRY_CACHE_DIR},uid=${OWASP_UID},gid=${OWASP_GID} \
poetry install --no-root --without dev --without test
poetry install --no-root --without dev

COPY apps apps
COPY docker/entrypoint.sh entrypoint.sh
COPY manage.py wsgi.py ./
COPY settings settings
COPY static static
COPY templates templates
COPY tests tests

FROM python:3.13.7-alpine

Expand All @@ -63,5 +64,3 @@ RUN rm -rf /home/owasp/.cache && \
chmod +x /home/owasp/entrypoint.sh

USER owasp

CMD ["/home/owasp/entrypoint.sh"]
50 changes: 50 additions & 0 deletions docker-compose/backend.e2e.yaml
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
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:
1 change: 1 addition & 0 deletions docker-compose/production.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
services:
production-nest-backend:
container_name: production-nest-backend
entrypoint: /home/owasp/entrypoint.sh
image: owasp/nest:backend-production
env_file: .env.backend
depends_on:
Expand Down
1 change: 1 addition & 0 deletions docker-compose/staging.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
services:
staging-nest-backend:
container_name: staging-nest-backend
entrypoint: /home/owasp/entrypoint.sh
image: owasp/nest:backend-staging
env_file: .env.backend
depends_on:
Expand Down