Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
8fb3b86
Added better dockerignore files to spool up docker containers more ef…
AlexanderORuban Nov 18, 2025
e85002f
Fixed the next config file to use env.local base api url instead of t…
AlexanderORuban Nov 18, 2025
fa5bf75
Fixed end to end tests as it didn't reach the delete buttons at runti…
AlexanderORuban Nov 18, 2025
09d94da
Created the test.yml file for the automated testing pipeline.
AlexanderORuban Nov 19, 2025
f557210
Finished the test.yml file with detailed comments for each test job.
AlexanderORuban Nov 19, 2025
9b6be7a
Updated the readme with a new section for this automated testing pipe…
AlexanderORuban Nov 19, 2025
cea5d57
Merge pull request #3 from AlexanderORuban:feature/automated-testing-…
AlexanderORuban Nov 19, 2025
05c9135
Fixed the broken tests by getting rid of docker ignore flag for all c…
AlexanderORuban Nov 19, 2025
c29212c
Fixed dockerignore so docker-compose.test.yml is included in the work…
AlexanderORuban Nov 19, 2025
c724dbf
Added debug to check if the docker-compose.test.yml exists when runni…
AlexanderORuban Nov 20, 2025
7e9e7c3
Added default working directory to be root.
AlexanderORuban Nov 20, 2025
60da3f1
Fixed the working directory path.
AlexanderORuban Nov 20, 2025
549826d
Added more debugging.
AlexanderORuban Nov 20, 2025
6560535
Fixed indentation and adding more debugging for frontend.
AlexanderORuban Nov 20, 2025
7f3de28
Removed line breaks in docker commands.
AlexanderORuban Nov 20, 2025
7dd0866
Added basic testing env variables for e2e tests.
AlexanderORuban Nov 20, 2025
e2e03d5
Fixed the .env issues in the test file for e2e tests.
AlexanderORuban Nov 20, 2025
ffed0bc
Got rid of unused endpoints in e2e tests.
AlexanderORuban Nov 20, 2025
b953cf1
Fixed e2e test start command.
AlexanderORuban Nov 20, 2025
87e80f2
Added install command for cypress in test file.
AlexanderORuban Nov 20, 2025
bfec704
Fixed issue with backend and database not connecting with docker caus…
AlexanderORuban Nov 20, 2025
2eee9c8
Added an example.env.local for the env.local in the frontend
AlexanderORuban Nov 20, 2025
05bca61
Merge pull request #4 from AlexanderORuban/feature/fix-tests-ci
AlexanderORuban Nov 20, 2025
c3ad931
Created feature branch and deploy.yml for the automated deployment wo…
AlexanderORuban Nov 20, 2025
ce3e918
started working on deploy.yml
f3liz Nov 22, 2025
9f5b7b9
added workflow to trigger on pushes to main
f3liz Nov 22, 2025
dffa3ef
some setup for deploy.yml
f3liz Nov 22, 2025
8ca8d44
working on scripts to run deployment to vm
f3liz Nov 24, 2025
3d9e69c
deploy.yml written, need to test that it works
f3liz Nov 24, 2025
0d787b9
fixed a typo in the script
f3liz Nov 24, 2025
54f8e30
adjusted script
f3liz Nov 24, 2025
d23d4db
Updated the docker-compose.deploy.yml script to build locally on GitH…
AlexanderORuban Nov 24, 2025
1eef055
Fixed the errors in deploy.yml and added another env production file …
AlexanderORuban Nov 24, 2025
476a9e5
Updated the deploy.yml workflow to use the docker-compose.deploy.yml …
AlexanderORuban Nov 25, 2025
b7b55cf
Testing VM deployment with workflow.
AlexanderORuban Nov 25, 2025
6ca3fd3
Merge pull request #5 from AlexanderORuban/feature/automated-deployment
AlexanderORuban Nov 25, 2025
dc234f3
Fixed indentation in deploy.yml file.
AlexanderORuban Nov 25, 2025
06a4633
Merge pull request #6 from AlexanderORuban/feature/automated-deployment
AlexanderORuban Nov 25, 2025
3276f43
Fixed more indentation in the deployment script.
AlexanderORuban Nov 25, 2025
c7c419b
Merge pull request #7 from AlexanderORuban/feature/automated-deployment
AlexanderORuban Nov 25, 2025
e4d2797
Fixed indentation again.
AlexanderORuban Nov 25, 2025
68cbf7c
Merge pull request #8 from AlexanderORuban/feature/automated-deployment
AlexanderORuban Nov 25, 2025
4508902
Testing after updating missing secret.
AlexanderORuban Nov 25, 2025
e5cb20a
Merge pull request #9 from AlexanderORuban/feature/automated-deployment
AlexanderORuban Nov 25, 2025
dea4b84
Added health route to backend for testing.
AlexanderORuban Nov 25, 2025
ba65917
Merge pull request #10 from AlexanderORuban/feature/automated-deployment
AlexanderORuban Nov 25, 2025
550ffe3
Fixed health check.
AlexanderORuban Nov 25, 2025
0458d72
Edited deploy.yml to ensure github secrets are injected with ssh.
AlexanderORuban Nov 25, 2025
6dae78b
Merge pull request #11 from AlexanderORuban/feature/automated-deployment
AlexanderORuban Nov 25, 2025
473a3d9
Fixed app.js to use the correct path for the .env file.
AlexanderORuban Nov 25, 2025
4216f1d
Merge pull request #12 from AlexanderORuban/feature/automated-deployment
AlexanderORuban Nov 25, 2025
81f9882
Testing deployment again.
AlexanderORuban Nov 25, 2025
09b3040
Merge pull request #13 from AlexanderORuban/feature/automated-deployment
AlexanderORuban Nov 25, 2025
7c1a80b
Fixed the broken docker-compose.deploy.yml file to include the correc…
AlexanderORuban Nov 25, 2025
757261b
Merge pull request #14 from AlexanderORuban/feature/automated-deployment
AlexanderORuban Nov 25, 2025
f896ec1
Updated readme to include information for the new automated deploymen…
AlexanderORuban Nov 25, 2025
d5c54a8
Merge pull request #15 from AlexanderORuban/feature/automated-deployment
AlexanderORuban Nov 25, 2025
d58ac43
Merge pull request #16 from AlexanderORuban/development
AlexanderORuban Nov 25, 2025
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
87 changes: 87 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Automated Deployment

