Skip to content

Commit

Permalink
chore: add github-action/integration test
Browse files Browse the repository at this point in the history
 - setup-test.ts의 env파일 경로를 절대경로에서 상대경로로 수정
 - github action상에서의 mysql 권한문제로'mysql' package를 'mysql2'로 재설치
  • Loading branch information
inchanS committed Apr 23, 2024
1 parent 08a4715 commit 38264b9
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
51 changes: 51 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Integration Tests

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:latest
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: test_db
MYSQL_USER: ${{ secrets.DB_USERNAME }}
MYSQL_PASSWORD: ${{ secrets.DB_PASSWORD }}
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- name: Verify MySQL connection
run: |
mysql --version
sudo apt-get install -y mysql-client
mysql --host ${{ secrets.DB_HOST }} --port 3306 -u ${{ secrets.DB_USERNAME }} -p${{ secrets.DB_PASSWORD }} -e "SHOW DATABASES;"
- name: Check out repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Create ./env/.env.test file
run: |
mkdir -p ./env
echo "TYPEORM_CONNECTION=mysql" > ./env/.env.test
echo "TYPEORM_HOST=${{ secrets.DB_HOST }}" >> ./env/.env.test
echo "TYPEORM_DATABASE=test_db" >> ./env/.env.test
echo "TYPEORM_USERNAME=${{ secrets.DB_USERNAME }}" >> ./env/.env.test
echo "TYPEORM_PASSWORD=${{ secrets.DB_PASSWORD }}" >> ./env/.env.test
echo "TYPEORM_PORT=3306" >> ./env/.env.test
echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> ./env/.env.test
- name: Install dependencies
run: npm install

- name: Build the project
run: npm run build

- name: Run integration tests
run: npm run test-integration
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"jsonwebtoken": "^9.0.0",
"morgan": "^1.10.0",
"multer": "^1.4.5-lts.1",
"mysql": "^2.18.1",
"mysql2": "^3.9.7",
"nodemailer": "^6.9.1",
"reflect-metadata": "^0.2.1",
"sharp": "^0.32.6",
Expand Down

0 comments on commit 38264b9

Please sign in to comment.