Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more tests to CI #792

Merged
merged 6 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ ${DOCKER} bash -c "cd build && cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_DEBUG_WA
echo =====
${DOCKER} bash -c "cd build && make -j $(nproc)"
echo =====
${DOCKER} bash -c "cd rust && cargo build --target-dir ../build/rust --release"
echo =====
${DOCKER} bash -c "cd build && ctest --output-on-failure -j $(nproc)"
echo =====
ls -la ${WORKSPACE_ROOT}
Expand Down
15 changes: 15 additions & 0 deletions rust/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ add_test(
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/release/cargo-psibase test --manifest-path ${CMAKE_CURRENT_SOURCE_DIR}/test_subjective/Cargo.toml --target-dir ${CMAKE_CURRENT_BINARY_DIR} --psitest=${CMAKE_BINARY_DIR}/psitest
)

add_test(
NAME rs-test-contract
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/release/cargo-psibase test --manifest-path ${CMAKE_CURRENT_SOURCE_DIR}/test_contract/Cargo.toml --target-dir ${CMAKE_CURRENT_BINARY_DIR} --psitest=${CMAKE_BINARY_DIR}/psitest
)

add_test(
NAME rs-test-contract-2
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/release/cargo-psibase test --manifest-path ${CMAKE_CURRENT_SOURCE_DIR}/test_contract_2/Cargo.toml --target-dir ${CMAKE_CURRENT_BINARY_DIR} --psitest=${CMAKE_BINARY_DIR}/psitest
Expand All @@ -15,6 +20,16 @@ add_test(
COMMAND cargo test --manifest-path ${CMAKE_CURRENT_SOURCE_DIR}/Cargo.toml --target-dir ${CMAKE_CURRENT_BINARY_DIR} -p test_fracpack -p psibase -p cargo-psibase
)

add_test(
NAME rs-elections-test
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/release/cargo-psibase test --manifest-path ${CMAKE_CURRENT_SOURCE_DIR}/test_subjective/Cargo.toml --target-dir ${CMAKE_CURRENT_BINARY_DIR} --psitest=${CMAKE_BINARY_DIR}/psitest
)

add_test(
NAME rs-sites-test
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/release/cargo-psibase test --manifest-path ${CMAKE_CURRENT_SOURCE_DIR}/test_subjective/Cargo.toml --target-dir ${CMAKE_CURRENT_BINARY_DIR} --psitest=${CMAKE_BINARY_DIR}/psitest
)

include(ProcessorCount)
ProcessorCount(NPROC)
if(NPROC)
Expand Down
1 change: 1 addition & 0 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/test_service_elections/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ crate-type = ["cdylib"]
fracpack = { version = "0.11.0", path = "../fracpack" }
psibase = { version = "0.11.0", path = "../psibase" }
serde = { version = "1.0.145", features = ["derive"] }
async-graphql = "4.0"
8 changes: 4 additions & 4 deletions rust/test_service_elections/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod service {
use psibase::{
check, check_none, check_some, get_sender, get_service, serve_content, serve_simple_ui,
services::transact, store_content, AccountNumber, HexBytes, HttpReply, HttpRequest, Pack,
Reflect, Table, TimePointSec, ToKey, Unpack, WebContentRow,
Table, TimePointSec, ToKey, ToSchema, Unpack, WebContentRow,
};
use serde::{Deserialize, Serialize};

Expand All @@ -20,7 +20,7 @@ mod service {
const MIN_ELECTION_TIME_SECONDS: TimePointSec = TimePointSec { seconds: 60 * 60 };

#[table(name = "ElectionsTable", index = 0)]
#[derive(Debug, Pack, Unpack, Reflect, Serialize, Deserialize)]
#[derive(Debug, Pack, Unpack, ToSchema, Serialize, Deserialize)]
pub struct ElectionRecord {
#[primary_key]
pub id: u32,
Expand All @@ -37,7 +37,7 @@ mod service {
}

#[table(name = "CandidatesTable", index = 1)]
#[derive(Eq, PartialEq, Clone, Debug, Pack, Unpack, Reflect, Serialize, Deserialize)]
#[derive(Eq, PartialEq, Clone, Debug, Pack, Unpack, ToSchema, Serialize, Deserialize)]
pub struct CandidateRecord {
pub election_id: u32,
pub candidate: AccountNumber,
Expand All @@ -57,7 +57,7 @@ mod service {
}

#[table(name = "VotesTable", index = 2)]
#[derive(Eq, PartialEq, Clone, Pack, Unpack, Reflect, Serialize, Deserialize)]
#[derive(Eq, PartialEq, Clone, Pack, Unpack, ToSchema, Serialize, Deserialize)]
struct VotingRecord {
election_id: u32,
voter: AccountNumber,
Expand Down
6 changes: 4 additions & 2 deletions rust/test_service_sites/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ mod service {
use psibase::{
check, get_sender, get_service, queries, serve_action_templates, serve_graphiql,
serve_graphql, serve_pack_action, AccountNumber, HexBytes, HttpReply, HttpRequest, Pack,
Reflect, Table, TableIndex, ToKey, Unpack,
Table, TableIndex, ToKey, Unpack,
};
use serde::{Deserialize, Serialize};

type ContentKey = (AccountNumber, String);

#[table(name = "ContentTable", index = 0)]
#[derive(Debug, Pack, Unpack, PartialEq, Eq, Reflect, Serialize, Deserialize, SimpleObject)]
#[derive(Debug, Pack, Unpack, PartialEq, Eq, Serialize, Deserialize, SimpleObject)]
pub struct ContentRow {
pub account: AccountNumber,
pub path: String,
Expand All @@ -34,6 +34,7 @@ mod service {
impl From<ContentRow> for HttpReply {
fn from(content_row: ContentRow) -> Self {
HttpReply {
status: 200,
contentType: content_row.content_type,
body: content_row.content,
headers: Vec::new(),
Expand Down Expand Up @@ -519,6 +520,7 @@ mod tests {
assert_eq!(
reply,
&HttpReply {
status: 200,
contentType: content_type.to_owned(),
body: content.clone().into(),
headers: Vec::new(),
Expand Down
Loading