Test Automation & Release process #14
Workflow file for this run
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
name: Backend - E2E test | |
on: | |
pull_request_target: | |
branches: | |
- main | |
paths: | |
- "assistant/backend/**" | |
env: | |
DOCKER_TIMEOUT: 30 | |
jobs: | |
build: | |
name: Backend E2E test | |
runs-on: ubuntu-latest | |
permissions: write-all | |
steps: | |
# Get the code | |
- name: Prep - Checkout code | |
uses: actions/checkout@v4 | |
# Create local Docker image registry | |
- name: Prep - Local Image registry | |
run: | | |
docker run -d -p 5000:5000 --restart=always --name registry registry:2 | |
# Build local Docker image | |
- name: Build - Docker image | |
working-directory: ./assistant/backend | |
run: | | |
# Build the Docker image | |
docker build --build-arg "JFROG_USER=${{ secrets.JFROG_IDENTITY_USER }}" --build-arg "JFROG_TOKEN=${{ secrets.JFROG_IDENTITY_TOKEN }}" -t ai-backend . | |
# Check the Docker image | |
- name: Build - Check Docker image | |
run: docker images ai-backend | |
# Push image to local registry | |
- name: Publish - Push image to local registry | |
run: | | |
docker tag ai-backend:latest localhost:5000/ai-backend:latest | |
docker push localhost:5000/ai-backend:latest | |
# Copy local registry configuration | |
- name: K3s - Configure local registry for k3s | |
run: | | |
mkdir -p ~/.k3s | |
cp .scripts/kubernetes/registries.yaml ~/.k3s/registries.yaml | |
# Install and configure K3s cluster | |
- name: K3s - Install and configure K3s cluster | |
run: .scripts/shell/k3s-installation.sh | |
# Verify K3s cluster | |
- name: K3s - Verify K3s cluster | |
run: | | |
kubectl get nodes | |
kubectl get ns | |
# Deploy the Docker image to the K3s cluster | |
## Ceare namespace | |
- name: Deploy - Create namespace | |
run: | | |
kubectl apply -f .scripts/kubernetes/ai-backend-namespace.yaml | |
## Create secret | |
- name: Deploy - Create secret on K3s | |
run: | | |
echo "${{ secrets.K3S_SECRET }}" > .scripts/kubernetes/ai-backend-secret.yaml | |
kubectl apply -f .scripts/kubernetes/ai-backend-secret.yaml | |
rm -f .scripts/kubernetes/ai-backend-secret.yaml | |
## Create configmap | |
- name: Deploy - Create configmap on K3s | |
run: | | |
echo "${{ secrets.K3S_CONFIGMAP }}" > .scripts/kubernetes/ai-backend-configmap.yaml | |
kubectl apply -f .scripts/kubernetes/ai-backend-configmap.yaml | |
rm -f .scripts/kubernetes/ai-backend-configmap.yaml | |
## Deploy pod and service (NodePort) | |
- name: Deploy - Create Backend and NodePort service | |
run: | | |
kubectl apply -f .scripts/kubernetes/ai-backend-deployment.yaml | |
## Check the deployment | |
- name: Deploy - Wait for deployment | |
run: .scripts/shell/deploy-wait-for-deployment.sh $DOCKER_TIMEOUT | |
# Backend health check - /api/v1/health/check | |
- name: Test - Health check | |
run: .scripts/shell/test-health-check.sh | |
# Backend resources check - /api/v1/resources | |
- name: Test - Cluster resources | |
run: .scripts/shell/test-api-v1-resources.sh |