add drone ci support
This commit is contained in:
parent
6392388d8a
commit
ff225070e4
|
@ -0,0 +1,39 @@
|
||||||
|
kind: pipeline
|
||||||
|
name: papertrader
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: database_init
|
||||||
|
image: postgres
|
||||||
|
commands:
|
||||||
|
- sleep 10
|
||||||
|
- echo "database:5432:pt_db:pt_usr:PASSWORD" > ~/.pgpass
|
||||||
|
- chmod 0600 ~/.pgpass
|
||||||
|
- export DIR="$(pwd)/src/libtrader/server/db/sql"
|
||||||
|
- for file in $DIR/*; do psql -w -U pt_usr -d pt_db -a -h database -f "$${file}"; done
|
||||||
|
|
||||||
|
- name: server
|
||||||
|
image: rust
|
||||||
|
detach: true
|
||||||
|
commands:
|
||||||
|
- sleep 15
|
||||||
|
- export CI_DEPLOY=1
|
||||||
|
- ./scripts/deploy_sandbox_server.sh server:4000
|
||||||
|
depends:
|
||||||
|
- database_init
|
||||||
|
|
||||||
|
- name: client
|
||||||
|
image: rust
|
||||||
|
commands:
|
||||||
|
- sleep 75
|
||||||
|
- ./scripts/deploy_sandbox_client.sh server:4000
|
||||||
|
|
||||||
|
services:
|
||||||
|
- name: database
|
||||||
|
image: postgres
|
||||||
|
volumes:
|
||||||
|
- name: dockersock
|
||||||
|
path: /var/run
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: pt_db
|
||||||
|
POSTGRES_USER: pt_usr
|
||||||
|
POSTGRES_PASSWORD: PASSWORD
|
|
@ -1,4 +1,4 @@
|
||||||
![Rust](https://github.com/realaltffour/PaperTrader/workflows/Rust/badge.svg)
|
[![Build Status](https://drone.tildegit.org/api/badges/ayham/PaperTrader/status.svg)](https://drone.tildegit.org/ayham/PaperTrader)
|
||||||
# PaperTrader
|
# PaperTrader
|
||||||
The opensource cross-platform paper trader for learning to trade assets.
|
The opensource cross-platform paper trader for learning to trade assets.
|
||||||
# Getting Started
|
# Getting Started
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
cargo run --no-default-features --features "client,tls_no_verify"
|
cargo run --no-default-features --features "client,tls_no_verify" -- ${1:-0.0.0.0:4000}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
. ./scripts/env.sh && cargo run --no-default-features --features "server" -- 0.0.0.0:4000 --cert certs/certificate.crt --key certs/private.key
|
. ./scripts/env.sh && cargo run --no-default-features --features "server" -- ${1:-0.0.0.0:4000} --cert certs/certificate.crt --key certs/private.key
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
export DB_HOST="localhost"
|
export DB_HOST="database"
|
||||||
|
[ -z "$CI_DEPLOY" ] && export DB_HOST="localhost"
|
||||||
|
|
||||||
export DB_HOST_PORT="5432"
|
export DB_HOST_PORT="5432"
|
||||||
export DB_NAME="pt_db"
|
export DB_NAME="pt_db"
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,16 @@ use crate::client::network::gen_tls_client_config::gen_tls_client_config;
|
||||||
use rand::distributions::Alphanumeric;
|
use rand::distributions::Alphanumeric;
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
|
|
||||||
|
use argh::FromArgs;
|
||||||
|
|
||||||
|
/// Client Options
|
||||||
|
#[derive(FromArgs)]
|
||||||
|
struct Options {
|
||||||
|
/// bind addr
|
||||||
|
#[argh(positional)]
|
||||||
|
addr: String,
|
||||||
|
}
|
||||||
|
|
||||||
/// Initializes global logger.
|
/// Initializes global logger.
|
||||||
///
|
///
|
||||||
/// Private function used by libtrader_init() to initialize the logger. Log destinations are
|
/// Private function used by libtrader_init() to initialize the logger. Log destinations are
|
||||||
|
@ -94,10 +104,15 @@ pub async fn libtrader_init_client() -> std::io::Result<()> {
|
||||||
// Initialize log.
|
// Initialize log.
|
||||||
libtrader_init_log()?;
|
libtrader_init_log()?;
|
||||||
|
|
||||||
let addr = ("0.0.0.0", 4000)
|
// Initialize arguments
|
||||||
|
let options: Options = argh::from_env();
|
||||||
|
|
||||||
|
let addr = options
|
||||||
|
.addr
|
||||||
.to_socket_addrs()?
|
.to_socket_addrs()?
|
||||||
.next()
|
.next()
|
||||||
.ok_or_else(|| std::io::Error::from(std::io::ErrorKind::NotFound))?;
|
.ok_or_else(|| std::io::Error::from(std::io::ErrorKind::AddrNotAvailable))?;
|
||||||
|
|
||||||
let domain = "localhost";
|
let domain = "localhost";
|
||||||
let config = gen_tls_client_config()?;
|
let config = gen_tls_client_config()?;
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ pub async fn db_connect(
|
||||||
pass: String,
|
pass: String,
|
||||||
) -> Result<tokio_postgres::Client, tokio_postgres::Error> {
|
) -> Result<tokio_postgres::Client, tokio_postgres::Error> {
|
||||||
/* Generate the requested string */
|
/* Generate the requested string */
|
||||||
|
println!("{}", std::env::var("DB_HOST").unwrap());
|
||||||
let db_connect_str = format!(
|
let db_connect_str = format!(
|
||||||
"host={} port={} dbname={} user={} password={}",
|
"host={} port={} dbname={} user={} password={}",
|
||||||
std::env::var("DB_HOST").unwrap(),
|
std::env::var("DB_HOST").unwrap(),
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
## To do
|
## To do
|
||||||
|
|
||||||
|
- use env.sh or arguments
|
||||||
## In progress
|
- server move network code to somewhere plausable.
|
||||||
|
- create correct modules
|
||||||
- data implmentation stuff
|
- data implmentation stuff
|
||||||
* [ ] implement buy & sell
|
* [ ] implement buy & sell
|
||||||
* [ ] impl on client
|
* [ ] impl on client
|
||||||
|
@ -12,6 +12,16 @@
|
||||||
* [ ] ret data on server
|
* [ ] ret data on server
|
||||||
* [ ] transaction data retrieval
|
* [ ] transaction data retrieval
|
||||||
* [ ] split data into multiple writes
|
* [ ] split data into multiple writes
|
||||||
|
- add testing suite
|
||||||
|
* [ ] configure ci to run those tests
|
||||||
|
* [ ] add tests for all server functions
|
||||||
|
* [ ] add tests for all client functions
|
||||||
|
|
||||||
|
## In progress
|
||||||
|
|
||||||
|
- configure drone ci
|
||||||
|
* [ ] wrap server deployment commands in docker
|
||||||
|
* [ ] wrap client deployment commands in docker
|
||||||
|
|
||||||
## Done
|
## Done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue