From f48caac586b427e514d33d4664c0eb5dd3888c33 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Mon, 26 Feb 2024 20:25:37 +0100 Subject: [PATCH] Upload native-image argfiles (#9094) In PR #8953, in commit https://github.com/enso-org/enso/pull/8953/commits/ba0a69de6e715340dfc912368054dfbc9c48ad57, I have introduced argument files to the `native-image`. In this PR, let's try to upload these argfiles as artifacts on GH, so that we can inspect them later. --- build/build/paths.yaml | 11 ++++++- build/build/src/engine/context.rs | 31 +++++++++++++++++++ .../downloader/http/HttpDownloaderTest.java | 7 +++-- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/build/build/paths.yaml b/build/build/paths.yaml index ce96cb12213f..0d8fa691fd38 100644 --- a/build/build/paths.yaml +++ b/build/build/paths.yaml @@ -1,5 +1,5 @@ # This file is used to generate `target//build/enso-build-/out/paths.rs`. -# Generation logic is in `ci_utils/src/paths.rs`. +# Generation logic is in `build/macros/lib/src/paths.rs`. /: .github/: @@ -89,8 +89,13 @@ test/: resources/: Factorial.enso: + target/: + native-image-args.txt: runtime/: target/: + launcher/: + target/: + native-image-args.txt: runtime-benchmarks/: bench-report.xml: lib/: @@ -98,6 +103,10 @@ parser/: generate-java/: java/: + scala/: + project-manager/: + target/: + native-image-args.txt: target/: ensogl-pack/: dist/: # Here ensogl-pack outputs its artifacts diff --git a/build/build/src/engine/context.rs b/build/build/src/engine/context.rs index 93d576a10bc1..e8a8aef846ba 100644 --- a/build/build/src/engine/context.rs +++ b/build/build/src/engine/context.rs @@ -216,6 +216,35 @@ impl RunContext { Ok(()) } + /// During the native-image build, the engine generates arg files. This function uploads them as + /// artifacts on the CI, so we can inspect them later. + /// Note that if something goes wrong, the native image arg files may not be present. + async fn upload_native_image_arg_files(&self) -> Result { + debug!("Uploading Native Image Arg Files"); + let engine_runner_ni_argfile = + &self.repo_root.engine.runner.target.native_image_args_txt.path; + let launcher_ni_argfile = &self.repo_root.engine.launcher.target.native_image_args_txt.path; + let project_manager_ni_argfile = + &self.repo_root.lib.scala.project_manager.target.native_image_args_txt.path; + let native_image_arg_files = [ + (engine_runner_ni_argfile, "Engine Runner native-image-args"), + (launcher_ni_argfile, "Launcher native-image-args"), + (project_manager_ni_argfile, "Project Manager native-image-args"), + ]; + for (argfile, artifact_name) in native_image_arg_files { + if argfile.exists() { + ide_ci::actions::artifacts::upload_single_file(&argfile, artifact_name).await?; + } else { + warn!( + "Native Image Arg File for {} not found at {}", + artifact_name, + argfile.display() + ); + } + } + Ok(()) + } + pub async fn build(&self) -> Result { self.prepare_build_env().await?; if ide_ci::ci::run_in_ci() { @@ -475,6 +504,8 @@ impl RunContext { // If we were running any benchmarks, they are complete by now. Upload the report. if is_in_env() { + self.upload_native_image_arg_files().await?; + for bench in &self.config.execute_benchmarks { match bench { Benchmarks::Runtime => { diff --git a/lib/scala/downloader/src/test/java/org/enso/downloader/http/HttpDownloaderTest.java b/lib/scala/downloader/src/test/java/org/enso/downloader/http/HttpDownloaderTest.java index 8db53023614f..8bf5a21df4f7 100644 --- a/lib/scala/downloader/src/test/java/org/enso/downloader/http/HttpDownloaderTest.java +++ b/lib/scala/downloader/src/test/java/org/enso/downloader/http/HttpDownloaderTest.java @@ -162,6 +162,9 @@ public void done(Try result) { task.addProgressListener(progressListener); var resp = task.force(); assertThat(resp.content(), containsString("Hello")); + assertThat("Done was called exactly once", doneCalls[0], is(1)); + assertThat( + "Progress reported was called at least once", progressUpdateCalls[0], greaterThan(0)); } private static class TextHandler extends SimpleHttpHandler { @@ -188,9 +191,9 @@ protected void doHandle(HttpExchange exchange) throws IOException { } private static class BigFileHandler extends SimpleHttpHandler { - private static final long BIG_FILE_SIZE = 10 * 1024; - private static final byte[] BIG_FILE_BYTES = new byte[Math.toIntExact(BIG_FILE_SIZE)]; private static final int CHUNK_SIZE = 1024; + private static final long BIG_FILE_SIZE = 10 * CHUNK_SIZE; + private static final byte[] BIG_FILE_BYTES = new byte[Math.toIntExact(BIG_FILE_SIZE)]; static { var rnd = new Random(42);