-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from hpi-sam/77-setup-ci
77 setup ci
- Loading branch information
Showing
23 changed files
with
2,224 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,102 @@ | ||
name: CI Tests | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
hello-world: | ||
build-and-test-frontend: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Build frontend Docker container | ||
run: | | ||
cd ./frontend/ | ||
docker-compose up -d | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Push frontend Docker images | ||
run: | | ||
docker tag dps_training_k-frontend ghcr.io/hpi-sam/dps_training_k-frontend:dev | ||
docker push ghcr.io/hpi-sam/dps_training_k-frontend:dev | ||
build-and-test-backend: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Build backend Docker containers | ||
run: | | ||
cd ./backend/dps_training_k/ | ||
docker-compose up -d | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Push backend Docker images | ||
run: | | ||
docker tag dps_training_k-django ghcr.io/hpi-sam/dps_training_k-django:dev | ||
docker push ghcr.io/hpi-sam/dps_training_k-django:dev | ||
docker tag dps_training_k-celeryworker ghcr.io/hpi-sam/dps_training_k-celeryworker:dev | ||
docker push ghcr.io/hpi-sam/dps_training_k-celeryworker:dev | ||
docker tag dps_training_k-celerybeat ghcr.io/hpi-sam/dps_training_k-celerybeat:dev | ||
docker push ghcr.io/hpi-sam/dps_training_k-celerybeat:dev | ||
docker tag dps_training_k-nginx ghcr.io/hpi-sam/dps_training_k-nginx:dev | ||
docker push ghcr.io/hpi-sam/dps_training_k-nginx:dev | ||
docker tag dps_training_k-postgres ghcr.io/hpi-sam/dps_training_k-postgres:dev | ||
docker push ghcr.io/hpi-sam/dps_training_k-postgres:dev | ||
# Skip redis as it is just the public Docker Hub image anyway and therefore should be directly pulled from there | ||
- name: Run backend tests | ||
run: docker exec K-dPS-django python3 manage.py test | ||
|
||
test-integration: | ||
needs: [build-and-test-frontend, build-and-test-backend] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: print hello world | ||
run: echo "Hello World!" | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Run docker containers with deploy configuration | ||
run: | | ||
cp ./backend/dps_training_k/.env ./ | ||
cp ./frontend/env.d.ts ./ | ||
export IMAGE_TAG=dev | ||
envsubst '${IMAGE_TAG}' < docker-compose.template.yml > docker-compose.yml | ||
docker-compose up -d | ||
- name: Run integration tests | ||
run: | | ||
cd ./frontend/ | ||
npm install cypress --save-dev | ||
npx cypress run --e2e | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,59 @@ | ||
name: Build and Push Docker Images | ||
name: Deploy | ||
|
||
on: | ||
release: | ||
types: [published] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
hello-world: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: print hello world | ||
run: echo "Hello World!" | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push frontend Docker images | ||
run: | | ||
cd ./frontend/ | ||
docker-compose build | ||
docker tag dps_training_k-frontend ghcr.io/hpi-sam/dps_training_k-frontend:latest | ||
docker push ghcr.io/hpi-sam/dps_training_k-frontend:latest | ||
- name: Build and push backend Docker images | ||
run: | | ||
cd ./backend/dps_training_k/ | ||
docker-compose build | ||
docker tag dps_training_k-django ghcr.io/hpi-sam/dps_training_k-django:latest | ||
docker push ghcr.io/hpi-sam/dps_training_k-django:latest | ||
docker tag dps_training_k-celeryworker ghcr.io/hpi-sam/dps_training_k-celeryworker:latest | ||
docker push ghcr.io/hpi-sam/dps_training_k-celeryworker:latest | ||
docker tag dps_training_k-celerybeat ghcr.io/hpi-sam/dps_training_k-celerybeat:latest | ||
docker push ghcr.io/hpi-sam/dps_training_k-celerybeat:latest | ||
docker tag dps_training_k-nginx ghcr.io/hpi-sam/dps_training_k-nginx:latest | ||
docker push ghcr.io/hpi-sam/dps_training_k-nginx:latest | ||
docker tag dps_training_k-postgres ghcr.io/hpi-sam/dps_training_k-postgres:latest | ||
docker push ghcr.io/hpi-sam/dps_training_k-postgres:latest | ||
# Skip redis as it is just the public Docker Hub image anyway and therefore should be directly pulled from there | ||
- name: Prepare deployment files | ||
run: | | ||
mkdir deployment_files | ||
cp docker-compose.template.yml deployment_files/ | ||
cp frontend/env.d.ts deployment_files/ | ||
cp backend/dps_training_k/.env deployment_files/ | ||
- name: Archive deployment files | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: deployment-files | ||
path: deployment_files/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.vscode/settings.json | ||
backend/.vscode/settings.json | ||
.idea/ | ||
.vscode/launch.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM nginx:1.21-alpine | ||
FROM nginx:latest | ||
|
||
RUN rm /etc/nginx/conf.d/default.conf | ||
COPY nginx.conf /etc/nginx/conf.d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
version: '3.8' | ||
|
||
volumes: | ||
local_postgres_data: { } | ||
local_postgres_data_backups: { } | ||
static_volume: { } | ||
|
||
services: | ||
web: | ||
image: ghcr.io/hpi-sam/dps_training_k-frontend:${IMAGE_TAG} | ||
container_name: K-dPS-frontend | ||
ports: | ||
- "5173:5173" | ||
|
||
django: | ||
image: ghcr.io/hpi-sam/dps_training_k-django:${IMAGE_TAG} | ||
container_name: K-dPS-django | ||
restart: unless-stopped | ||
depends_on: | ||
- postgres | ||
- redis | ||
env_file: | ||
- .env | ||
environment: | ||
- RUN_MIGRATIONS=1 | ||
volumes: | ||
- static_volume:/app/staticfiles | ||
expose: | ||
- 8000 | ||
command: uvicorn configuration.asgi:application --host 0.0.0.0 --reload | ||
|
||
|
||
postgres: | ||
image: ghcr.io/hpi-sam/dps_training_k-postgres:${IMAGE_TAG} | ||
container_name: K-dPS-postgres | ||
volumes: | ||
- local_postgres_data:/var/lib/postgresql/data:Z | ||
- local_postgres_data_backups:/backups:z | ||
env_file: | ||
- .env | ||
healthcheck: | ||
test: [ "CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}" ] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
|
||
redis: | ||
image: redis:latest | ||
container_name: K-dPS-redis | ||
|
||
celeryworker: | ||
env_file: | ||
- .env | ||
image: ghcr.io/hpi-sam/dps_training_k-celeryworker:${IMAGE_TAG} | ||
container_name: K-dPS-celeryworker | ||
command: /start-celeryworker | ||
depends_on: | ||
- django | ||
|
||
celerybeat: | ||
env_file: | ||
- .env | ||
image: ghcr.io/hpi-sam/dps_training_k-celerybeat:${IMAGE_TAG} | ||
container_name: K-dPS-celerybeat | ||
command: /start-celerybeat | ||
depends_on: | ||
- django | ||
|
||
nginx: | ||
image: ghcr.io/hpi-sam/dps_training_k-nginx:${IMAGE_TAG} | ||
container_name: K-dPS-nginx | ||
volumes: | ||
- static_volume:/app/staticfiles | ||
ports: | ||
- "8000:80" | ||
depends_on: | ||
- django |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from "cypress" | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
setupNodeEvents(on, config) { | ||
// implement node event listeners here | ||
}, | ||
}, | ||
}) |
Oops, something went wrong.