cyrtophora

Full-stack users-first, secure web framework.
git clone https://gitlab.com/kwatafana/cyrtophora.git
Log | Files | Refs | README

commit f148b42cb5f4162fec53fa094fd8837dee05ffa1
parent 04bf46132d478f0d17c28a957e9841722c306ae0
Author: kaindume <cy6erlion@protonmail.com>
Date:   Thu, 22 Sep 2022 14:14:18 +0000

Merge branch 'ci' into 'root'

Setup Rust CI

See merge request kwatafana/cyrtophora!2
Diffstat:
A.gitlab-ci.yml | 38++++++++++++++++++++++++++++++++++++++
Mphora/Cargo.lock | 1+
Mphora/Cargo.toml | 3+--
Mphora/src/lib.rs | 23+++++++++++++++++++++--
4 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml @@ -0,0 +1,38 @@ +.cargo_test_template: &cargo_test + stage: test + script: + - cd phora + - mkdir test-data + - cargo test -F sqlite --verbose --jobs 1 + +stages: + - test + - deploy + +stable:cargo: + image: rustdocker/rust:stable + <<: *cargo_test + +beta:cargo: + image: rustdocker/rust:beta + <<: *cargo_test + +nightly:cargo: + image: rustdocker/rust:nightly + <<: *cargo_test + +pages: + image: rustdocker/rust:stable + stage: deploy + only: + - root + script: + - cargo doc + - rm -rf public + - mkdir public + - cp -R target/doc/* public + artifacts: + paths: + - public + +# Reference: http://imp.gitlab.io/blog/blog/gitlab-ci-and-rust/ diff --git a/phora/Cargo.lock b/phora/Cargo.lock @@ -250,6 +250,7 @@ version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f0455f2c1bc9a7caa792907026e469c1d91761fb0ea37cbb16427c77280cf35" dependencies = [ + "cc", "pkg-config", "vcpkg", ] diff --git a/phora/Cargo.toml b/phora/Cargo.toml @@ -10,7 +10,6 @@ chacha20poly1305 = "0.9.0" base64 = "0.13.0" scrypt = "0.10.0" serde = { version = "1.0.144", features = ["derive"] } -rusqlite = { version = "0.28.0", optional = true } - +rusqlite = { version = "0.28.0", features = ["bundled"], optional = true } [features] sqlite = ["dep:rusqlite"] \ No newline at end of file diff --git a/phora/src/lib.rs b/phora/src/lib.rs @@ -17,9 +17,9 @@ where impl<D: DB> Cyrtophora<D> { #[cfg(feature = "sqlite")] pub fn new_sqlite( - path: &str, + db_path: &str, ) -> Result<Cyrtophora<database::sqlite::SqliteDB>, database::error::Error> { - let mut db = database::sqlite::SqliteDB::new(path); + let mut db = database::sqlite::SqliteDB::new(db_path); db.connect()?; let c = Cyrtophora { database: Some(db) }; Ok(c) @@ -56,3 +56,22 @@ impl<D: DB> Cyrtophora<D> { } } } + +#[cfg(test)] +mod test { + use super::*; + + const TEST_DB_PATH: &str = "test-data/ACCOUNTS.db"; + + #[test] + #[cfg(feature = "sqlite")] + fn test_new_sqlite() { + let cyrtophora = + Cyrtophora::<database::sqlite::SqliteDB>::new_sqlite(TEST_DB_PATH).unwrap(); + + match cyrtophora.database { + Some(_conn) => assert!(true), + _ => assert!(false), + } + } +}