on:
pull_request:
types: [closed]
branches: [ main ]

jobs:
deploy:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Deploy to VM (Digital Ocean)
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.VM_HOST }}
username: ${{ secrets.VM_USERNAME }}
password: ${{ secrets.VM_PASSWORD }}

envs: DB_HOST,DB_USER,DB_PASSWORD,DB_DATABASE,DB_PORT,NEXT_PUBLIC_API_URL

script: |
echo "*** Updating + Upgrading VM ***"
sudo apt-get update -y
yes | sudo DEBIAN_FRONTEND=noninteractive apt-get -yqq upgrade

echo "*** Installing Docker Dependencies ***"
sudo apt install -y ca-certificates curl gnupg lsb-release

echo "*** Add Docker GPG Key and repo ***"
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

echo "*** Install Docker engine and compose plugin ***"
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

echo "*** Removing old deployment folder ***"
rm -rf ~/pixel-to-pattern

echo "*** Cloning latest repo ***"
git clone https://github.com/${{ github.repository }}.git ~/pixel-to-pattern

echo "*** Moving into project directory ***"
cd ~/pixel-to-pattern

echo "*** Writing backend .env ***"
cat << EENV > .env
DB_HOST=${DB_HOST}
DB_USER=${DB_USER}
DB_PASSWORD=${DB_PASSWORD}
DB_DATABASE=${DB_DATABASE}
DB_PORT=${DB_PORT}
SERVER_PORT=3000
EENV

echo "*** Writing frontend client/.env.production ***"
mkdir -p client
cd client
cat << FRONTENV > .env.production
NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
FRONTENV
cd ..

echo "*** Cleaning old docker images ***"
docker image prune -f

echo "*** Building + Deploying containers using repo's compose file ***"
docker compose -f docker-compose.deploy.yml up -d --build

echo "*** Verifying Deployment ***"
sleep 5
curl -I http://localhost:3000/health || exit 1

echo "*** Deployment complete. Running containers: ***"
docker ps
env:
DB_HOST: ${{ secrets.DB_HOST }}
DB_USER: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_DATABASE: ${{ secrets.DB_DATABASE }}
DB_PORT: ${{ secrets.DB_PORT }}
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
152 changes: 152 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: Automated Testing Pipeline

defaults:
run:
working-directory: .

