diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index cd643c1..90806ce 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -20,4 +20,8 @@ jobs: key: ${{ secrets.DEV_TEST }} port: 22 script: | - ls -al \ No newline at end of file + cd /home/ec2-user/app + git pull origin main + docker compose down + docker compose up -d --build + docker ps \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..83a1edb --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,50 @@ +name: test with create .env test + +on: [pull_request] + +jobs: + build: + name: React build & test + runs-on: ubuntu-latest + services: + postgres: + image: postgres:15 + env: + POSTGRES_USER: testuser + POSTGRES_PASSWORD: testpass + POSTGRES_DB: testdb + ports: + - 5432:5432 + options: >- + --health-cmd "pg_isready -U testuser" + --health-interval 5s + --health-timeout 5s + --health-retries 5 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Create .env + run: | + echo "Port=3000" >> .env + echo "SESSION_SECRET=your_session_secret" >> .env + echo "JWT_ACCESS_TOKEN_SECRET=your_jwt_access_token_secret" >> .env + echo "JWT_REFRESH_TOKEN_SECRET=your_jwt_refresh_token_secret" >> .env + # 테스트용 로컬 Postgres + echo "DATABASE_URL=postgres://testuser:testpass@localhost:5432/testdb" >> .env + echo "AWS_REGION=${{ secrets.AWS_REGION }}" >> .env + echo "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" >> .env + echo "AWS_S3_BUCKET=${{ secrets.AWS_S3_BUCKET }}" >> .env + + - name: Install dependencies + run: npm install + + - name: Prisma Generate + run: npx prisma generate + + - name: Prisma Migrate Dev + run: npx prisma migrate deploy + + - name: Run tests + run: npm test -- --runInBand diff --git a/.gitignore b/.gitignore index 108bb11..c7ba734 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,4 @@ node_modules /generated/prisma -coverage - dist \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bf50bb8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# 1. Node.js +FROM node:20.13.1 + +WORKDIR /app + +COPY package*.json ./ +RUN npm install + +# Prisma generate +RUN npx prisma generate + +COPY . . + +RUN mkdir -p /app/uploads + +# TypeScript 빌드 +RUN npx tsc + +EXPOSE 3000 +CMD ["npm", "start"] diff --git a/coverage/lcov-report/index.html b/coverage/lcov-report/index.html index a9fe99f..5b6e6af 100644 --- a/coverage/lcov-report/index.html +++ b/coverage/lcov-report/index.html @@ -23,30 +23,30 @@

All files

- 56.82% + 53.23% Statements - 429/755 + 395/742
- 21.48% + 17.09% Branches - 26/121 + 20/117
- 42.1% + 38.8% Functions - 56/133 + 52/134
- 61.42% + 57.12% Lines - 422/687 + 389/681
@@ -95,17 +95,17 @@

All files

src/controllers - -
+ +
- 32.24% - 89/276 - 6.38% - 3/47 - 32.35% - 11/34 - 36.86% - 87/236 + 29.43% + 83/282 + 4.16% + 2/48 + 28.57% + 10/35 + 32.53% + 81/249 @@ -170,47 +170,47 @@

All files

src/repositories - -
+ +
- 54.23% - 32/59 + 53.33% + 32/60 10% 1/10 - 33.33% - 13/39 - 55.35% - 31/56 + 32.5% + 13/40 + 54.38% + 31/57 src/routers - +
- 98.97% - 97/98 + 98.98% + 98/99 50% 1/2 100% 2/2 100% - 97/97 + 98/98 src/services - -
+ +
- 45.03% - 68/151 - 16.21% - 6/37 - 43.24% - 16/37 - 51.14% - 67/131 + 39.86% + 61/153 + 13.51% + 5/37 + 39.47% + 15/38 + 45.86% + 61/133 @@ -228,21 +228,6 @@

All files

13/21 - - tests/helpers - -
- - 95.65% - 22/23 - 80% - 4/5 - 100% - 2/2 - 95.65% - 22/23 - -
@@ -251,7 +236,7 @@

All files