From a467ad5f14c44326fcf67b75efd70f47282054b6 Mon Sep 17 00:00:00 2001 From: Mariano Ruiz Date: Fri, 19 Apr 2024 19:08:31 -0300 Subject: [PATCH] Run e2e tests from CI --- .env.example | 25 ----- .github/workflows/docker-image.yml | 31 ++++++ .gitignore | 2 + compose.yml | 159 ----------------------------- 4 files changed, 33 insertions(+), 184 deletions(-) delete mode 100644 .env.example delete mode 100644 compose.yml diff --git a/.env.example b/.env.example deleted file mode 100644 index be6a950..0000000 --- a/.env.example +++ /dev/null @@ -1,25 +0,0 @@ -PYTHONUNBUFFERED=1 -DEBUG=true -DATABASE_URL=postgresql://dcoleman:postgres@postgres/dcoleman_dev -POSTGRES_PASSWORD=postgres -LANGUAGE_CODE=en -PORT=8000 -REST_ENABLED=true -SECRET_KEY=f*)$)fay97180m+ti%xi8si##u__h(8%(ipr1z-*lsjbucooz& -LOG_LEVEL=INFO -LOG_LEVEL_DJANGO=INFO -LOG_LEVEL_DJANGO_DB=INFO -LOG_LEVEL_DJANGO_REQ=INFO -EMAIL_HOST_USER=YOUREMAIL@gmail.com -EMAIL_HOST_PASSWORD=PASS -EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend -TASKS_SEND_EMAILS_TO_ASSIGNED=true -TASKS_SEND_EMAILS_TO_PARTNERS=true -TASKS_VIEWER_ENABLED=true -AUTH_PASSWORD_VALIDATORS_ENABLED=false -APP_EMAIL=no-reply@localhost -APP_NAME=Django Coleman -SITE_HEADER=Django Coleman - A Simple Task Manager -ADMIN_USERNAME=admin -ADMIN_PASSWORD=admin1234 -DCOLEMAN_ENDPOINT=http://django-coleman:8000/api/v1 diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index b635955..ea31c5a 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -25,6 +25,37 @@ jobs: - name: Release Docker image if: ${{ github.ref != 'refs/heads/master' }} run: docker push "mrsarm/django-coleman:${GITHUB_REF_SLUG}" + + - name: Get GitHub downloader + run: wget https://gist.github.com/mrsarm/95279381f3d8bf4269499fb437888e2c/raw/github-file.sh + - name: Get compose.yaml + env: + TOKEN: ${{ secrets.repo_token }} + run: bash ./github-file.sh compose.yaml mrsarm/dcoleman-e2e $GITHUB_REF_SLUG main $TOKEN + - name: Get .env.example + env: + TOKEN: ${{ secrets.repo_token }} + run: bash ./github-file.sh .env.example mrsarm/dcoleman-e2e $GITHUB_REF_SLUG main $TOKEN + + - name: Setup environment variables + run: cp .env.example .env + - name: Download pose + if: ${{ github.ref != 'refs/heads/master' }} + run: wget https://github.com/mrsarm/pose/releases/download/0.4.0-b4/pose-0.4.0-b4-x86_64-unknown-linux-gnu.tar.gz + - name: Unpack pose + if: ${{ github.ref != 'refs/heads/master' }} + run: tar -xvf pose*.tar.gz + - name: Build compose file for CI with pose + if: ${{ github.ref != 'refs/heads/master' }} + run: ./pose --no-docker config --tag "${GITHUB_REF_SLUG}" --tag-filter regex=mrsarm/ --progress -o ci.yaml + - name: Create compose file for CI without pose + if: ${{ github.ref == 'refs/heads/master' }} + run: cp compose.yaml ci.yaml + - name: Pull images + run: docker compose -f ci.yaml pull + - name: Run e2e tests + run: docker compose -f ci.yaml run dcoleman-e2e + - name: Tag "latest" if: ${{ github.ref == 'refs/heads/master' }} run: docker tag "mrsarm/django-coleman:${GITHUB_REF_SLUG}" mrsarm/django-coleman:latest diff --git a/.gitignore b/.gitignore index 8ceea19..e3c8b5d 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,5 @@ venv*/ /htmlcov /.coverage + +ci*.yaml diff --git a/compose.yml b/compose.yml deleted file mode 100644 index 447fda5..0000000 --- a/compose.yml +++ /dev/null @@ -1,159 +0,0 @@ -name: coleman - -volumes: - data: # Volume name listed: django-coleman_data - driver: local - -services: - django-coleman: - image: "mrsarm/django-coleman:${TAG:-latest}" - build: - context: . - args: - - BUILD - ports: - - "8000:8000" - environment: - # Set the values in an .env file or here - - PYTHONUNBUFFERED - - DEBUG - - DATABASE_URL - - POSTGRES_PASSWORD - - LANGUAGE_CODE - - PORT - - REST_ENABLED - - SECRET_KEY - - LOG_LEVEL - - LOG_LEVEL_DJANGO - - LOG_LEVEL_DJANGO_DB - - LOG_LEVEL_DJANGO_REQ - - EMAIL_HOST_USER - - EMAIL_HOST_PASSWORD - - EMAIL_BACKEND - - TASKS_SEND_EMAILS_TO_ASSIGNED - - TASKS_SEND_EMAILS_TO_PARTNERS - - TASKS_VIEWER_ENABLED - - AUTH_PASSWORD_VALIDATORS_ENABLED - - APP_EMAIL - - APP_NAME - - SITE_HEADER - - ADMIN_USERNAME - - ADMIN_PASSWORD - depends_on: - postgres: - condition: service_healthy - - postgres: - image: postgres:15 - environment: - - POSTGRES_PASSWORD=postgres - - PGUSER=postgres - ports: - - "5432:5432" - volumes: - - data:/var/lib/postgresql/data - healthcheck: - test: ["CMD-SHELL", "pg_isready"] - interval: 1s - timeout: 3s - retries: 5 - command: ["postgres", "-c", "log_statement=all"] # Comment to disable SQL logs. all: all queries, ddl: DDL only, mod: DDL and modifying statements - - django-coleman-mtasks-viewer: - image: "mrsarm/django-coleman-mtasks-viewer" - ports: - - "8888:8888" - environment: - - PORT=8888 - - DCOLEMAN_ENDPOINT - - DCOLEMAN_TASKS_VIEWER_HASH_SALT - - DCOLEMAN_MASTER_TOKEN - depends_on: - - django-coleman - - # - # **tools** profile, none of these services runs on startup by default, - # and all are commands that exit once the task finished - # - - - psql: - image: postgres:15 - command: psql postgres -h postgres -U postgres - depends_on: - - postgres - profiles: - - tools - - - # Provide all the DB resources: DB and DB user creation, DB migrations and admin user creation - django-coleman-provision: - image: "mrsarm/django-coleman:${TAG:-latest}" - environment: - - PROCESS_TYPE=provision - - POSTGRES_PASSWORD - - DATABASE_URL - - ADMIN_USERNAME - - ADMIN_PASSWORD - depends_on: - postgres: - condition: service_healthy - profiles: - - tools - - - # One by one provision tasks - # - # Useful in case you only need to run one, e.g. to - # create a new administrator user "john", you would - # normally run `docker-compose up' first to launch - # all the apps, and then in another terminal: - # `ADMIN_USERNAME=john ADMIN_PASSWORD=secretpass docker-compose up django-coleman-createadmin' - - django-coleman-createdb: - image: "mrsarm/django-coleman:${TAG:-latest}" - environment: - - PROCESS_TYPE=createdb - - POSTGRES_PASSWORD - - DATABASE_URL - depends_on: - postgres: - condition: service_healthy - profiles: - - tools - - django-coleman-migrate: - image: "mrsarm/django-coleman:${TAG:-latest}" - environment: - - PROCESS_TYPE=migrate - - DATABASE_URL - - LOG_LEVEL_DJANGO_DB=INFO - depends_on: - postgres: - condition: service_healthy - profiles: - - tools - - django-coleman-createadmin: - image: "mrsarm/django-coleman:${TAG:-latest}" - environment: - - PROCESS_TYPE=createadmin - - DATABASE_URL - - ADMIN_USERNAME - - ADMIN_PASSWORD - - LOG_LEVEL_DJANGO_DB=INFO - depends_on: - postgres: - condition: service_healthy - profiles: - - tools - - - # Run automated tests - - django-coleman-test: - image: "mrsarm/django-coleman:${TAG:-latest}" - environment: - - PROCESS_TYPE=test - profiles: - - tools