# Workflow triggers only on pull requests and pushes to main or development branches
on:
push:
branches: [ main, development ]
pull_request:
branches: [ main, development ]

jobs:
backend-tests:
runs-on: ubuntu-latest
env:
# Test environment variables for backend tests
DB_HOST: db-test
DB_USER: testuser
DB_PASSWORD: testpass
DB_DATABASE: test_db
NODE_ENV: test

steps:
- uses: actions/checkout@v3

# Debug: Validate that docker-compose.test.yml exists and loads correctly
- name: Validate compose file
run: |
echo "Listing files..."
ls -al .
echo "Validating docker-compose.test.yml..."
docker compose -f docker-compose.test.yml config

# Build the backend test containers
- name: Build test containers
run: docker compose -f docker-compose.test.yml build

# Debug working directory
- name: Print working directory
run: pwd

- name: List files in working directory
run: ls -al

# Run backend units tests via Jest
- name: Run backend unit tests
run: docker compose -f docker-compose.test.yml up backend-unit-tests --abort-on-container-exit --exit-code-from backend-unit-tests

# Run backend integration tests for DB + API with Supertest
- name: Run backend integration tests (DB + API)
run: docker compose -f docker-compose.test.yml up db-test backend-integration --abort-on-container-exit --exit-code-from backend-integration

# Always clean up the test containers even if the tests fail
- name: Cleanup test containers
if: always()
run: docker compose -f docker-compose.test.yml down -v || true


frontend-tests:
runs-on: ubuntu-latest
env:
# Test environment variables for frontend tests
NODE_ENV: test
CI: "true"

steps:
- uses: actions/checkout@v3

# Debug: Validate that docker-compose.test.yml exists and loads correctly
- name: Validate compose file
run: |
echo "Listing files..."
ls -al .
echo "Validating docker-compose.test.yml..."
docker compose -f docker-compose.test.yml config

# Build the frontend test containers from docker-compose.test.yml
- name: Build test containers
run: docker compose -f docker-compose.test.yml build

# Debug working directory
- name: Print working directory
run: pwd

- name: List files in working directory
run: ls -al

# Run the frontend unit tests with Jest and the React Testing Library
- name: Run frontend unit tests
run: docker compose -f docker-compose.test.yml up frontend-tests --abort-on-container-exit --exit-code-from frontend-tests

# Always clean up the test containers even if the tests fail
- name: Cleanup
if: always()
run: docker compose -f docker-compose.test.yml down -v || true


e2e-tests:
runs-on: ubuntu-latest
needs: [backend-tests, frontend-tests] # Only runs the E2E tests if unit and integration tests pass
env:
# Test environment variables for E2E
DB_HOST: db-test
DB_USER: testuser
DB_PASSWORD: testpass
DB_DATABASE: test_db
NODE_ENV: test
NEXT_PUBLIC_API_BASE_URL: http://backend:3000 # required for Next.js rewrites

steps:
- uses: actions/checkout@v3

# Create CI .env file so docker-compose.yml does not fail (required by env_file: .env)
- name: Create CI .env file
run: |
echo "DB_HOST=db" >> .env
echo "DB_USER=testuser" >> .env
echo "DB_PASSWORD=testpass" >> .env
echo "DB_DATABASE=test_db" >> .env
echo "NODE_ENV=test" >> .env
echo "NEXT_PUBLIC_API_BASE_URL=http://backend:3000" >> .env # <-- REQUIRED

# Install dependencies so Cypress exists on the GitHub runner
- name: Install dependencies
run: npm install

# Build the containers and start the full application from docker-compose.yml
- name: Build full stack
run: docker compose up -d --build

# Wait until the backend API server is ready (no /health route needed)
- name: Wait for backend API server to be ready
run: |
echo "Waiting for backend..."
timeout 60 bash -c 'until curl -s http://localhost:3000/ > /dev/null; do sleep 2; done'

# Wait until the frontend is ready (no /health route needed)
- name: Wait for frontend
run: |
echo "Waiting for frontend..."
timeout 60 bash -c 'until curl -s http://localhost:3001/ > /dev/null; do sleep 2; done'

# Run the end-to-end tests using Cypress and full application
- name: Run Cypress E2E tests
run: npm run cypress:run

# Clean up the test containers after runtime
- name: Shutdown app stack
if: always()
run: docker compose down || true
Loading