Skip to content
Draft
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
3 changes: 1 addition & 2 deletions .github/actions/run_tests/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# will have compiled files and executables
debug/
target/
lcov.info

# These are backup files generated by rustfmt
**/*.rs.bk
Expand Down
18 changes: 9 additions & 9 deletions cli-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
2 changes: 2 additions & 0 deletions cli-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod command_builder;
pub mod utils;
12 changes: 0 additions & 12 deletions cli-tests/src/main.rs

This file was deleted.

11 changes: 5 additions & 6 deletions cli-tests/src/test.rs → cli-tests/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
20 changes: 12 additions & 8 deletions cli-tests/src/upload.rs → cli-tests/tests/upload.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::io::Write;

Check failure on line 1 in cli-tests/tests/upload.rs

View workflow job for this annotation

GitHub Actions / Trunk Check

rustfmt

Incorrect formatting, autoformat by running 'trunk fmt'
use std::sync::{Arc, Mutex};
use std::{fs, io::BufReader};

Expand All @@ -10,6 +10,12 @@
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::{
Expand All @@ -18,6 +24,7 @@
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;
Expand All @@ -30,12 +37,6 @@
};
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() {
Expand Down Expand Up @@ -120,7 +121,10 @@
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
Expand All @@ -143,7 +147,7 @@
);
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());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use predicates::prelude::*;

Check failure on line 1 in cli-tests/tests/validate.rs

View workflow job for this annotation

GitHub Actions / Trunk Check

rustfmt

Incorrect formatting, autoformat by running 'trunk fmt'
use superconsole::{
style::{style, Color, Stylize},
Line, Span,
};
use tempfile::tempdir;

use crate::{
use cli_tests::{
command_builder::CommandBuilder,
utils::{
generate_mock_codeowners, generate_mock_invalid_junit_xmls,
Expand Down
2 changes: 1 addition & 1 deletion context-py/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading