feat: Add CI configuration for backend tests

This commit is contained in:
Faruk AYDIN
2023-10-08 16:13:48 +02:00
parent 1dfe58ec02
commit 12c53a3d4d
4 changed files with 61 additions and 9 deletions

View File

@@ -3,14 +3,12 @@ HOST=localhost
PROTOCOL=http
PORT=3000
LOG_LEVEL=debug
WEBHOOK_SECRET_KEY=secret
ENCRYPTION_KEY=sample_encryption_key
WEBHOOK_SECRET_KEY=sample_webhook_secret_key
APP_SECRET_KEY=sample_app_secret_key
POSTGRES_HOST=localhost
POSTGRES_DATABASE=automatisch_test
POSTGRES_PORT=5432
POSTGRES_HOST=localhost
POSTGRES_USERNAME=automatisch_test_user
POSTGRES_PASSWORD=
POSTGRES_ENABLE_SSL=false
ENCRYPTION_KEY=secret
APP_SECRET_KEY=secret
REDIS_PORT=6379
REDIS_HOST=127.0.0.1
POSTGRES_PASSWORD=automatisch_test_user_password
REDIS_HOST=localhost

View File

@@ -55,6 +55,7 @@ type AppConfig = {
paddlePublicKey: string;
licenseKey: string;
sentryDsn: string;
CI: boolean;
};
const host = process.env.HOST || 'localhost';
@@ -131,6 +132,7 @@ const appConfig: AppConfig = {
paddlePublicKey: process.env.PADDLE_PUBLIC_KEY,
licenseKey: process.env.LICENSE_KEY,
sentryDsn: process.env.SENTRY_DSN,
CI: process.env.CI === 'true',
};
if (!appConfig.encryptionKey) {

View File

@@ -2,9 +2,13 @@ import './check-env-file';
import { createDatabaseAndUser } from '../../bin/database/utils';
import { client as knex } from '../../src/config/database';
import logger from '../../src/helpers/logger';
import appConfig from '../../src/config/app';
const createAndMigrateDatabase = async () => {
await createDatabaseAndUser();
if (!appConfig.CI) {
await createDatabaseAndUser();
}
const migrator = knex.migrate;
await migrator.latest();