Skip to content

Commit

Permalink
Fix CI - Attempt #2
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai committed Nov 12, 2024
1 parent b48a1f2 commit 11c3e08
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ jobs:
# Otherwise only the last build to finish would get saved to the cache.
# We allow different test_flags to share a cache as they should have identical build outputs
key: ${{ matrix.runner }} - ${{ matrix.cargo_flags }}
cache-directories: |
target/debug/jassets
target/release/jassets
cache-directories: "test-helpers/j4rs"

# this line means that only the main branch writes to the cache
# benefits:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
/docs/mdbook_bin
/shotover-proxy/build/packages
/some_local_file
/test-helpers/src/connection/kafka/node/node_modules
/test-helpers/src/connection/kafka/node/node_modules
/test-helpers/j4rs
3 changes: 3 additions & 0 deletions test-helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ rustls-pemfile = "2.0.0"
tokio-tungstenite = { version = "0.24", features = ["rustls-tls-native-roots"] }
pretty_assertions.workspace = true
serde.workspace = true

[build-dependencies]
j4rs = "0.21.0"
20 changes: 20 additions & 0 deletions test-helpers/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use j4rs::errors::J4RsError;

fn main() {
println!("cargo:rerun-if-changed=build.rs");

std::fs::create_dir("j4rs").ok();
match j4rs::Jvm::copy_j4rs_libs_under("j4rs") {
Ok(()) => {}
Err(J4RsError::GeneralError(e)) => {
// if the jassets directory has been deleted (maybe it wasnt cached with the rest of the build)
// then we may still have a functioning j4rs directory from a previous run
if e != "Can not find jassets directory" {
panic!("j4rs lib copy failed with: GeneralError({e})")
}
}
Err(e) => {
panic!("j4rs lib copy failed with: {e}")
}
}
}
7 changes: 6 additions & 1 deletion test-helpers/src/connection/java.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ impl Jvm {
/// Construct a JVM, downloads the list of deps from the maven repository.
/// Example dep string: "org.slf4j:slf4j-api:1.7.36"
pub(crate) fn new(deps: &[&str]) -> Self {
let jvm = Rc::new(JvmBuilder::new().build().unwrap());
let jvm = Rc::new(
JvmBuilder::new()
.with_base_path("../test-helpers/j4rs")
.build()
.unwrap(),
);

for dep in deps {
jvm.deploy_artifact(&MavenArtifact::from(*dep)).unwrap();
Expand Down

0 comments on commit 11c3e08

Please sign in to comment.