Skip to content

Commit

Permalink
add mssql actions
Browse files Browse the repository at this point in the history
  • Loading branch information
momentiris committed Nov 20, 2024
1 parent fc6b733 commit 0785fc4
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .env.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LEASING_DATABASE__PASSWORD=Passw0rd!
LEASING_DATABASE__HOST=localhost
LEASING_DATABASE__USER=sa
LEASING_DATABASE__PORT=1433
LEASING_DATABASE__DATABASE=tenants-leases-test
11 changes: 11 additions & 0 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ on:
workflow_call:
jobs:
test:
services:
sql:
image: mcr.microsoft.com/mssql/server:2019-latest
env:
SA_PASSWORD: Passw0rd!
ACCEPT_EULA: Y
ports:
- "1433:1433"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -15,6 +23,9 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Create db
run: |
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Passw0rd! -Q "CREATE DATABASE [tenants-leases-test]"
- name: Install dependencies
run: npm ci
- name: Run tests
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ config.json
# Jetbrains IDE
.idea/

.vscode/
.vscode/
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ module.exports = {
].concat(
process.env.NODE_ENV === 'test-ci'
? [
'<rootDir>/src/services/lease-service/tests/adapters/',
'<rootDir>/src/services/lease-service/tests/sync-internal-parking-space-listings-from-xpand.test.ts',
'<rootDir>/src/services/lease-service/tests/offer-service.test.ts',
// '<rootDir>/src/services/lease-service/tests/adapters/',
// '<rootDir>/src/services/lease-service/tests/sync-internal-parking-space-listings-from-xpand.test.ts',
// '<rootDir>/src/services/lease-service/tests/offer-service.test.ts',
]
: []
),
Expand Down
1 change: 1 addition & 0 deletions knexfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Update with your config settings.

require('dotenv').config()

/**
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
"node": "20.*"
},
"scripts": {
"test": "jest",
"test:watch": "jest --watch",
"test": "DOTENV_CONFIG_PATH=.env.test node -r dotenv/config node_modules/jest/bin/jest --config jest.config.js",
"test:watch": "DOTENV_CONFIG_PATH=.env.test jest --watch",
"build": "tsc",
"start": "npm run migrate:up && node index",
"dev": "npm run migrate:up && nodemon -e ts,js --exec ts-node src/index ",
"start": "npm run migrate:up && node -r dotenv/config index",
"dev": "DOTENV_CONFIG_PATH=.env npm run migrate:up && nodemon -e ts,js --exec ts-node -r dotenv/config src/index ",
"lint": "eslint src/",
"migrate:make": "knex migrate:make",
"migrate:up": "knex migrate:latest --env dev",
"migrate:down": "knex migrate:down --env dev",
"seed": "knex seed:run --env dev",
"script:expire-listings": "node scripts/expire-listings.js",
"ts:watch": "tsc --watch --noEmit",
"test:ci": "NODE_ENV=test-ci jest --silent",
"test:ci": "DOTENV_CONFIG_PATH=.env.ci node -r dotenv/config node_modules/jest/bin/jest --config jest.config.js application",
"ts:ci": "tsc --noEmit"
},
"author": "",
Expand Down
8 changes: 0 additions & 8 deletions src/common/config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import configPackage from '@iteam/config'
import dotenv from 'dotenv'
import path from 'path'

if (process.env.NODE_ENV == 'test') {
dotenv.config({ path: path.join(__dirname, '../../.env.test') })
} else {
dotenv.config()
}

export interface Config {
port: number
Expand Down
2 changes: 1 addition & 1 deletion src/services/lease-service/adapters/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const getTestConfig = () => {

const getConfigBasedOnEnvironment = () => {
const environment = process.env.NODE_ENV || 'dev'
return environment === 'test' ? getTestConfig() : getStandardConfig()
return environment.includes('test') ? getTestConfig() : getStandardConfig()
}

export const createDbClient = () => {
Expand Down

0 comments on commit 0785fc4

Please sign in to comment.