feat: buildpacks worker process fallback

This commit is contained in:
Patryk Jeziorowski
2021-08-12 08:35:37 +02:00
parent e9f7145fe5
commit b7318adfae
2 changed files with 66 additions and 5 deletions

View File

@@ -1,3 +1,10 @@
use std::{env, fs};
use std::path::Path;
use chrono::Duration;
use sysinfo::{Disk, DiskExt, SystemExt};
use crate::{cmd, git};
use crate::build_platform::{Build, BuildPlatform, BuildResult, Image, Kind};
use crate::error::{EngineError, EngineErrorCause, SimpleError, SimpleErrorKind};
use crate::fs::workspace_directory;
@@ -5,11 +12,6 @@ use crate::git::checkout_submodules;
use crate::models::{
Context, Listen, Listener, Listeners, ListenersHelper, ProgressInfo, ProgressLevel, ProgressScope,
};
use crate::{cmd, git};
use chrono::Duration;
use std::env;
use std::path::Path;
use sysinfo::{Disk, DiskExt, SystemExt};
const BUILD_DURATION_TIMEOUT_MIN: i64 = 30;
@@ -194,6 +196,16 @@ impl LocalDocker {
buildpacks_args.push("-B");
buildpacks_args.push(builder_name);
// Just a fallback for now to help our bot loving users deploy their apps
// Long term solution requires lots of changes in UI and Core as well
// And passing some params to the engine
if let Ok(content) = fs::read_to_string(into_dir_docker_style.clone().to_owned() + "/Procfile") {
if content.contains("worker") {
buildpacks_args.push("--default-process");
buildpacks_args.push("worker");
}
}
// buildpacks build
exit_status = cmd::utilities::exec_with_envs_and_output(
"pack",

View File

@@ -252,6 +252,55 @@ fn build_with_buildpacks_and_deploy_a_working_environment() {
})
}
#[cfg(feature = "test-aws-self-hosted")]
#[named]
#[test]
fn build_worker_with_buildpacks_and_deploy_a_working_environment() {
let test_name = function_name!();
engine_run_test(|| {
init();
let span = span!(Level::INFO, "test", name = test_name);
let _enter = span.enter();
let context = context();
let context_for_deletion = context.clone_not_same_execution_id();
let secrets = FuncTestsSecrets::new();
let mut environment = test_utilities::aws::working_minimal_environment(&context, secrets);
environment.applications = environment
.applications
.into_iter()
.map(|mut app| {
app.private_port = None;
app.commit_id = "4f35f4ab3e98426c5a3eaa91e788ff8ab466f19a".to_string();
app.branch = "buildpack-process".to_string();
app.dockerfile_path = None;
app
})
.collect::<Vec<qovery_engine::models::Application>>();
let mut environment_delete = environment.clone();
environment_delete.action = Action::Delete;
let ea = EnvironmentAction::Environment(environment);
let ea_delete = EnvironmentAction::Environment(environment_delete);
match deploy_environment(&context, &ea) {
TransactionResult::Ok => assert!(true),
TransactionResult::Rollback(_) => assert!(false),
TransactionResult::UnrecoverableError(_, _) => assert!(false),
};
match delete_environment(&context_for_deletion, &ea_delete) {
TransactionResult::Ok => assert!(true),
TransactionResult::Rollback(_) => assert!(false),
TransactionResult::UnrecoverableError(_, _) => assert!(false),
};
return test_name.to_string();
})
}
#[cfg(feature = "test-aws-self-hosted")]
#[named]
#[test]