mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
commit
1570657e28
6 changed files with 112 additions and 4 deletions
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
|
@ -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
28
.github/workflows/postgres-ci.yml
vendored
Normal 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
65
ci.json
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
9
docker/docker-compose-ci.yml
Normal file
9
docker/docker-compose-ci.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
version: '3'
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:alpine
|
||||
environment:
|
||||
- POSTGRES_USER=${PG_USER}
|
||||
- POSTGRES_PASSWORD=${PG_PASS}
|
||||
ports:
|
||||
- 5432:5432
|
|
@ -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, {
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue