- Removing old scripts that aren't useful to anyone but myself
+ Adding new bootstrapping script for Docker testing pipeline This build-database script is what is going to setup things like our tables for us so that we can actually run our test queries ! Basically turning off the ci right now since its going through some large breaking changes It's going to be broken for a while so there's no point in running it into a wall of predictable failures
This commit is contained in:
parent
44bfed1351
commit
85660e2fc9
@ -1,6 +1,7 @@
|
|||||||
image: shockrah/freechat:0.4
|
image: shockrah/freechat-pipeline:latest
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- documentation
|
||||||
- build
|
- build
|
||||||
- test
|
- test
|
||||||
|
|
||||||
@ -11,6 +12,13 @@ workflow:
|
|||||||
variables:
|
variables:
|
||||||
CARGO_HOME: $CI_PROJECT_DIR/.cargo
|
CARGO_HOME: $CI_PROJECT_DIR/.cargo
|
||||||
GIT_SUBMODULE_STRATEGY: recursive
|
GIT_SUBMODULE_STRATEGY: recursive
|
||||||
|
# Not doing strict host checking to avoid writing the host fingerprint anywhere
|
||||||
|
# This is important because I don't host this gitlab instance, if I did host my
|
||||||
|
# own gitlab however this wouldn't be here as it would be under my control but
|
||||||
|
# this isn't the case
|
||||||
|
# Really we're just trading one security issue for another:
|
||||||
|
# - keeping fingerprints on someone else's server
|
||||||
|
# - not verifying the host for my little known service
|
||||||
SHOPTS: "-o StrictHostKeyChecking=no"
|
SHOPTS: "-o StrictHostKeyChecking=no"
|
||||||
|
|
||||||
|
|
||||||
@ -24,7 +32,7 @@ build-json-api:
|
|||||||
|
|
||||||
only:
|
only:
|
||||||
refs:
|
refs:
|
||||||
- master
|
- broken
|
||||||
|
|
||||||
changes:
|
changes:
|
||||||
- json-api/Cargo.*
|
- json-api/Cargo.*
|
||||||
@ -38,7 +46,7 @@ build-json-api:
|
|||||||
- json-api/build.sh
|
- json-api/build.sh
|
||||||
|
|
||||||
- json-api/db/Cargo.*
|
- json-api/db/Cargo.*
|
||||||
- json-api/db/src/*
|
- json-api/db/src/*.rs
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- cd json-api/
|
- cd json-api/
|
||||||
@ -61,7 +69,7 @@ test-json-api:
|
|||||||
- build-json-api
|
- build-json-api
|
||||||
only:
|
only:
|
||||||
refs:
|
refs:
|
||||||
- master
|
- broken
|
||||||
|
|
||||||
changes:
|
changes:
|
||||||
- json-api/Cargo.*
|
- json-api/Cargo.*
|
||||||
@ -116,7 +124,7 @@ build-channer:
|
|||||||
build-wiki:
|
build-wiki:
|
||||||
image: shockrah/website:latest
|
image: shockrah/website:latest
|
||||||
only: [ "master" ]
|
only: [ "master" ]
|
||||||
stage: build
|
stage: documentation
|
||||||
|
|
||||||
only:
|
only:
|
||||||
refs:
|
refs:
|
||||||
|
65
scripts/build-db.sh
Normal file
65
scripts/build-db.sh
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Points to the folder that contains all pertinent database tables
|
||||||
|
# Each table directory contains:
|
||||||
|
# dir/
|
||||||
|
# up.sql
|
||||||
|
# down.sql
|
||||||
|
|
||||||
|
|
||||||
|
# First some parameter checks
|
||||||
|
if [ ! $1 ];then
|
||||||
|
echo Failure: Insufficient arguments provided
|
||||||
|
echo ./build-db.sh /migrations/folder/path
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! $2 ];then
|
||||||
|
echo Failure: Insufficient arguments provided
|
||||||
|
echo ./build-db.sh /migrations/folder/path /path/to/.env file
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
migration_loc=$1
|
||||||
|
env_path=$2
|
||||||
|
|
||||||
|
source $env_path
|
||||||
|
|
||||||
|
# This is kinda dumb but we have to check and make sure the sample default user
|
||||||
|
# configuration is all there
|
||||||
|
if [ ! $DATABASE_NAME ];then
|
||||||
|
echo No DATABASE_NAME set
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ ! $DATABASE_PASS ];then
|
||||||
|
echo No DATABASE_PASS set
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ ! $DATABASE_USER ];then
|
||||||
|
echo No DATABASE_USER set
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ ! $DATABASE_HOST ];then
|
||||||
|
echo No DATABASE_HOST set
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ ! $DATABASE_PORT ];then
|
||||||
|
echo No DATABASE_PORT set
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Next we setup the database user
|
||||||
|
mysql -e "CREATE USER '$DATABASE_USER'@'$DATABASE_HOST' IDENTIFIED BY '$DATABASE_PASS';"
|
||||||
|
# Yet another reason to not use this in prod to setup you're database
|
||||||
|
mysql -e "GRANT ALL PRIVILEGES ON *.* TO '$DATABASE_USER'@'$DATABASE_HOST';"
|
||||||
|
|
||||||
|
# First we'll setup the databse that we want to use
|
||||||
|
for dir in $(ls $migration_loc);do
|
||||||
|
# Port field is ignored in this script as its straight up not used in Docker tests
|
||||||
|
echo Migrating $dir
|
||||||
|
mysql -u $DATABASE_USER -p $DATABASE_PASS \
|
||||||
|
-h $DATABASE_HOST -D $DATABASE_NAME \
|
||||||
|
< $dir/up.sql
|
||||||
|
done
|
||||||
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
|||||||
'''
|
|
||||||
Additions: +
|
|
||||||
Modifications: *
|
|
||||||
Removals: -
|
|
||||||
Note/Warning !
|
|
||||||
'''
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
TMP_MSG_FILE = 'commit-message.tmp'
|
|
||||||
|
|
||||||
lines = []
|
|
||||||
|
|
||||||
for line in sys.stdin:
|
|
||||||
line = line.strip()
|
|
||||||
if line.startswith('+'):
|
|
||||||
line = '➕' + line[1:]
|
|
||||||
|
|
||||||
elif line.startswith('-'):
|
|
||||||
line = '➖' + line[1:]
|
|
||||||
|
|
||||||
elif line.startswith('*'):
|
|
||||||
line = '✨' + line[1:]
|
|
||||||
|
|
||||||
elif line.startswith('!'):
|
|
||||||
line = '❗' + line[1:]
|
|
||||||
|
|
||||||
lines.append(line)
|
|
||||||
|
|
||||||
with open(TMP_MSG_FILE, 'w') as target:
|
|
||||||
for line in lines:
|
|
||||||
print(line, file=target)
|
|
||||||
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# This script assumes that everything has been built already
|
|
||||||
export DATABASE_URL=mysql://freechat_dev:password@localhost:3306/freechat
|
|
||||||
json-api/target/release/json-api -s &
|
|
||||||
pushd rtc-server
|
|
||||||
npm start
|
|
||||||
popd
|
|
||||||
kill $(pgrep json-api)
|
|
Loading…
Reference in New Issue
Block a user