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
147 changes: 147 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: CI

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop

jobs:
lint:
name: Lint Codebase
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20

- name: Install pnpm
run: |
corepack enable
corepack prepare pnpm@latest --activate

- name: Install dependencies
run: pnpm install

- name: Run lint
run: pnpm run lint

build:
name: Build Project
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20

- name: Install pnpm
run: |
corepack enable
corepack prepare pnpm@latest --activate

- name: Install dependencies
run: pnpm install

- name: Run build
run: pnpm run build

test:
name: Run Tests
runs-on: ubuntu-latest
needs: build
services:
test-db:
image: postgres:15-alpine
ports:
- 5433:5432
env:
NODE_ENV: test
POSTGRES_DB: dropit_test
POSTGRES_USER: ${{ secrets.TEST_POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.TEST_POSTGRES_PASSWORD }}
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20

- name: Install pnpm
run: |
corepack enable
corepack prepare pnpm@latest --activate

- name: Install dependencies
run: pnpm install

- name: Build dependencies
run: pnpm run build

- name: Run api tests
working-directory: apps/api
run: pnpm run test:e2e

dev:
name: Verify Dev Environment
runs-on: ubuntu-latest
needs: test
services:
postgres:
image: postgres:15-alpine
ports:
- 5432:5432
env:
POSTGRES_DB: dropit
POSTGRES_USER: ${{ secrets.DB_POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.DB_POSTGRES_PASSWORD }}
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20

- name: Install pnpm
run: |
corepack enable
corepack prepare pnpm@latest --activate

- name: Install dependencies
run: pnpm install

- name: Build dependencies
run: pnpm run build

- name: Run dev server
working-directory: .
run: |
pnpm run dev &
sleep 10
curl -f http://localhost:3001 || exit 1
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json --runInBand --detectOpenHandles",
"test:e2e:docker": "docker-compose -f ../../docker-compose.test.yml up -d && jest --config ./test/jest-e2e.json --runInBand --detectOpenHandles && docker-compose -f ../../docker-compose.test.yml down"
},
"dependencies": {
Expand Down
5 changes: 5 additions & 0 deletions apps/api/test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ describe('AppController (e2e)', () => {
await app.init();
});

afterAll(async () => {
// Fermer l'application NestJS
await app.close();
});

it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
Expand Down
16 changes: 9 additions & 7 deletions apps/api/test/jest-e2e.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"detectOpenHandles": true,
"forceExit": true,
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}
Loading