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
23 changes: 19 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI
name: CI Test

on:
push:
Expand All @@ -10,13 +10,22 @@ on:
branches: [main]

jobs:
build:
ci-test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
workspace: ['test:unit', 'test:e2e']

services:
mysql:
image: mysql:8.0.23
ports:
- 3307:3306
env:
MYSQL_DATABASE: e_commerce_test
MYSQL_ROOT_PASSWORD: root

steps:
- uses: actions/checkout@v4
Expand All @@ -27,4 +36,10 @@ jobs:
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
- name: init database
run: |
sudo /etc/init.d/mysql start
mysql -h 127.0.0.1 -P 3307 -uroot -proot -e "CREATE DATABASE IF NOT EXISTS e_commerce_test;"
mysql -h 127.0.0.1 -P 3307 -uroot -proot e_commerce_test < ./docker/mysql/init-backend.sql
- name: npm run ${{ matrix.workspace }}
run: npm run ${{ matrix.workspace }}
2 changes: 1 addition & 1 deletion docker-compose.development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
command: --init-file /init-backend.sql
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=e-commerce_local
- MYSQL_DATABASE=e_commerce_local
- MYSQL_USER=anniemon
- MYSQL_PASSWORD=anniemon
- MYSQL_TCP_PORT=3307
Expand Down
6 changes: 3 additions & 3 deletions docker/mysql/init-backend.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CREATE DATABASE IF NOT EXISTS `e-commerce_local` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
DROP DATABASE IF EXISTS `e-commerce_test`;
CREATE DATABASE IF NOT EXISTS `e-commerce_test` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE DATABASE IF NOT EXISTS `e_commerce_local` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
DROP DATABASE IF EXISTS `e_commerce_test`;
CREATE DATABASE IF NOT EXISTS `e_commerce_test` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER IF NOT EXISTS 'root'@'%' IDENTIFIED BY 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
CREATE USER IF NOT EXISTS 'anniemon'@'%' IDENTIFIED BY 'anniemon';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest --config ./jest.json --verbose --runInBand",
"test:unit": "jest --config ./jest.json --verbose --runInBand --testRegex ./test/unit/.*\\.spec\\.ts$",
"test:e2e": "jest --config ./jest.json --verbose --runInBand --testRegex ./test/e2e/.*\\.spec\\.ts$",
"test:e2e": "MYSQL_DATABASE=e_commerce_test jest --config ./jest.json --verbose --runInBand --testRegex ./test/e2e/.*\\.spec\\.ts$ --forceExit",
"test:watch": "jest --watch --forceExit",
"test:coverage": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
Expand Down
5 changes: 4 additions & 1 deletion src/application/modules/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ const modulesList = Object.keys(modules).map(
);

@Module({
imports: [...modulesList, TypeOrmModule.forRoot(dataSource.options)],
imports: [
...modulesList,
TypeOrmModule.forRoot({ ...dataSource.options, autoLoadEntities: true }),
],
providers: [
AppService,
{
Expand Down
4 changes: 2 additions & 2 deletions src/infrastructure/typeorm/data-source/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DataSource, DataSourceOptions } from 'typeorm';

const { MYSQL_DATABASE } = process.env;
// TODO: 환경별 설정 분리
export const dataSourceOptions: DataSourceOptions = {
type: 'mysql',
Expand All @@ -8,8 +9,7 @@ export const dataSourceOptions: DataSourceOptions = {
bigNumberStrings: false,
username: 'root',
password: 'root',
database: `e-commerce_local`,
migrationsRun: true,
database: MYSQL_DATABASE ?? 'e_commerce_local',
entities: [__dirname + '/../entities/*.entity{.ts,.js}'],
migrations: [__dirname + '/../migrations/*{.ts,.js}'],
synchronize: true,
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ describe('AppController (e2e)', () => {
await app.init();
});

// TODO: 로컬 테스트 환경 설정 후 활성화
it.skip('/ (GET)', () => {
it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
Expand Down
251 changes: 0 additions & 251 deletions test/order-facade.spec.ts

This file was deleted.

Loading
Loading