add drone ci support
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is passing Details

This commit is contained in:
ayham 2021-07-30 07:04:54 +03:00
parent 6392388d8a
commit ff225070e4
Signed by: ayham
GPG Key ID: EAB7F5A9DF503678
8 changed files with 76 additions and 9 deletions

39
.drone.yml Normal file
View File

@ -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

View File

@ -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
The opensource cross-platform paper trader for learning to trade assets.
# Getting Started

View File

@ -1,3 +1,3 @@
#!/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}

View File

@ -1,3 +1,3 @@
#!/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

View File

@ -1,6 +1,8 @@
#!/bin/sh
export DB_HOST="localhost"
export DB_HOST="database"
[ -z "$CI_DEPLOY" ] && export DB_HOST="localhost"
export DB_HOST_PORT="5432"
export DB_NAME="pt_db"

View File

@ -10,6 +10,16 @@ use crate::client::network::gen_tls_client_config::gen_tls_client_config;
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use argh::FromArgs;
/// Client Options
#[derive(FromArgs)]
struct Options {
/// bind addr
#[argh(positional)]
addr: String,
}
/// Initializes global logger.
///
/// 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.
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()?
.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 config = gen_tls_client_config()?;

View File

@ -19,6 +19,7 @@ pub async fn db_connect(
pass: String,
) -> Result<tokio_postgres::Client, tokio_postgres::Error> {
/* Generate the requested string */
println!("{}", std::env::var("DB_HOST").unwrap());
let db_connect_str = format!(
"host={} port={} dbname={} user={} password={}",
std::env::var("DB_HOST").unwrap(),

View File

@ -1,8 +1,8 @@
## To do
## In progress
- use env.sh or arguments
- server move network code to somewhere plausable.
- create correct modules
- data implmentation stuff
* [ ] implement buy & sell
* [ ] impl on client
@ -12,6 +12,16 @@
* [ ] ret data on server
* [ ] transaction data retrieval
* [ ] 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