Skip to content

Commit

Permalink
feat(mongo): mongo connection added (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinezanardi committed Mar 1, 2023
1 parent 39e28f6 commit f133b05
Show file tree
Hide file tree
Showing 32 changed files with 2,613 additions and 91 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Start Docker containers 🐳
run: npm run docker:test:start
- name: Install project dependencies 📦
run: npm ci
- name: Build app ✨
run: npm run build
- name: Check and lint code 🔍
run: npm run lint
- name: Test 💯
run: npm run test:cov
run: npm run test:cov
- name: Stop Docker containers 🐳
if: ${{ always() }}
run: npm run docker:test:stop
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,13 @@ tests/**/coverage
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/extensions.json

# Env
env/*
!env/.env.example
!env/.env.development
!env/.env.test

# Stryker
.stryker-tmp
2 changes: 1 addition & 1 deletion .validate-branch-namerc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"pattern": "^(main|develop){1}$|^(feat|fix)\/.+$",
"pattern": "^(feat|fix)\/.+$",
"errorMsg": "Your branch name doesn't respect the established convention. Please respect the following format : (feat|fix)/[FEATURE_NAME]\nYou can change the name of your branch with the command `git branch -m NEW_NAME`"
}
2 changes: 1 addition & 1 deletion config/eslint/rules/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const importRules = Object.freeze({
"import/no-named-as-default": ERROR,
"import/no-named-as-default-member": ERROR,
"import/no-deprecated": ERROR,
"import/no-extraneous-dependencies": ERROR,
"import/no-extraneous-dependencies": [ERROR, { peerDependencies: false }],
"import/no-mutable-exports": ERROR,
"import/no-unused-modules": [ERROR, { unusedExports: true }],
// - Module systems (https://github.com/import-js/eslint-plugin-import#module-systems)
Expand Down
1 change: 1 addition & 0 deletions config/eslint/rules/overrides/test-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const testFilesOverride = Object.freeze({
plugins: ["jest"],
extends: ["plugin:jest/recommended"],
rules: {
"max-lines-per-function": OFF,
"@typescript-eslint/init-declarations": OFF,
"@typescript-eslint/no-magic-numbers": OFF,
"import/no-namespace": OFF,
Expand Down
9 changes: 7 additions & 2 deletions config/jest/jest-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ const config: Config = {
testRegex: "tests/e2e/.+.e2e-spec.ts",
transform: { "^.+\\.(t|j)s$": "ts-jest" },
verbose: true,
resetMocks: true,
restoreMocks: true,
clearMocks: true,
coverageReporters: ["clover", "json", "lcov", "text", "text-summary"],
collectCoverageFrom: ["src/**/*.ts"],
coveragePathIgnorePatterns: ["main.ts$", ".service.ts$"],
collectCoverageFrom: [
"src/**/*.controller.ts",
"src/**/*.module.ts",
],
coverageDirectory: "tests/e2e/coverage",
coverageThreshold: {
global: {
Expand Down
10 changes: 8 additions & 2 deletions config/jest/jest-global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ const config: Config = {
testRegex: ["tests/unit/.+.spec.ts", "tests/e2e/.+.e2e-spec.ts"],
transform: { "^.+\\.(t|j)s$": "ts-jest" },
verbose: true,
resetMocks: true,
restoreMocks: true,
clearMocks: true,
setupFiles: ["<rootDir>/tests/global-setup.ts"],
coverageReporters: ["clover", "json", "lcov", "text", "text-summary"],
collectCoverageFrom: ["src/**/*.ts"],
coveragePathIgnorePatterns: ["main.ts$"],
collectCoverageFrom: [
"src/**/*.ts",
"!src/main.ts",
],
coverageDirectory: "tests/coverage",
coverageThreshold: {
global: {
Expand Down
13 changes: 11 additions & 2 deletions config/jest/jest-unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@ const config: Config = {
testRegex: "tests/unit/.+.spec.ts",
transform: { "^.+\\.(t|j)s$": "ts-jest" },
verbose: true,
resetMocks: true,
restoreMocks: true,
clearMocks: true,
detectLeaks: true,
setupFiles: ["<rootDir>/tests/unit/unit-setup.ts"],
coverageReporters: ["clover", "json", "lcov", "text", "text-summary"],
collectCoverageFrom: ["src/**/*.ts"],
coveragePathIgnorePatterns: ["main.ts$", ".module.ts$", ".controller.ts$"],
collectCoverageFrom: [
"src/**/*.ts",
"!src/main.ts",
"!src/**/*.module.ts",
"!src/**/*.controller.ts",
],
coverageDirectory: "tests/unit/coverage",
coverageThreshold: {
global: {
Expand Down
6 changes: 6 additions & 0 deletions config/stryker/stryker.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
"cleanTempDir": true,
"incremental": true,
"incrementalFile": "tests/stryker/incremental.json",
"checkers": ["typescript"],
"tsconfigFile": "tsconfig.json",
"testRunner": "jest",
"jest": {
"configFile": "config/jest/jest-global.ts"
},
"reporters": [
"clear-text", "progress", "html", "json"
],
Expand Down
15 changes: 15 additions & 0 deletions docker/werewolves-assistant-dev/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "3.8"
services:
mongo:
container_name: "mongo-dev"
image: mongo:latest
environment:
MONGO_INITDB_ROOT_USERNAME: dev
MONGO_INITDB_ROOT_PASSWORD: speed_burger_is_the_best
ports:
- "27019:27017"
volumes:
- mongodb_data_container:/data/db

volumes:
mongodb_data_container:
16 changes: 16 additions & 0 deletions docker/werewolves-assistant-test/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3.8"
services:
mongo:
container_name: "mongo-test"
image: mongo:latest
environment:
MONGO_INITDB_ROOT_USERNAME: test
MONGO_INITDB_ROOT_PASSWORD: speed_burger_is_the_best
MONGO_INITDB_DATABASE: werewolves-assistant
ports:
- "27018:27017"
volumes:
- mongodb_data_container:/data/db

volumes:
mongodb_data_container:
6 changes: 6 additions & 0 deletions env/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ENVIRONMENT=development
DATABASE_HOST=localhost
DATABASE_PORT=27019
DATABASE_NAME=werewolves-assistant
DATABASE_USERNAME=dev
DATABASE_PASSWORD=speed_burger_is_the_best
6 changes: 6 additions & 0 deletions env/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ENVIRONMENT=development|production|test
DATABASE_HOST=locahost
DATABASE_PORT=port
DATABASE_NAME=name
DATABASE_USERNAME=username
DATABASE_PASSWORD=password
6 changes: 6 additions & 0 deletions env/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ENVIRONMENT=test
DATABASE_HOST=127.0.0.1
DATABASE_PORT=27018
DATABASE_NAME=werewolves-assistant
DATABASE_USERNAME=test
DATABASE_PASSWORD=speed_burger_is_the_best

0 comments on commit f133b05

Please sign in to comment.