E2E CI pipeline mit ephemerer Infrastruktur
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
- drone.yml: deploy_latest Pipeline mit k3s test-backend, OpenTofu E2E-VMs, E2E-Test-Ausführung, Email-Notification und Cleanup - Alte tag/promote Pipelines auskommentiert - APK build/upload vorerst auskommentiert - E2E test runner script (scripts/e2e-test.sh) - tsconfig: expo/tsconfig.base Extension - CLAUDE.md an neue CI/CD-Struktur angepasst
This commit is contained in:
351
.drone.yml
351
.drone.yml
@@ -41,7 +41,7 @@
|
||||
# - npm run check_format
|
||||
#
|
||||
# ---
|
||||
#
|
||||
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: deploy_latest
|
||||
@@ -61,6 +61,7 @@ steps:
|
||||
# dockerfile: apps/server/docker/Dockerfile
|
||||
# tags:
|
||||
# - latest
|
||||
# - ${DRONE_COMMIT_SHA:0:8}
|
||||
# username:
|
||||
# from_secret: gitea_username
|
||||
# password:
|
||||
@@ -84,93 +85,279 @@ steps:
|
||||
# - docker pull gitea.gilmour109.de/gilmour109/calchat-server:latest
|
||||
# - docker compose -f /root/calchat-mongo/docker-compose.yml up -d
|
||||
|
||||
- name: build_apk
|
||||
image: gitea.gilmour109.de/gilmour109/eas-build:latest
|
||||
- name: deploy_test_backend
|
||||
image: gitea.gilmour109.de/gilmour109/e2e-tools:latest
|
||||
environment:
|
||||
EXPO_TOKEN:
|
||||
from_secret: expo_token
|
||||
K3S_SSH_PASSWORD:
|
||||
from_secret: k3s_ssh_password
|
||||
commands:
|
||||
- npm ci
|
||||
- npm run build -w @calchat/shared
|
||||
- npm run -w @calchat/client build:apk
|
||||
- export NAME=e2e$(echo $DRONE_COMMIT_SHA | head -c 8)
|
||||
- export TAG=$(echo $DRONE_COMMIT_SHA | head -c 8)
|
||||
- export COMMIT=$DRONE_COMMIT_SHA
|
||||
- envsubst < kubernetes/manifest.yml > /tmp/e2e-manifest.yml
|
||||
- sshpass -p "$K3S_SSH_PASSWORD" scp /tmp/e2e-manifest.yml debian@192.168.178.201:/tmp/e2e-manifest.yml
|
||||
- sshpass -p "$K3S_SSH_PASSWORD" ssh debian@192.168.178.201 "sudo kubectl apply -f /tmp/e2e-manifest.yml"
|
||||
- sshpass -p "$K3S_SSH_PASSWORD" ssh debian@192.168.178.201 "sudo kubectl wait --for=condition=available --timeout=120s deployment/calchat-server-$NAME"
|
||||
|
||||
- name: upload_apk
|
||||
image: plugins/s3
|
||||
- name: create_e2e_vm
|
||||
image: gitea.gilmour109.de/gilmour109/e2e-tools:latest
|
||||
environment:
|
||||
TF_VAR_run_id: ${DRONE_BUILD_NUMBER}
|
||||
TF_VAR_proxmox_password:
|
||||
from_secret: proxmox_password
|
||||
TF_VAR_clone_vm_password:
|
||||
from_secret: e2e_vm_password
|
||||
TOFU_GARAGE_ACCESS_KEY:
|
||||
from_secret: tofu_garage_access_key
|
||||
TOFU_GARAGE_SECRET_KEY:
|
||||
from_secret: tofu_garage_secret_key
|
||||
commands:
|
||||
- cd tofu/e2e
|
||||
- tofu init
|
||||
- tofu apply -auto-approve
|
||||
|
||||
- name: run_e2e_tests
|
||||
image: gitea.gilmour109.de/gilmour109/e2e-tools:latest
|
||||
environment:
|
||||
E2E_VM_PASSWORD:
|
||||
from_secret: e2e_vm_password
|
||||
commands:
|
||||
- export VM_IP=192.168.178.$((211 + DRONE_BUILD_NUMBER % 44))
|
||||
- export RUN_ID=$(echo $DRONE_COMMIT_SHA | head -c 8)
|
||||
- export API_URL="http://e2e$${RUN_ID}.192.168.178.201.nip.io"
|
||||
- echo "Waiting for VM to be reachable..."
|
||||
- timeout 120 bash -c "until sshpass -p '$E2E_VM_PASSWORD' ssh debian@$VM_IP 'echo ok' 2>/dev/null; do sleep 5; done"
|
||||
- sshpass -p "$E2E_VM_PASSWORD" scp scripts/e2e-test.sh debian@$VM_IP:/tmp/e2e-test.sh
|
||||
- sshpass -p "$E2E_VM_PASSWORD" ssh debian@$VM_IP "chmod +x /tmp/e2e-test.sh"
|
||||
- sshpass -p "$E2E_VM_PASSWORD" ssh debian@$VM_IP "REPO_URL=https://gitea.gilmour109.de/gilmour109/calchat.git COMMIT_SHA=$DRONE_COMMIT_SHA API_URL=$API_URL bash /tmp/e2e-test.sh"
|
||||
- sshpass -p "$E2E_VM_PASSWORD" scp debian@$VM_IP:/tmp/e2e-results.txt /tmp/e2e-results.txt
|
||||
|
||||
- name: notify_failure
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
endpoint: https://garage.gilmour109.de
|
||||
bucket: calchat-releases
|
||||
access_key:
|
||||
from_secret: calchat_drone_garage_access_key
|
||||
secret_key:
|
||||
from_secret: calchat_drone_garage_secret_key
|
||||
source: apps/client/calchat.apk
|
||||
target: /
|
||||
region: garage
|
||||
path_style: true
|
||||
host:
|
||||
from_secret: smtp_host
|
||||
username:
|
||||
from_secret: smtp_username
|
||||
password:
|
||||
from_secret: smtp_password
|
||||
from: liwa7755@bht-berlin.de
|
||||
recipients:
|
||||
- liwa7755@bht-berlin.de
|
||||
subject: "E2E Tests failed: ${DRONE_REPO} #${DRONE_BUILD_NUMBER}"
|
||||
body: |
|
||||
E2E tests failed for commit ${DRONE_COMMIT_SHA:0:8} on branch ${DRONE_BRANCH}.
|
||||
Build: ${DRONE_BUILD_LINK}
|
||||
when:
|
||||
status:
|
||||
- failure
|
||||
|
||||
- name: destroy_e2e_vm
|
||||
image: gitea.gilmour109.de/gilmour109/e2e-tools:latest
|
||||
environment:
|
||||
TF_VAR_run_id: ${DRONE_BUILD_NUMBER}
|
||||
TF_VAR_proxmox_password:
|
||||
from_secret: proxmox_password
|
||||
TF_VAR_clone_vm_password:
|
||||
from_secret: e2e_vm_password
|
||||
TOFU_GARAGE_ACCESS_KEY:
|
||||
from_secret: tofu_garage_access_key
|
||||
TOFU_GARAGE_SECRET_KEY:
|
||||
from_secret: tofu_garage_secret_key
|
||||
commands:
|
||||
- cd tofu/e2e
|
||||
- tofu init
|
||||
- tofu destroy -auto-approve
|
||||
when:
|
||||
status:
|
||||
- success
|
||||
- failure
|
||||
|
||||
- name: cleanup_k3s
|
||||
image: gitea.gilmour109.de/gilmour109/e2e-tools:latest
|
||||
environment:
|
||||
K3S_SSH_PASSWORD:
|
||||
from_secret: k3s_ssh_password
|
||||
commands:
|
||||
- export NAME=e2e$(echo $DRONE_COMMIT_SHA | head -c 8)
|
||||
- sshpass -p "$K3S_SSH_PASSWORD" ssh debian@192.168.178.201 "sudo kubectl delete all,ingress -l deploy-name=$NAME --ignore-not-found"
|
||||
when:
|
||||
status:
|
||||
- success
|
||||
- failure
|
||||
|
||||
# - name: build_apk
|
||||
# image: gitea.gilmour109.de/gilmour109/eas-build:latest
|
||||
# environment:
|
||||
# EXPO_TOKEN:
|
||||
# from_secret: expo_token
|
||||
# commands:
|
||||
# - npm ci
|
||||
# - npm run build -w @calchat/shared
|
||||
# - npm run -w @calchat/client build:apk
|
||||
# when:
|
||||
# status:
|
||||
# - success
|
||||
#
|
||||
# - name: upload_apk
|
||||
# image: plugins/s3
|
||||
# settings:
|
||||
# endpoint: https://garage.gilmour109.de
|
||||
# bucket: calchat-releases
|
||||
# access_key:
|
||||
# from_secret: calchat_drone_garage_access_key
|
||||
# secret_key:
|
||||
# from_secret: calchat_drone_garage_secret_key
|
||||
# source: apps/client/calchat.apk
|
||||
# target: /
|
||||
# region: garage
|
||||
# path_style: true
|
||||
# when:
|
||||
# status:
|
||||
# - success
|
||||
|
||||
# depends_on:
|
||||
# - server_build_and_test
|
||||
# - check_for_formatting
|
||||
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: upload_tag
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- tag
|
||||
|
||||
steps:
|
||||
- name: upload_tag
|
||||
image: plugins/docker
|
||||
settings:
|
||||
registry: gitea.gilmour109.de
|
||||
repo: gitea.gilmour109.de/gilmour109/calchat-server
|
||||
dockerfile: apps/server/docker/Dockerfile
|
||||
tags:
|
||||
- ${DRONE_TAG}
|
||||
username:
|
||||
from_secret: gitea_username
|
||||
password:
|
||||
from_secret: gitea_password
|
||||
|
||||
- name: deploy_to_k3s
|
||||
image: appleboy/drone-ssh
|
||||
settings:
|
||||
host:
|
||||
- 192.168.178.201
|
||||
username: debian
|
||||
password:
|
||||
from_secret: k3s_ssh_password
|
||||
envs:
|
||||
- drone_tag
|
||||
- drone_commit_sha
|
||||
port: 22
|
||||
command_timeout: 10m
|
||||
script:
|
||||
- export TAG=$DRONE_TAG
|
||||
- export NAME=$(echo $DRONE_TAG | tr -d '.')
|
||||
- export COMMIT=$DRONE_COMMIT_SHA
|
||||
- envsubst < /home/debian/manifest.yml | sudo kubectl apply -f -
|
||||
|
||||
- name: build_apk
|
||||
image: gitea.gilmour109.de/gilmour109/eas-build:latest
|
||||
environment:
|
||||
EXPO_TOKEN:
|
||||
from_secret: expo_token
|
||||
commands:
|
||||
- npm ci
|
||||
- npm run build -w @calchat/shared
|
||||
- npm run -w @calchat/client build:apk
|
||||
|
||||
- name: release_apk
|
||||
image: plugins/gitea-release
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: gitea_token
|
||||
base_url: https://gitea.gilmour109.de
|
||||
files:
|
||||
- calchat.apk
|
||||
title: ${DRONE_TAG}
|
||||
# ---
|
||||
#
|
||||
# kind: pipeline
|
||||
# type: docker
|
||||
# name: upload_tag
|
||||
#
|
||||
# trigger:
|
||||
# event:
|
||||
# - tag
|
||||
#
|
||||
# steps:
|
||||
# - name: upload_tag
|
||||
# image: plugins/docker
|
||||
# settings:
|
||||
# registry: gitea.gilmour109.de
|
||||
# repo: gitea.gilmour109.de/gilmour109/calchat-server
|
||||
# dockerfile: apps/server/docker/Dockerfile
|
||||
# tags:
|
||||
# - ${DRONE_TAG}
|
||||
# username:
|
||||
# from_secret: gitea_username
|
||||
# password:
|
||||
# from_secret: gitea_password
|
||||
#
|
||||
# - name: deploy_to_k3s
|
||||
# image: appleboy/drone-ssh
|
||||
# settings:
|
||||
# host:
|
||||
# - 192.168.178.201
|
||||
# username: debian
|
||||
# password:
|
||||
# from_secret: k3s_ssh_password
|
||||
# envs:
|
||||
# - drone_tag
|
||||
# - drone_commit_sha
|
||||
# port: 22
|
||||
# command_timeout: 10m
|
||||
# script:
|
||||
# - export TAG=$DRONE_TAG
|
||||
# - export NAME=$(echo $DRONE_TAG | tr -d '.')
|
||||
# - export COMMIT=$DRONE_COMMIT_SHA
|
||||
# - envsubst < /home/debian/manifest.yml | sudo kubectl apply -f -
|
||||
#
|
||||
# - name: create_e2e_vm
|
||||
# image: gitea.gilmour109.de/gilmour109/e2e-tools:latest
|
||||
# environment:
|
||||
# TF_VAR_run_id: ${DRONE_BUILD_NUMBER}
|
||||
# TF_VAR_proxmox_password:
|
||||
# from_secret: proxmox_password
|
||||
# TF_VAR_clone_vm_password:
|
||||
# from_secret: e2e_vm_password
|
||||
# TOFU_GARAGE_ACCESS_KEY:
|
||||
# from_secret: tofu_garage_access_key
|
||||
# TOFU_GARAGE_SECRET_KEY:
|
||||
# from_secret: tofu_garage_secret_key
|
||||
# commands:
|
||||
# - cd tofu/e2e
|
||||
# - tofu init
|
||||
# - tofu apply -auto-approve
|
||||
#
|
||||
# - name: run_e2e_tests
|
||||
# image: gitea.gilmour109.de/gilmour109/e2e-tools:latest
|
||||
# environment:
|
||||
# E2E_VM_PASSWORD:
|
||||
# from_secret: e2e_vm_password
|
||||
# commands:
|
||||
# - export VM_IP=192.168.178.$((211 + DRONE_BUILD_NUMBER % 44))
|
||||
# - export TAG_NAME=$(echo $DRONE_TAG | tr -d '.')
|
||||
# - export API_URL="http://$${TAG_NAME}.192.168.178.201.nip.io"
|
||||
# - timeout 120 bash -c "until sshpass -p '$E2E_VM_PASSWORD' ssh debian@$VM_IP 'echo ok' 2>/dev/null; do sleep 5; done"
|
||||
# - sshpass -p "$E2E_VM_PASSWORD" scp scripts/e2e-test.sh debian@$VM_IP:/tmp/e2e-test.sh
|
||||
# - sshpass -p "$E2E_VM_PASSWORD" ssh debian@$VM_IP "chmod +x /tmp/e2e-test.sh"
|
||||
# - sshpass -p "$E2E_VM_PASSWORD" ssh debian@$VM_IP "REPO_URL=https://gitea.gilmour109.de/gilmour109/calchat.git COMMIT_SHA=$DRONE_COMMIT_SHA API_URL=$API_URL bash /tmp/e2e-test.sh"
|
||||
# - sshpass -p "$E2E_VM_PASSWORD" scp debian@$VM_IP:/tmp/e2e-results.txt /tmp/e2e-results.txt
|
||||
#
|
||||
# - name: notify_failure
|
||||
# image: drillster/drone-email
|
||||
# settings:
|
||||
# host:
|
||||
# from_secret: smtp_host
|
||||
# username:
|
||||
# from_secret: smtp_username
|
||||
# password:
|
||||
# from_secret: smtp_password
|
||||
# from: drone@gilmour109.de
|
||||
# recipients:
|
||||
# - liwa7755@bht-berlin.de
|
||||
# subject: "E2E Tests failed: ${DRONE_REPO} ${DRONE_TAG} #${DRONE_BUILD_NUMBER}"
|
||||
# body: |
|
||||
# E2E tests failed for tag ${DRONE_TAG} (commit ${DRONE_COMMIT_SHA:0:8}).
|
||||
# Build: ${DRONE_BUILD_LINK}
|
||||
# when:
|
||||
# status:
|
||||
# - failure
|
||||
#
|
||||
# - name: destroy_e2e_vm
|
||||
# image: gitea.gilmour109.de/gilmour109/e2e-tools:latest
|
||||
# environment:
|
||||
# TF_VAR_run_id: ${DRONE_BUILD_NUMBER}
|
||||
# TF_VAR_proxmox_password:
|
||||
# from_secret: proxmox_password
|
||||
# TF_VAR_clone_vm_password:
|
||||
# from_secret: e2e_vm_password
|
||||
# TOFU_GARAGE_ACCESS_KEY:
|
||||
# from_secret: tofu_garage_access_key
|
||||
# TOFU_GARAGE_SECRET_KEY:
|
||||
# from_secret: tofu_garage_secret_key
|
||||
# commands:
|
||||
# - cd tofu/e2e
|
||||
# - tofu init
|
||||
# - tofu destroy -auto-approve
|
||||
# when:
|
||||
# status:
|
||||
# - success
|
||||
# - failure
|
||||
#
|
||||
# - name: build_apk
|
||||
# image: gitea.gilmour109.de/gilmour109/eas-build:latest
|
||||
# environment:
|
||||
# EXPO_TOKEN:
|
||||
# from_secret: expo_token
|
||||
# commands:
|
||||
# - npm ci
|
||||
# - npm run build -w @calchat/shared
|
||||
# - npm run -w @calchat/client build:apk
|
||||
# when:
|
||||
# status:
|
||||
# - success
|
||||
#
|
||||
# - name: release_apk
|
||||
# image: plugins/gitea-release
|
||||
# settings:
|
||||
# api_key:
|
||||
# from_secret: gitea_token
|
||||
# base_url: https://gitea.gilmour109.de
|
||||
# files:
|
||||
# - calchat.apk
|
||||
# title: ${DRONE_TAG}
|
||||
# when:
|
||||
# status:
|
||||
# - success
|
||||
|
||||
Reference in New Issue
Block a user