Merge pull request #268 from mchangrh/pg-ci

PostgreSQL docker CI
This commit is contained in:
Ajay Ramachandran 2021-06-24 00:10:37 -04:00 committed by GitHub
commit 1570657e28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 112 additions and 4 deletions

View file

@ -1,11 +1,10 @@
name: CI
name: SQLite CI
on: [push, pull_request]
jobs:
build:
name: Run Tests
name: Run Tests with SQLite
runs-on: ubuntu-latest
steps:

28
.github/workflows/postgres-ci.yml vendored Normal file
View file

@ -0,0 +1,28 @@
name: PostgreSQL CI
on: [push, pull_request]
jobs:
build:
name: Run Tests with PostgreSQL
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Build the docker-compose stack
env:
PG_USER: ci_db_user
PG_PASS: ci_db_pass
run: docker-compose -f docker/docker-compose-ci.yml up -d
- name: Sleep
uses: jakejarvis/wait-action@master
with:
time: '10s'
- name: Check running containers
run: docker ps
- uses: actions/setup-node@v1
- run: npm install
- name: Run test suite
env:
TEST_POSTGRES: true
run: npm test

65
ci.json Normal file
View file

@ -0,0 +1,65 @@
{
"port": 8080,
"mockPort": 8081,
"globalSalt": "testSalt",
"adminUserID": "4bdfdc9cddf2c7d07a8a87b57bf6d25389fb75d1399674ee0e0938a6a60f4c3b",
"newLeafURLs": ["placeholder"],
"discordReportChannelWebhookURL": "http://127.0.0.1:8081/ReportChannelWebhook",
"discordFirstTimeSubmissionsWebhookURL": "http://127.0.0.1:8081/FirstTimeSubmissionsWebhook",
"discordCompletelyIncorrectReportWebhookURL": "http://127.0.0.1:8081/CompletelyIncorrectReportWebhook",
"discordNeuralBlockRejectWebhookURL": "http://127.0.0.1:8081/NeuralBlockRejectWebhook",
"neuralBlockURL": "http://127.0.0.1:8081/NeuralBlock",
"behindProxy": true,
"postgres": {
"user": "ci_db_user",
"password": "ci_db_pass",
"host": "localhost",
"port": 5432
},
"createDatabaseIfNotExist": true,
"schemaFolder": "./databases",
"dbSchema": "./databases/_sponsorTimes.db.sql",
"privateDBSchema": "./databases/_private.db.sql",
"mode": "test",
"readOnly": false,
"webhooks": [
{
"url": "http://127.0.0.1:8081/CustomWebhook",
"key": "superSecretKey",
"scopes": [
"vote.up",
"vote.down"
]
}, {
"url": "http://127.0.0.1:8081/FailedWebhook",
"key": "superSecretKey",
"scopes": [
"vote.up",
"vote.down"
]
}, {
"url": "http://127.0.0.1:8099/WrongPort",
"key": "superSecretKey",
"scopes": [
"vote.up",
"vote.down"
]
}
],
"categoryList": ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "highlight"],
"maxNumberOfActiveWarnings": 3,
"hoursAfterWarningExpires": 24,
"rateLimit": {
"vote": {
"windowMs": 900000,
"max": 20,
"message": "Too many votes, please try again later",
"statusCode": 429
},
"view": {
"windowMs": 900000,
"max": 20,
"statusCode": 200
}
}
}

View file

@ -0,0 +1,9 @@
version: '3'
services:
postgres:
image: postgres:alpine
environment:
- POSTGRES_USER=${PG_USER}
- POSTGRES_PASSWORD=${PG_PASS}
ports:
- 5432:5432

View file

@ -2,7 +2,9 @@ import fs from 'fs';
import {SBSConfig} from "./types/config.model";
const isTestMode = process.env.npm_lifecycle_script === 'ts-node test/test.ts';
const configFile = isTestMode ? 'test.json' : 'config.json';
const configFile = process.env.TEST_POSTGRES ? 'ci.json'
: isTestMode ? 'test.json'
: 'config.json';
export const config: SBSConfig = JSON.parse(fs.readFileSync(configFile).toString('utf8'));
addDefaults(config, {

View file

@ -23,6 +23,11 @@ async function init() {
await initDb();
const dbMode = config.mysql ? 'mysql'
: config.postgres ? 'postgres'
: 'sqlite'
Logger.info('Database Mode: ' + dbMode)
// Instantiate a Mocha instance.
const mocha = new Mocha();