diff --git a/.github/workflows/ide-packaging-optional.yml b/.github/workflows/ide-packaging-optional.yml index 485bc4c0995d..8a8f1a1834b9 100644 --- a/.github/workflows/ide-packaging-optional.yml +++ b/.github/workflows/ide-packaging-optional.yml @@ -51,6 +51,15 @@ jobs: - run: ./run backend get env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Archive project-manager + run: tar -cvf project-manager.tar -C dist/backend . + - name: Upload project-manager + uses: actions/upload-artifact@v4 + with: + name: project-manager-macos + path: project-manager.tar + - name: Cleanup + run: rm project-manager.tar - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean @@ -145,7 +154,15 @@ jobs: run: ./run git-clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: ./run ide build --backend-source current-ci-run --gui-upload-artifact false + - name: Download project-manager + uses: actions/download-artifact@v4 + with: + name: project-manager-macos + path: dist/backend + - run: |- + tar -xvf dist/backend/project-manager.tar -C dist/backend + rm dist/backend/project-manager.tar + - run: ./run ide build --backend-source local --gui-upload-artifact false env: APPLEID: ${{ secrets.APPLE_NOTARIZATION_USERNAME }} APPLEIDPASS: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }} @@ -181,6 +198,11 @@ jobs: compression-level: 0 name: test-traces-macos-amd64 path: app/ide-desktop/client/test-traces + - name: Upload ide + uses: actions/upload-artifact@v4 + with: + name: ide-macos + path: dist/ide/enso-*.dmg - run: rm $HOME/.enso/credentials env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ide-packaging.yml b/.github/workflows/ide-packaging.yml index 2f1b00dae956..4088c148e93a 100644 --- a/.github/workflows/ide-packaging.yml +++ b/.github/workflows/ide-packaging.yml @@ -51,6 +51,25 @@ jobs: - run: ./run backend get env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Upload Edition File + uses: actions/upload-artifact@v4 + with: + name: Edition File + path: distribution/editions/*.yaml + - name: Upload fbs-schema + uses: actions/upload-artifact@v4 + with: + name: fbs-schema + path: engine/language-server/src/main/schema/ + - name: Archive project-manager + run: tar -cvf project-manager.tar -C dist/backend . + - name: Upload project-manager + uses: actions/upload-artifact@v4 + with: + name: project-manager-linux + path: project-manager.tar + - name: Cleanup + run: rm project-manager.tar - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean @@ -92,6 +111,15 @@ jobs: - run: ./run backend get env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Archive project-manager + run: tar -cvf project-manager.tar -C dist/backend . + - name: Upload project-manager + uses: actions/upload-artifact@v4 + with: + name: project-manager-windows + path: project-manager.tar + - name: Cleanup + run: rm project-manager.tar - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean @@ -146,6 +174,11 @@ jobs: ENSO_IDE_SENTRY_DSN: ${{ vars.ENSO_CLOUD_SENTRY_DSN }} ENSO_IDE_STRIPE_KEY: ${{ vars.ENSO_CLOUD_STRIPE_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Upload gui + uses: actions/upload-artifact@v4 + with: + name: gui + path: dist/gui/ - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean @@ -240,7 +273,15 @@ jobs: run: ./run git-clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: ./run ide build --backend-source current-ci-run --gui-upload-artifact false + - name: Download project-manager + uses: actions/download-artifact@v4 + with: + name: project-manager-linux + path: dist/backend + - run: |- + tar -xvf dist/backend/project-manager.tar -C dist/backend + rm dist/backend/project-manager.tar + - run: ./run ide build --backend-source local --gui-upload-artifact false env: ENSO_IDE_AG_GRID_LICENSE_KEY: ${{ vars.ENSO_AG_GRID_LICENSE_KEY }} ENSO_IDE_API_URL: ${{ vars.ENSO_CLOUD_API_URL }} @@ -270,6 +311,11 @@ jobs: compression-level: 0 name: test-traces-linux-amd64 path: app/ide-desktop/client/test-traces + - name: Upload ide + uses: actions/upload-artifact@v4 + with: + name: ide-linux + path: dist/ide/enso-*.AppImage - run: rm $HOME/.enso/credentials env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -313,7 +359,15 @@ jobs: run: ./run git-clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: ./run ide build --backend-source current-ci-run --gui-upload-artifact false + - name: Download project-manager + uses: actions/download-artifact@v4 + with: + name: project-manager-windows + path: dist/backend + - run: |- + tar -xvf dist/backend/project-manager.tar -C dist/backend + rm dist/backend/project-manager.tar + - run: ./run ide build --backend-source local --gui-upload-artifact false env: ENSO_IDE_AG_GRID_LICENSE_KEY: ${{ vars.ENSO_AG_GRID_LICENSE_KEY }} ENSO_IDE_API_URL: ${{ vars.ENSO_CLOUD_API_URL }} @@ -344,6 +398,11 @@ jobs: compression-level: 0 name: test-traces-windows-amd64 path: app/ide-desktop/client/test-traces + - name: Upload ide + uses: actions/upload-artifact@v4 + with: + name: ide-windows + path: dist/ide/enso-*.exe - run: rm $HOME/.enso/credentials env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/wasm-changed-files.yml b/.github/workflows/wasm-changed-files.yml index fdbf1aa2b345..6998435d8222 100644 --- a/.github/workflows/wasm-changed-files.yml +++ b/.github/workflows/wasm-changed-files.yml @@ -30,7 +30,7 @@ jobs: files: | .cargo/** app/rust-ffi/** - build/** + build_tools/** lib/rust/** tools/language-server/logstat/** tools/language-server/wstest/** diff --git a/build_tools/build/examples/artifact.rs b/build_tools/build/examples/artifact.rs deleted file mode 100644 index 83e295c0b473..000000000000 --- a/build_tools/build/examples/artifact.rs +++ /dev/null @@ -1,70 +0,0 @@ -use enso_build::prelude::*; - -use ide_ci::actions::artifacts; -use ide_ci::actions::artifacts::download::ArtifactDownloader; -use ide_ci::actions::artifacts::run_session::SessionClient; -use tempfile::TempDir; - - - -#[tokio::main] -async fn main() -> Result { - let dir = std::env::current_exe()?.parent().unwrap().to_owned(); - - debug!("Will upload {}", dir.display()); - let provider = artifacts::discover_recursive(dir); - artifacts::upload(provider, "MyPrecious", default()).await?; - - - let file = std::env::current_exe()?; - debug!("Will upload {}", file.display()); - let artifact_name = file.file_name().unwrap().to_str().unwrap(); - let provider = artifacts::single_file_provider(file.clone())?; - artifacts::upload(provider, artifact_name, default()).await?; - debug!("Upload done!"); - // artifacts::upload_single_file(file, ) - - let context = artifacts::context::Context::new_from_env()?; - let session = SessionClient::new(&context)?; - - // debug!("Checking artifacts through official API"); - // let octocrab = setup_octocrab()?; - // let run_id = ide_ci::actions::env::run_id()?; - // debug!("Got run ID {run_id}"); - // let run = octocrab.workflows("enso-org", "ci-build").get(run_id).await?; - // debug!("Got run information {run:?}"); - // let artifacts = octocrab - // .actions() - // .list_workflow_run_artifacts("enso-org", "ci-build", run_id) - // .send() - // .await?; - // debug!("Got artifacts information {artifacts:?}"); - - - debug!("Checking artifacts through runtime API"); - let list = session.list_artifacts().await?; - dbg!(&list); - - let relevant_entry = list - .iter() - .find(|artifact| artifact.name == artifact_name) - .ok_or_else(|| anyhow!("Failed to find artifact by name {artifact_name}."))?; - - dbg!(&relevant_entry); - - let items = artifacts::raw::endpoints::get_container_items( - &context.json_client()?, - relevant_entry.file_container_resource_url.clone(), - &relevant_entry.name, - ) - .await?; - dbg!(&items); - - let temp = TempDir::new()?; - let downloader = ArtifactDownloader::new(session.clone(), artifact_name).await?; - downloader.download_all_to(temp.path()).await?; - - let expected_path = temp.path().join(artifact_name); - assert_eq!(std::fs::read(expected_path)?, std::fs::read(&file)?); - Ok(()) -} diff --git a/build_tools/build/src/ci_gen/job.rs b/build_tools/build/src/ci_gen/job.rs index aae178f0be32..51fa29946fc2 100644 --- a/build_tools/build/src/ci_gen/job.rs +++ b/build_tools/build/src/ci_gen/job.rs @@ -11,6 +11,7 @@ use crate::ci_gen::RunnerType; use crate::ci_gen::RELEASE_CLEANING_POLICY; use crate::engine::env as engine_env; use crate::ide::web::env as ide_env; +use crate::paths; use core::panic; use ide_ci::actions::workflow::definition::cancel_workflow_action; @@ -222,6 +223,14 @@ impl JobArchetype for JvmTests { fn job(&self, target: Target) -> Job { let graal_edition = self.graal_edition; let job_name = format!("JVM Tests ({graal_edition})"); + let test_results_dir = paths::ENSO_TEST_JUNIT_DIR + .get() + .ok() + .and_then(|buf| buf.to_str().map(|s| s.to_owned())) + .unwrap_or_else(|| "target/test-results/".to_owned()); + let _upload_artifact_job = step::upload_artifact("Upload test results") + .with_custom_argument("name", format!("Test_Results_{}", target.0)) + .with_custom_argument("path", test_results_dir); let mut job = RunStepsBuilder::new("backend test jvm") .customize(move |step| vec![step, step::engine_test_reporter(target, graal_edition)]) .build_job(job_name, target) @@ -444,7 +453,18 @@ impl JobArchetype for GuiBuild { fn job(&self, target: Target) -> Job { let command: &str = "gui build"; RunStepsBuilder::new(command) - .customize(|step| vec![expose_gui_vars(step)]) + .customize(move |step| { + let mut steps = vec![expose_gui_vars(step)]; + + if target.0 == OS::Linux { + let upload_gui = step::upload_artifact("Upload gui") + .with_custom_argument("name", "gui") + .with_custom_argument("path", "dist/gui/"); + steps.push(upload_gui); + } + + steps + }) .build_job("GUI build", target) } } @@ -465,7 +485,44 @@ pub struct BuildBackend; impl JobArchetype for BuildBackend { fn job(&self, target: Target) -> Job { - plain_job(target, "Build Backend", "backend get") + RunStepsBuilder::new("backend get") + .customize(move |step| { + let mut steps = vec![step]; + + if target.0 == OS::Linux { + let upload_edition_file = step::upload_artifact("Upload Edition File") + .with_custom_argument("name", paths::EDITION_FILE_ARTIFACT_NAME) + .with_custom_argument("path", "distribution/editions/*.yaml"); + steps.push(upload_edition_file); + + let upload_fbs_schema = step::upload_artifact("Upload fbs-schema") + .with_custom_argument("name", "fbs-schema") + .with_custom_argument("path", "engine/language-server/src/main/schema/"); + steps.push(upload_fbs_schema) + } + + let archive_project_manager = Step { + name: Some("Archive project-manager".into()), + run: Some("tar -cvf project-manager.tar -C dist/backend .".into()), + ..Default::default() + }; + steps.push(archive_project_manager); + + let upload_project_manager = step::upload_artifact("Upload project-manager") + .with_custom_argument("name", format!("project-manager-{}", target.0)) + .with_custom_argument("path", "project-manager.tar"); + steps.push(upload_project_manager); + + let cleanup = Step { + name: Some("Cleanup".into()), + run: Some("rm project-manager.tar".into()), + ..Default::default() + }; + steps.push(cleanup); + + steps + }) + .build_job("Build Backend", target) } } @@ -610,56 +667,85 @@ pub struct PackageIde; impl JobArchetype for PackageIde { fn job(&self, target: Target) -> Job { - RunStepsBuilder::new( - "ide build --backend-source current-ci-run --gui-upload-artifact false", - ) - .customize(move |step| { - let mut steps = prepare_packaging_steps(target.0, step, PackagingTarget::Development); - const TEST_COMMAND: &str = "corepack pnpm -r --filter enso exec playwright test"; - let test_step = match target.0 { - OS::Linux => shell(format!("xvfb-run {TEST_COMMAND}")) - // See https://askubuntu.com/questions/1512287/obsidian-appimage-the-suid-sandbox-helper-binary-was-found-but-is-not-configu - .with_env("ENSO_TEST_APP_ARGS", "--no-sandbox"), - - OS::MacOS => - // MacOS CI runners are very slow - shell(format!("{TEST_COMMAND} --timeout 300000")), - _ => shell(TEST_COMMAND), - }; - let test_step = test_step - .with_env("DEBUG", "pw:browser log:") - .with_secret_exposed_as(secret::ENSO_CLOUD_TEST_ACCOUNT_USERNAME, "ENSO_TEST_USER") - .with_secret_exposed_as( - secret::ENSO_CLOUD_TEST_ACCOUNT_PASSWORD, - "ENSO_TEST_USER_PASSWORD", - ); - steps.push(test_step); - - let upload_test_traces_step = Step { - r#if: Some("failure()".into()), - name: Some("Upload Test Traces".into()), - uses: Some("actions/upload-artifact@v4".into()), - with: Some(Argument::Other(BTreeMap::from_iter([ - ("name".into(), format!("test-traces-{}-{}", target.0, target.1).into()), - ("path".into(), "app/ide-desktop/client/test-traces".into()), - ("compression-level".into(), 0.into()), // The traces are in zip already. - ]))), - ..Default::default() - }; - steps.push(upload_test_traces_step); - - // After the E2E tests run, they create a credentials file in user home directory. - // If that file is not cleaned up, future runs of our tests may randomly get - // authenticated into Enso Cloud. We want to run tests as an authenticated - // user only when we explicitly set that up, not randomly. So we clean the credentials - // file. - let cloud_credentials_path = "$HOME/.enso/credentials"; - let cleanup_credentials_step = shell(format!("rm {cloud_credentials_path}")); - steps.push(cleanup_credentials_step); - - steps - }) - .build_job("Package New IDE", target) + RunStepsBuilder::new("ide build --backend-source local --gui-upload-artifact false") + .customize(move |step| { + let mut steps = vec![]; + + let download_project_manager = step::download_artifact("Download project-manager") + .with_custom_argument("name", format!("project-manager-{}", target.0)) + .with_custom_argument("path", "dist/backend"); + steps.push(download_project_manager); + + let unpack_project_manager = Step { + run: Some( + "tar -xvf dist/backend/project-manager.tar -C dist/backend +rm dist/backend/project-manager.tar" + .into(), + ), + ..Default::default() + }; + steps.push(unpack_project_manager); + + let mut packaging_steps = + prepare_packaging_steps(target.0, step, PackagingTarget::Development); + steps.append(&mut packaging_steps); + + const TEST_COMMAND: &str = "corepack pnpm -r --filter enso exec playwright test"; + let test_step = match target.0 { + OS::Linux => shell(format!("xvfb-run {TEST_COMMAND}")) + // See https://askubuntu.com/questions/1512287/obsidian-appimage-the-suid-sandbox-helper-binary-was-found-but-is-not-configu + .with_env("ENSO_TEST_APP_ARGS", "--no-sandbox"), + + OS::MacOS => + // MacOS CI runners are very slow + shell(format!("{TEST_COMMAND} --timeout 300000")), + _ => shell(TEST_COMMAND), + }; + let test_step = test_step + .with_env("DEBUG", "pw:browser log:") + .with_secret_exposed_as( + secret::ENSO_CLOUD_TEST_ACCOUNT_USERNAME, + "ENSO_TEST_USER", + ) + .with_secret_exposed_as( + secret::ENSO_CLOUD_TEST_ACCOUNT_PASSWORD, + "ENSO_TEST_USER_PASSWORD", + ); + steps.push(test_step); + + let upload_test_traces_step = Step { + r#if: Some("failure()".into()), + name: Some("Upload Test Traces".into()), + uses: Some("actions/upload-artifact@v4".into()), + with: Some(Argument::Other(BTreeMap::from_iter([ + ("name".into(), format!("test-traces-{}-{}", target.0, target.1).into()), + ("path".into(), "app/ide-desktop/client/test-traces".into()), + ("compression-level".into(), 0.into()), // The traces are in zip already. + ]))), + ..Default::default() + }; + steps.push(upload_test_traces_step); + + let upload_ide = step::upload_artifact("Upload ide") + .with_custom_argument("name", format!("ide-{}", target.0)) + .with_custom_argument( + "path", + format!("dist/ide/enso-*.{}", target.0.package_extension()), + ); + steps.push(upload_ide); + + // After the E2E tests run, they create a credentials file in user home directory. + // If that file is not cleaned up, future runs of our tests may randomly get + // authenticated into Enso Cloud. We want to run tests as an authenticated + // user only when we explicitly set that up, not randomly. So we clean the + // credentials file. + let cloud_credentials_path = "$HOME/.enso/credentials"; + let cleanup_credentials_step = shell(format!("rm {cloud_credentials_path}")); + steps.push(cleanup_credentials_step); + + steps + }) + .build_job("Package New IDE", target) } } diff --git a/build_tools/build/src/ci_gen/step.rs b/build_tools/build/src/ci_gen/step.rs index 788731f02e58..48e81ef7b991 100644 --- a/build_tools/build/src/ci_gen/step.rs +++ b/build_tools/build/src/ci_gen/step.rs @@ -49,3 +49,19 @@ pub fn extra_stdlib_test_reporter((os, arch): Target, graal_edition: graalvm::Ed let path = format!("{}/*/*.xml", env_expression(&paths::ENSO_TEST_JUNIT_DIR)); test_reporter(step_name, report_name, path) } + +pub fn upload_artifact(step_name: impl Into) -> Step { + Step { + name: Some(step_name.into()), + uses: Some("actions/upload-artifact@v4".into()), + ..default() + } +} + +pub fn download_artifact(step_name: impl Into) -> Step { + Step { + name: Some(step_name.into()), + uses: Some("actions/download-artifact@v4".into()), + ..default() + } +} diff --git a/build_tools/build/src/engine/context.rs b/build_tools/build/src/engine/context.rs index 059e4d5a13df..96019ba92926 100644 --- a/build_tools/build/src/engine/context.rs +++ b/build_tools/build/src/engine/context.rs @@ -220,35 +220,6 @@ 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() { @@ -267,29 +238,13 @@ impl RunContext { ide_ci::fs::remove_glob(bench_report_xml)?; } - - let _test_results_upload_guard = - if self.config.test_jvm || self.config.test_standard_library.is_some() { - // If we run tests, make sure that old and new results won't end up mixed together. - let test_results_dir = ENSO_TEST_JUNIT_DIR - .get() - .unwrap_or_else(|_| self.paths.repo_root.target.test_results.path.clone()); - ide_ci::fs::reset_dir(&test_results_dir)?; - - // If we are run in CI conditions and we prepared some test results, we want to - // upload them as a separate artifact to ease debugging. And we do want to do that - // even if the tests fail and we are leaving the scope with an error. - is_in_env().then(|| { - scopeguard::guard(test_results_dir, |test_results_dir| { - ide_ci::global::spawn( - "Upload test results", - upload_test_results(test_results_dir), - ); - }) - }) - } else { - None - }; + if self.config.test_jvm || self.config.test_standard_library.is_some() { + // If we run tests, make sure that old and new results won't end up mixed together. + let test_results_dir = ENSO_TEST_JUNIT_DIR + .get() + .unwrap_or_else(|_| self.paths.repo_root.target.test_results.path.clone()); + ide_ci::fs::reset_dir(&test_results_dir)?; + }; // Workaround for incremental compilation issue, as suggested by kustosz. // We target files like @@ -460,8 +415,6 @@ impl RunContext { } if is_in_env() { - self.upload_native_image_arg_files().await?; - // If we were running any benchmarks, they are complete by now. Upload the report. for bench in &self.config.execute_benchmarks { match bench { @@ -553,24 +506,6 @@ impl RunContext { } } - if self.config.build_engine_package { - if TARGET_OS == OS::Linux && ide_ci::ci::run_in_ci() { - self.paths.upload_edition_file_artifact().await?; - } - - let schema_dir = self.paths.repo_root.join_iter([ - "engine", - "language-server", - "src", - "main", - "schema", - ]); - if is_in_env() { - ide_ci::actions::artifacts::upload_compressed_directory(&schema_dir, "fbs-schema") - .await?; - } - } - let graal_version = engine::deduce_graal_bundle(&self.repo_root.build_sbt).await?; for bundle in ret.bundles() { bundle.create(&self.repo_root, &graal_version).await?; diff --git a/build_tools/build/src/engine/env.rs b/build_tools/build/src/engine/env.rs index d7133e1c0590..03e467201656 100644 --- a/build_tools/build/src/engine/env.rs +++ b/build_tools/build/src/engine/env.rs @@ -1,6 +1,7 @@ //! Environment variables used by the engine's SBT-based build system. //use crate::prelude::*; + use crate::engine; use ide_ci::cache::goodie::graalvm; diff --git a/build_tools/build/src/paths.rs b/build_tools/build/src/paths.rs index 2ec8057ce856..849d81a94e5b 100644 --- a/build_tools/build/src/paths.rs +++ b/build_tools/build/src/paths.rs @@ -166,14 +166,6 @@ impl Paths { self.repo_root.distribution.editions.edition_yaml.to_path_buf() } - pub async fn upload_edition_file_artifact(&self) -> Result { - ide_ci::actions::artifacts::upload_single_file( - self.edition_file(), - EDITION_FILE_ARTIFACT_NAME, - ) - .await - } - pub async fn download_edition_file_artifact(&self) -> Result { ide_ci::actions::artifacts::download_single_file_artifact( EDITION_FILE_ARTIFACT_NAME, diff --git a/build_tools/build/src/project.rs b/build_tools/build/src/project.rs index d316b9c1252f..0ad54edb6457 100644 --- a/build_tools/build/src/project.rs +++ b/build_tools/build/src/project.rs @@ -14,7 +14,6 @@ use crate::source::WithDestination; use ide_ci::actions::artifacts; use ide_ci::cache; use ide_ci::cache::Cache; -use ide_ci::ok_ready_boxed; use ide_ci::programs::git; use octocrab::models::repos::Asset; @@ -167,32 +166,16 @@ pub trait IsTarget: Clone + Debug + Sized + Send + Sync + 'static { job: BuildTargetJob, ) -> BoxFuture<'static, Result> { let span = debug_span!("Building.", ?self, ?context, ?job).entered(); - let upload_artifacts = job.should_upload_artifact; let artifact_fut = self.build_internal(context, job.map(|job| job.input)); let this = self.clone(); async move { let artifact = artifact_fut.await.context(format!("Failed to build {this:?}."))?; - // We upload only built artifacts. There would be no point in uploading something that - // we've just downloaded. That's why the uploading code is here. - if upload_artifacts { - this.perhaps_upload_artifact(&artifact).await?; - } Ok(artifact) } .instrument(span.exit()) .boxed() } - fn perhaps_upload_artifact(&self, artifact: &Self::Artifact) -> BoxFuture<'static, Result> { - let should_upload_artifact = ide_ci::actions::workflow::is_in_env(); - trace!("Got target {:?}, should it be uploaded? {}", self, should_upload_artifact); - if should_upload_artifact { - self.upload_artifact(ready(Ok(artifact.clone()))) - } else { - ok_ready_boxed(()) - } - } - /// Produce an artifact from build inputs. fn build_internal( &self, @@ -200,15 +183,6 @@ pub trait IsTarget: Clone + Debug + Sized + Send + Sync + 'static { job: WithDestination, ) -> BoxFuture<'static, Result>; - /// Upload artifact to the current GitHub Actions run. - fn upload_artifact( - &self, - output: impl Future> + Send + 'static, - ) -> BoxFuture<'static, Result> { - let name = self.artifact_name(); - async move { artifacts::upload_compressed_directory(output.await?, name).await }.boxed() - } - fn download_artifact( &self, context: Context, diff --git a/build_tools/build/src/project/gui.rs b/build_tools/build/src/project/gui.rs index ae6a55f72342..0e1734a776bf 100644 --- a/build_tools/build/src/project/gui.rs +++ b/build_tools/build/src/project/gui.rs @@ -12,6 +12,7 @@ use crate::project::Context; use crate::project::IsArtifact; use crate::project::IsTarget; use crate::source::WithDestination; + use ide_ci::ok_ready_boxed; use ide_ci::programs::Pnpm; diff --git a/build_tools/build/src/project/ide.rs b/build_tools/build/src/project/ide.rs index 840f6cdf6695..171316fd5b6c 100644 --- a/build_tools/build/src/project/ide.rs +++ b/build_tools/build/src/project/ide.rs @@ -4,10 +4,6 @@ use crate::prelude::*; use crate::project::gui::ide_desktop_from_context; use crate::project::Context; -use ide_ci::actions::artifacts::upload_compressed_directory; -use ide_ci::actions::artifacts::upload_single_file; -use ide_ci::actions::workflow::is_in_env; - #[derive(Clone, Debug)] @@ -47,20 +43,6 @@ impl Artifact { } } - pub async fn upload_as_ci_artifact(&self, prefix: impl AsRef) -> Result { - if is_in_env() { - let prefix = prefix.as_ref(); - upload_compressed_directory(&self.unpacked, format!("{prefix}-unpacked-{TARGET_OS}")) - .await?; - let packed_artifact_name = format!("{prefix}-{TARGET_OS}"); - upload_single_file(&self.image, &packed_artifact_name).await?; - upload_single_file(&self.image_checksum, &packed_artifact_name).await?; - } else { - info!("Not in the CI environment, will not upload the artifacts.") - } - Ok(()) - } - pub fn start_unpacked( &self, extra_ide_options: impl IntoIterator>, diff --git a/build_tools/build/src/project/wasm/test.rs b/build_tools/build/src/project/wasm/test.rs index 356e9de70688..374879d78130 100644 --- a/build_tools/build/src/project/wasm/test.rs +++ b/build_tools/build/src/project/wasm/test.rs @@ -24,7 +24,7 @@ pub const PACKAGE_BLACKLIST: [&str; 1] = ["integration-test"]; pub const WASM_TEST_ATTRIBUTES: [&str; 2] = ["#[wasm_bindgen_test]", "#[wasm_bindgen_test(async)]"]; /// Subdirectories in the crate directory that contain sources for the crate. -pub const SOURCE_SUBDIRECTORIES: [&str; 4] = ["src", "benches", "examples", "tests"]; +pub const SOURCE_SUBDIRECTORIES: [&str; 3] = ["src", "benches", "tests"]; // =============== // === Browser === diff --git a/build_tools/build/src/source.rs b/build_tools/build/src/source.rs index 9b66c10d2fea..760d477c9bc3 100644 --- a/build_tools/build/src/source.rs +++ b/build_tools/build/src/source.rs @@ -28,9 +28,7 @@ impl ExternalSource { #[derive(Clone, Debug)] pub struct BuildSource { /// Data needed to build the target. - pub input: Target::BuildInput, - /// Whether to upload the resulting artifact as CI artifact. - pub should_upload_artifact: bool, + pub input: Target::BuildInput, } /// Describes how to get a target. diff --git a/build_tools/ci_utils/src/actions/artifacts.rs b/build_tools/ci_utils/src/actions/artifacts.rs index 178d3aca611c..beedddad6a3d 100644 --- a/build_tools/ci_utils/src/actions/artifacts.rs +++ b/build_tools/ci_utils/src/actions/artifacts.rs @@ -66,7 +66,7 @@ pub fn discover_recursive( } -pub fn upload( +fn upload( file_provider: impl Stream + Send + 'static, artifact_name: impl Into, options: UploadOptions, diff --git a/build_tools/ci_utils/src/actions/workflow/definition.rs b/build_tools/ci_utils/src/actions/workflow/definition.rs index 0746363d0fe5..07e62b4013c9 100644 --- a/build_tools/ci_utils/src/actions/workflow/definition.rs +++ b/build_tools/ci_utils/src/actions/workflow/definition.rs @@ -1,12 +1,11 @@ //! Model of a workflow definition and related utilities. -use serde_yaml::Value; - use crate::prelude::*; use crate::convert_case::ToKebabCase; use crate::env::accessor::RawVariable; +use serde_yaml::Value; use std::collections::btree_map::Entry; use std::collections::BTreeMap; use std::sync::atomic::AtomicU64; diff --git a/build_tools/ci_utils/src/os/target.rs b/build_tools/ci_utils/src/os/target.rs index 9467be2232a5..02818f5dd476 100644 --- a/build_tools/ci_utils/src/os/target.rs +++ b/build_tools/ci_utils/src/os/target.rs @@ -80,6 +80,14 @@ impl OS { OS::MacOS => "", } } + + pub const fn package_extension(self) -> &'static str { + match self { + OS::Windows => "exe", + OS::Linux => "AppImage", + OS::MacOS => "dmg", + } + } } #[cfg(test)] diff --git a/build_tools/cli/src/lib.rs b/build_tools/cli/src/lib.rs index 2866d5a6b864..5f3b2aaba2d5 100644 --- a/build_tools/cli/src/lib.rs +++ b/build_tools/cli/src/lib.rs @@ -134,12 +134,9 @@ impl Processor { { let span = info_span!("Resolving.", ?target, ?source).entered(); let destination = source.output_path.output_path; - let should_upload_artifact = source.build_args.upload_artifact; let source = match source.source { arg::SourceKind::Build => T::resolve(self, source.build_args.input) - .map_ok(move |input| { - Source::BuildLocally(BuildSource { input, should_upload_artifact }) - }) + .map_ok(move |input| Source::BuildLocally(BuildSource { input })) .boxed(), arg::SourceKind::Local => ok_ready_boxed(Source::External(ExternalSource::LocalFile(source.path))), @@ -209,16 +206,10 @@ impl Processor { &self, job: BuildJob, ) -> BoxFuture<'static, Result>> { - let BuildJob { input: BuildDescription { input, upload_artifact }, output_path } = job; + let BuildJob { input: BuildDescription { input, .. }, output_path } = job; let input = self.resolve_inputs::(input); async move { - Ok(WithDestination::new( - BuildSource { - input: input.await?, - should_upload_artifact: upload_artifact, - }, - output_path.output_path, - )) + Ok(WithDestination::new(BuildSource { input: input.await? }, output_path.output_path)) } .boxed() } @@ -551,16 +542,7 @@ impl Processor { }; let target = Ide { target_os: self.triple.os, target_arch: self.triple.arch }; - let artifact_name_prefix = input.artifact_name.clone(); - let build_job = target.build(&self.context, input, output_path); - async move { - let artifacts = build_job.await?; - if is_in_env() { - artifacts.upload_as_ci_artifact(artifact_name_prefix).await?; - } - Ok(artifacts) - } - .boxed() + target.build(&self.context, input, output_path) } pub fn target(&self) -> Result {