diff --git a/.github/actions/run_tests/action.yaml b/.github/actions/run_tests/action.yaml index a078cb10..c303efb2 100644 --- a/.github/actions/run_tests/action.yaml +++ b/.github/actions/run_tests/action.yaml @@ -30,10 +30,9 @@ runs: shell: bash run: | set +e - cargo llvm-cov --no-report nextest --features=bindings --workspace ${{ contains(inputs.target, 'musl') && '--exclude context-js --exclude context-py --exclude context_ruby' || '' }} --profile=ci + cargo llvm-cov --all-features --no-report nextest --features=bindings --workspace ${{ contains(inputs.target, 'musl') && '--exclude context-js --exclude context-py --exclude context_ruby' || '' }} --profile=ci exitcode="$?" cargo llvm-cov --no-report --doc - cargo llvm-cov report --doctests --lcov --output-path lcov.info exit "$exitcode" - name: Upload coverage reports to Codecov diff --git a/.gitignore b/.gitignore index 73fab072..315f87e6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ # will have compiled files and executables debug/ target/ +lcov.info # These are backup files generated by rustfmt **/*.rs.bk diff --git a/cli-tests/Cargo.toml b/cli-tests/Cargo.toml index a2a0d1a7..04b87f0a 100644 --- a/cli-tests/Cargo.toml +++ b/cli-tests/Cargo.toml @@ -5,26 +5,17 @@ edition = "2021" [dev-dependencies] api = { path = "../api" } -assert_cmd = "2.0.16" assert_matches = "1.5.0" axum = { version = "0.7.5", features = ["macros"] } -bazel-bep = { path = "../bazel-bep" } bundle = { path = "../bundle" } -chrono = "0.4.33" codeowners = { path = "../codeowners" } -constants = { path = "../constants" } context = { path = "../context" } -escargot = "0.5.12" exitcode = "1.1.1" -junit-mock = { path = "../junit-mock" } -lazy_static = "1.4" more-asserts = "0.3.1" predicates = "3.0.3" -serde_json = "1.0.133" tempfile = "3.2.0" prost-wkt-types = { version = "0.5.1", features = ["vendored-protox"] } prost = "0.12.6" -test_utils = { path = "../test_utils" } tokio = { version = "*" } trunk-analytics-cli = { path = "../cli", features = ["force-sentry-env-dev"] } pretty_assertions = "0.6" @@ -34,6 +25,15 @@ default = [] wasm = [] [dependencies] +chrono = "0.4.33" +constants = { path = "../constants" } +bazel-bep = { path = "../bazel-bep" } +escargot = "0.5.12" +lazy_static = "1.4" +test_utils = { path = "../test_utils" } +junit-mock = { path = "../junit-mock" } +assert_cmd = "2.0.16" +serde_json = "1.0.133" anyhow = "1.0.96" proto = { version = "0.0.0", path = "../proto" } superconsole = "0.2.0" diff --git a/cli-tests/src/lib.rs b/cli-tests/src/lib.rs new file mode 100644 index 00000000..8a125d1e --- /dev/null +++ b/cli-tests/src/lib.rs @@ -0,0 +1,2 @@ +pub mod command_builder; +pub mod utils; diff --git a/cli-tests/src/main.rs b/cli-tests/src/main.rs deleted file mode 100644 index 2db0ba6b..00000000 --- a/cli-tests/src/main.rs +++ /dev/null @@ -1,12 +0,0 @@ -#[cfg(test)] -mod command_builder; -#[cfg(test)] -mod test; -#[cfg(test)] -mod upload; -#[cfg(test)] -mod utils; -#[cfg(test)] -mod validate; - -fn main() {} diff --git a/cli-tests/src/test.rs b/cli-tests/tests/test.rs similarity index 99% rename from cli-tests/src/test.rs rename to cli-tests/tests/test.rs index 4a323623..755645b7 100644 --- a/cli-tests/src/test.rs +++ b/cli-tests/tests/test.rs @@ -10,18 +10,17 @@ use api::message::{ use assert_matches::assert_matches; use axum::{extract::State, Json}; use bundle::BundleMeta; -use context::{bazel_bep::parser::BazelBepParser, junit::parser::JunitParser}; -use predicates::prelude::*; -use tempfile::tempdir; -use test_utils::mock_server::{MockServerBuilder, RequestPayload, SharedMockServerState}; - -use crate::{ +use cli_tests::{ command_builder::CommandBuilder, utils::{ generate_mock_bazel_bep, generate_mock_codeowners, generate_mock_git_repo, generate_mock_valid_junit_xmls, }, }; +use context::{bazel_bep::parser::BazelBepParser, junit::parser::JunitParser}; +use predicates::prelude::*; +use tempfile::tempdir; +use test_utils::mock_server::{MockServerBuilder, RequestPayload, SharedMockServerState}; // NOTE: must be multi threaded to start a mock server #[tokio::test(flavor = "multi_thread")] diff --git a/cli-tests/src/upload.rs b/cli-tests/tests/upload.rs similarity index 99% rename from cli-tests/src/upload.rs rename to cli-tests/tests/upload.rs index 13f7ec92..e68a18fe 100644 --- a/cli-tests/src/upload.rs +++ b/cli-tests/tests/upload.rs @@ -10,6 +10,12 @@ use assert_matches::assert_matches; use axum::{extract::State, http::StatusCode, Json}; use bundle::{BundleMeta, FileSetType, INTERNAL_BIN_FILENAME}; use chrono::TimeDelta; +use cli_tests::command_builder::CommandBuilder; +use cli_tests::utils::{ + generate_mock_bazel_bep, generate_mock_codeowners, generate_mock_git_repo, + generate_mock_valid_junit_xmls, + generate_mock_invalid_junit_xmls, +}; use codeowners::CodeOwners; use constants::EXIT_FAILURE; use context::{ @@ -18,6 +24,7 @@ use context::{ repo::{BundleRepo, RepoUrlParts as Repo}, }; use lazy_static::lazy_static; +use more_asserts::assert_lt; use predicates::prelude::*; use pretty_assertions::assert_eq; use prost::Message; @@ -30,12 +37,6 @@ use test_utils::{ }; use trunk_analytics_cli::upload_command::DRY_RUN_OUTPUT_DIR; -use crate::command_builder::CommandBuilder; -use crate::utils::{ - generate_mock_bazel_bep, generate_mock_codeowners, generate_mock_git_repo, - generate_mock_invalid_junit_xmls, generate_mock_valid_junit_xmls, -}; - // NOTE: must be multi threaded to start a mock server #[tokio::test(flavor = "multi_thread")] async fn upload_bundle() { @@ -120,7 +121,10 @@ async fn upload_bundle() { assert!(!base_props.repo.repo_head_sha.is_empty()); let repo_head_sha_short = base_props.repo.repo_head_sha_short.unwrap(); assert!(!repo_head_sha_short.is_empty()); - assert!(&repo_head_sha_short.len() < &base_props.repo.repo_head_sha.len()); + assert_lt!( + &repo_head_sha_short.len(), + &base_props.repo.repo_head_sha.len() + ); assert!(base_props .repo .repo_head_sha @@ -143,7 +147,7 @@ async fn upload_bundle() { ); let time_since_upload = chrono::Utc::now() - chrono::DateTime::from_timestamp(base_props.upload_time_epoch as i64, 0).unwrap(); - more_asserts::assert_lt!(time_since_upload.num_minutes(), 5); + assert_lt!(time_since_upload.num_minutes(), 5); assert_eq!(base_props.test_command, None); assert!(base_props.os_info.is_some()); assert!(base_props.quarantined_tests.is_empty()); diff --git a/cli-tests/src/validate.rs b/cli-tests/tests/validate.rs similarity index 99% rename from cli-tests/src/validate.rs rename to cli-tests/tests/validate.rs index 071661f0..e69ac494 100644 --- a/cli-tests/src/validate.rs +++ b/cli-tests/tests/validate.rs @@ -5,7 +5,7 @@ use superconsole::{ }; use tempfile::tempdir; -use crate::{ +use cli_tests::{ command_builder::CommandBuilder, utils::{ generate_mock_codeowners, generate_mock_invalid_junit_xmls, diff --git a/context-py/src/lib.rs b/context-py/src/lib.rs index e1727a5b..b8d0098a 100644 --- a/context-py/src/lib.rs +++ b/context-py/src/lib.rs @@ -65,7 +65,7 @@ fn branch_class_to_string(branch_class: env::parser::BranchClass) -> String { #[gen_stub_pyfunction] #[pyfunction] fn ci_platform_to_string(ci_platform: env::parser::CIPlatform) -> String { - ci_platform.to_string() + String::from(Into::<&str>::into(ci_platform)) } #[gen_stub_pyfunction]