Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
40 changes: 40 additions & 0 deletions .github/scripts/get_backend_ip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

# Exit immediately if any command fails
set -e

echo "Waiting for LoadBalancer IPs to be assigned (up to 5 minutes)..."
NOTES_IP=""
USERS_IP=""

NOTES_PORT=""
USERS_PORT=""

for i in $(seq 1 60); do
echo "Attempt $i/60 to get IPs..."
NOTES_IP=$(kubectl get service notes-service -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
NOTES_PORT=$(kubectl get service notes-service -o jsonpath='{.spec.ports[0].port}')

USERS_IP=$(kubectl get service users-service -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
USERS_PORT=$(kubectl get service users-service -o jsonpath='{.spec.ports[0].port}')

if [[ -n "$NOTES_IP" && -n "$NOTES_PORT" && -n "$USERS_IP" && -n "$USERS_PORT" ]]; then
echo "All backend LoadBalancer IPs assigned!"
echo "NOTE Service IP: $NOTES_IP:$NOTES_PORT"
echo "USER Service IP: $USERS_IP:$USERS_PORT"
break
fi
sleep 5 # Wait 5 seconds before next attempt
done

if [[ -z "$NOTES_IP" || -z "$NOTES_PORT" || -z "$USERS_IP" || -z "$USERS_PORT" ]]; then
echo "Error: One or more LoadBalancer IPs not assigned after timeout."
exit 1 # Fail the job if IPs are not obtained
fi

# These are environment variables for subsequent steps in the *same job*
# And used to set the job outputs
echo "NOTES_IP=$NOTES_IP" >> $GITHUB_ENV
echo "NOTES_PORT=$NOTES_PORT" >> $GITHUB_ENV
echo "USERS_IP=$USERS_IP" >> $GITHUB_ENV
echo "USERS_PORT=$USERS_PORT" >> $GITHUB_ENV
15 changes: 15 additions & 0 deletions .github/scripts/smoke_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

NOTES_IP=$NOTES_SERVICE_IP
NOTES_PORT=$NOTES_SERVICE_PORT

USERS_IP=$USERS_SERVICE_IP
USERS_PORT=$USERS_SERVICE_PORT

echo "Running smoke tests against staging environment"
echo "Notes Service: http://${NOTES_IP}:${NOTES_PORT}"
echo "Users Service: http://${USERS_IP}:${USERS_PORT}"

echo "Done!"
71 changes: 71 additions & 0 deletions .github/workflows/acceptance_test_cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: CD - Staging Tests on PR

on:
# Manual trigger
workflow_dispatch:

# Run the test when the new PR to develop is created
pull_request:
branches:
- develop
paths:
- 'backend/**'
- 'frontend/**'
- 'k8s/staging/**'
- 'infrastructure/staging/**'
- '.github/workflows/*staging*.yml'

env:
PYTHON_VERSION: "3.10"

jobs:
# Test Individual Services (Already triggered on feature_test workflows)

# Acceptance Tests (End-to-End)
acceptance-tests:
name: Acceptance Tests - End-to-end user flow
runs-on: ubuntu-latest

services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_USER: testuser
POSTGRES_PASSWORD: testpass
POSTGRES_DB: notesdb
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Playwright
run: |
echo "Installing Playwright..."

- name: Start Users Service
run: |
echo "Starting users service..."

- name: Start Notes Service
run: |
echo "Starting notes service..."

- name: Start Frontend
run: |
echo "Starting frontend service..."

- name: Run acceptance tests
run: |
echo "Runing acceptance tests with Playwright..."
Loading