diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..59bd8c1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI — Lint & Test + +on: + push: + branches-ignore: [develop] + pull_request: + branches: ['**'] + +jobs: + ci: + name: Lint & Test + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run linter + run: npm run lint + + - name: Run tests + run: npm run test diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d5b4465..2406722 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: CI/CD Deploy to EC2 +name: CI/CD — Deploy to EC2 on: push: @@ -56,8 +56,6 @@ jobs: echo "POSTGRES_DB=${{ secrets.POSTGRES_DB }}" >> .env.production echo "POSTGRES_USER=${{ secrets.POSTGRES_USER }}" >> .env.production echo "POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}" >> .env.production - echo "REDIS_HOST=localhost" >> .env.production - echo "REDIS_PORT=6379" >> .env.production echo "REDIS_URL=${{ secrets.REDIS_URL }}" >> .env.production echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" >> .env.production echo "JWT_EXPIRES_IN=${{ secrets.JWT_EXPIRES_IN }}" >> .env.production diff --git a/src/app.controller.spec.ts b/src/app.controller.spec.ts index aa87cad..03956b4 100644 --- a/src/app.controller.spec.ts +++ b/src/app.controller.spec.ts @@ -17,8 +17,7 @@ describe('AppController', () => { describe('health check', () => { it('should return health check object', () => { expect(appController.getHealthCheck()).toEqual({ - status_code: 200, - detail: 'ok', + status: 'ok', result: 'working', }); }); diff --git a/src/modules/companies/__tests__/companies.controller.spec.ts b/src/modules/companies/__tests__/companies.controller.spec.ts index 35247c7..e013e3a 100644 --- a/src/modules/companies/__tests__/companies.controller.spec.ts +++ b/src/modules/companies/__tests__/companies.controller.spec.ts @@ -1,6 +1,9 @@ import { Test, TestingModule } from '@nestjs/testing'; import { CompaniesController } from '../controllers/companies.controller'; import { CompaniesService } from '../services/companies.service'; +import { CompanyMembersService } from '../services/company-members.service'; +import { CompanyRepository } from '../repositories/company.repository'; +import { DataSource } from 'typeorm'; describe('CompaniesController', () => { let controller: CompaniesController; @@ -8,7 +11,33 @@ describe('CompaniesController', () => { beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ controllers: [CompaniesController], - providers: [CompaniesService], + providers: [ + CompaniesService, + { + provide: CompanyRepository, + useValue: { + find: jest.fn(), + findOne: jest.fn(), + save: jest.fn(), + remove: jest.fn(), + findBySlugOrFail: jest.fn(), + findBySlugRaw: jest.fn(), + findPaginated: jest.fn(), + }, + }, + { + provide: CompanyMembersService, + useValue: { + createInitialOwner: jest.fn(), + }, + }, + { + provide: DataSource, + useValue: { + transaction: jest.fn(), + }, + }, + ], }).compile(); controller = module.get(CompaniesController);