Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment test #17

Merged
merged 54 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
e9fc2dc
Added User class
nwikeodigwe Dec 23, 2024
2bd513e
Added test to auth route
nwikeodigwe Dec 23, 2024
6a80f55
Refactored auth reset
nwikeodigwe Dec 23, 2024
5412c90
Refactored auth reset with token
nwikeodigwe Dec 23, 2024
3240cd6
Made changes to User.save
nwikeodigwe Dec 23, 2024
fc18653
Refactored User.save method
nwikeodigwe Dec 25, 2024
72004c0
Refactored comment endpoint for brand
nwikeodigwe Jan 11, 2025
80f5826
Refactored comment and brand delete
nwikeodigwe Jan 11, 2025
a3c0cee
Refactored user route subscribe and unsubscribe endpoint
nwikeodigwe Jan 12, 2025
37975a5
Refactored getStyles and updateProfile route with class
nwikeodigwe Jan 12, 2025
69b0382
Fixed update user error
nwikeodigwe Jan 12, 2025
1e9d0e7
Code refactor to oop
nwikeodigwe Jan 29, 2025
ee2fab0
Modified workflow to migrate deploy
nwikeodigwe Jan 29, 2025
eb4ce61
Modified workflow to migrate reset
nwikeodigwe Jan 29, 2025
8ef3472
Modified workflow to migrate dev
nwikeodigwe Jan 29, 2025
08803c6
Modified workflow added db pull and generate
nwikeodigwe Jan 29, 2025
327404b
Modified workflow migrate deploy
nwikeodigwe Jan 29, 2025
0b8613c
Added docker container and docker compose
nwikeodigwe Feb 4, 2025
d1ab2b2
Made changes to workflow
nwikeodigwe Feb 4, 2025
b60c31d
Made changes to workflow
nwikeodigwe Feb 4, 2025
8d1931e
Update main.yml
nwikeodigwe Feb 4, 2025
c82bb97
Made changes to migration
nwikeodigwe Feb 4, 2025
b50766c
Made changes to migration
nwikeodigwe Feb 4, 2025
bad71a4
Update migration.sql
nwikeodigwe Feb 4, 2025
e086cee
Update migration.sql
nwikeodigwe Feb 4, 2025
39e9391
Update main.yml
nwikeodigwe Feb 4, 2025
04d5939
Merge branch 'add-docker' of https://github.com/nwikeodigwe/relayapp …
nwikeodigwe Feb 5, 2025
a37a0e3
Rename workflow file
nwikeodigwe Feb 5, 2025
bed041e
Made changes to docker-compose and entrypoint.sh
nwikeodigwe Feb 5, 2025
22edff0
Added logging using winston and morgan
nwikeodigwe Feb 5, 2025
019fbce
Renamed workflow
nwikeodigwe Feb 5, 2025
55212c2
Added http-status and jest mock
nwikeodigwe Feb 7, 2025
ca2388c
Updated workflow
nwikeodigwe Feb 7, 2025
6006b98
Made changes to migration
nwikeodigwe Feb 7, 2025
0bc2e9c
made changes to migration
nwikeodigwe Feb 7, 2025
b213c80
Made changes to logger configuration
nwikeodigwe Feb 7, 2025
99c0c58
Added jest mocks for api various endponts
nwikeodigwe Feb 12, 2025
a630346
Added prisma and contants file
nwikeodigwe Feb 12, 2025
f3d1b0c
Updated test database uri
nwikeodigwe Feb 12, 2025
f42cada
Added caching for node modules
nwikeodigwe Feb 12, 2025
296be2e
Fixed npm ci to npm install in ci
nwikeodigwe Feb 12, 2025
0600830
Added prisma switch provider
nwikeodigwe Feb 12, 2025
c78e0f3
Added mysql service to ci workflow
nwikeodigwe Feb 12, 2025
e184c99
Added jwt refresh secret as env variable
nwikeodigwe Feb 12, 2025
46fbd8b
Refactored save method in classes
nwikeodigwe Feb 12, 2025
72a31dc
Rectored style.save method
nwikeodigwe Feb 13, 2025
a165c8b
Made changes to save method
nwikeodigwe Feb 21, 2025
389c50f
Added ondelete cascade to brand
nwikeodigwe Feb 22, 2025
8b44b9e
Added test for User class
nwikeodigwe Feb 23, 2025
fbc357d
Added test for Brand
nwikeodigwe Feb 23, 2025
1f388ed
Added test for Collection
nwikeodigwe Feb 23, 2025
3cb2bbf
Added test for collection
nwikeodigwe Feb 25, 2025
67de631
Should call create method when creating a comment
nwikeodigwe Feb 25, 2025
eead091
test for save and update
nwikeodigwe Feb 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
79 changes: 42 additions & 37 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
name: Relay app CI pipeline
name: CI pipeline

on:
push:
branches:
- main
pull_request:
branches:
- main
- main
workflow_dispatch:

jobs:

build-and-test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20, 21]
node-version: [20, 21]

services:
mysql:
image: mysql:latest
Expand All @@ -32,41 +31,47 @@ jobs:
--health-retries=3

env:
CI: true

steps:
- name: Checkout code
uses: actions/checkout@v3
CI: true

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Wait for MySQL to be ready
run: |
until mysqladmin ping -h 127.0.0.1 -u${{ secrets.MYSQL_USER }} -p${{ secrets.MYSQL_PASSWORD }} --silent; do
echo "Waiting for database to connect..."
sleep 2
done
- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Create test database
run: |
mysql -h 127.0.0.1 -u${{ secrets.MYSQL_USER }} -p${{ secrets.MYSQL_PASSWORD }} -e "CREATE DATABASE IF NOT EXISTS ${{ secrets.MYSQL_DB }};"
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies and run tests
env:
NODE_ENV: test
DATABASE_URL: "mysql://${{ secrets.MYSQL_USER }}:${{ secrets.MYSQL_PASSWORD }}@localhost:${{ secrets.MYSQL_PORT }}/${{ secrets.MYSQL_DB }}"
FACEBOOK_CLIENT_SECRET: ${{ secrets.FACEBOOK_CLIENT_SECRET }}
FACEBOOK_CLIENT_ID: ${{ secrets.FACEBOOK_CLIENT_ID }}
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
run: |
cd backend
npm install
npx prisma migrate dev
npx jest --verbose --runInBand

- name: Wait for MySQL to be ready
run: |
until mysqladmin ping -h 127.0.0.1 -u${{ secrets.MYSQL_USER }} -p${{ secrets.MYSQL_PASSWORD }} --silent; do
echo "Waiting for database to connect..."
sleep 2
done

- name: Create test database
run: |
mysql -h 127.0.0.1 -u${{ secrets.MYSQL_USER }} -p${{ secrets.MYSQL_PASSWORD }} -e "CREATE DATABASE IF NOT EXISTS ${{ secrets.MYSQL_DB }};"

- name: Install dependencies and run tests
env:
NODE_ENV: test
DATABASE_URI: "mysql://${{ secrets.MYSQL_USER }}:${{ secrets.MYSQL_PASSWORD }}@localhost:${{ secrets.MYSQL_PORT }}/${{ secrets.MYSQL_DB }}"
FACEBOOK_CLIENT_SECRET: ${{ secrets.FACEBOOK_CLIENT_SECRET }}
FACEBOOK_CLIENT_ID: ${{ secrets.FACEBOOK_CLIENT_ID }}
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
JWT_REFRESH_SECRET: ${{ secrets.JWT_REFRESH_SECRET }}
run: |
cd app
npm install
npx prisma migrate dev
npx jest --verbose --runInBand
16 changes: 11 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
/backend/node_modules
/backend/dist
/backend/coverage
/app/node_modules
/app/dist
/app/coverage

/app/*.env*
/app/*.log
/app/logs

/.vscode

/mysql

/backend/*.env*
/backend/*.log
9 changes: 9 additions & 0 deletions app/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules/
coverage/

package-lock.json

*.log
*.env*

.gitignore
File renamed without changes.
19 changes: 19 additions & 0 deletions app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:21-alpine

WORKDIR /app

RUN apk add --no-cache openssl libssl3
ENV OPENSSL_DIR=/usr/lib/ssl

COPY package*.json ./

RUN npm install
COPY . .
RUN npm install -g nodemon

RUN adduser -D -u 1010 theia && chown -R theia /app
USER theia

RUN chmod +x entrypoint.sh

EXPOSE 3000
File renamed without changes.
26 changes: 26 additions & 0 deletions app/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
MAX_RETRIES=10
RETRY_DELAY=2
RETRY_COUNT=0

echo "Applying database schema..."
if ! npx prisma db push; then
echo "Database schema push failed! Exiting."
exit 1
fi

echo "Running migrations..."
RETRY_COUNT=0

until echo "yes" | npx prisma migrate dev; do
echo "Migration failed. Retrying in $RETRY_DELAY seconds..."
RETRY_COUNT=$((RETRY_COUNT + 1))
if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then
echo "Migration failed after $MAX_RETRIES attempts. Exiting."
exit 1
fi
sleep $RETRY_DELAY
done

echo "Migrations complete! Starting app..."
exec npm start
4 changes: 4 additions & 0 deletions backend/jest.config.js → app/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
cache: true,
clearMocks: true,
resetModules: true,
restoreMocks: true,
preset: "ts-jest",
testEnvironment: "node",
transform: {
Expand Down
Loading
Loading