Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a packaged engine when running projects #7912

Closed
66 changes: 28 additions & 38 deletions app/gui/controller/engine-protocol/src/project_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,13 @@ impl From<ProjectNormalizedName> for ImString {
#[serde(rename_all = "camelCase")]
pub struct ProjectMetadata {
/// Project's name.
pub name: ProjectName,
pub name: ProjectName,
/// Project's namespace,
pub namespace: String,
pub namespace: String,
/// Project's uuid.
pub id: Uuid,
/// Engine version to use for the project, represented by a semver version string.
pub engine_version: Option<String>,
pub id: Uuid,
/// Last time the project was opened.
pub last_opened: Option<UTCDateTime>,
pub last_opened: Option<UTCDateTime>,
}

/// This type specifies what action should be taken if an Engine's component required to complete
Expand Down Expand Up @@ -319,33 +317,29 @@ mod mock_client_tests {
fn list_projects() {
let mock_client = MockClient::default();
let project1 = ProjectMetadata {
name: ProjectName::new_unchecked("project1"),
id: Uuid::default(),
last_opened: Some(DateTime::parse_from_rfc3339("2020-01-07T21:25:26Z").unwrap()),
engine_version: Some("0.2.21".to_owned()),
namespace: "local".to_owned(),
name: ProjectName::new_unchecked("project1"),
id: Uuid::default(),
last_opened: Some(DateTime::parse_from_rfc3339("2020-01-07T21:25:26Z").unwrap()),
namespace: "local".to_owned(),
};
let project2 = ProjectMetadata {
name: ProjectName::new_unchecked("project2"),
id: Uuid::default(),
last_opened: Some(DateTime::parse_from_rfc3339("2020-02-02T13:15:20Z").unwrap()),
engine_version: Some("0.2.22".to_owned()),
namespace: "local".to_owned(),
name: ProjectName::new_unchecked("project2"),
id: Uuid::default(),
last_opened: Some(DateTime::parse_from_rfc3339("2020-02-02T13:15:20Z").unwrap()),
namespace: "local".to_owned(),
};
let expected_recent_projects = response::ProjectList { projects: vec![project1, project2] };
let sample1 = ProjectMetadata {
name: ProjectName::new_unchecked("sample1"),
id: Uuid::default(),
last_opened: Some(DateTime::parse_from_rfc3339("2019-11-23T05:30:12Z").unwrap()),
engine_version: Some("0.2.21".to_owned()),
namespace: "test".to_owned(),
name: ProjectName::new_unchecked("sample1"),
id: Uuid::default(),
last_opened: Some(DateTime::parse_from_rfc3339("2019-11-23T05:30:12Z").unwrap()),
namespace: "test".to_owned(),
};
let sample2 = ProjectMetadata {
name: ProjectName::new_unchecked("sample2"),
id: Uuid::default(),
last_opened: Some(DateTime::parse_from_rfc3339("2019-12-25T00:10:58Z").unwrap()),
engine_version: Some("0.2.21".to_owned()),
namespace: "test".to_owned(),
name: ProjectName::new_unchecked("sample2"),
id: Uuid::default(),
last_opened: Some(DateTime::parse_from_rfc3339("2019-12-25T00:10:58Z").unwrap()),
namespace: "test".to_owned(),
};
let expected_sample_projects = response::ProjectList { projects: vec![sample1, sample2] };
expect_call!(mock_client.list_projects(count=Some(2)) =>
Expand Down Expand Up @@ -483,18 +477,16 @@ mod remote_client_tests {
let number_of_projects_json = json!({ "numberOfProjects": number_of_projects });
let num_projects_json = json!({ "numProjects": number_of_projects });
let project1 = ProjectMetadata {
name: ProjectName::new_unchecked("project1"),
id: Uuid::default(),
last_opened: Some(DateTime::parse_from_rfc3339("2020-01-07T21:25:26Z").unwrap()),
engine_version: Some("0.2.21".to_owned()),
namespace: "local".to_owned(),
name: ProjectName::new_unchecked("project1"),
id: Uuid::default(),
last_opened: Some(DateTime::parse_from_rfc3339("2020-01-07T21:25:26Z").unwrap()),
namespace: "local".to_owned(),
};
let project2 = ProjectMetadata {
name: ProjectName::new_unchecked("project2"),
id: Uuid::default(),
last_opened: Some(DateTime::parse_from_rfc3339("2020-02-02T13:15:20Z").unwrap()),
engine_version: Some("0.2.22".to_owned()),
namespace: "local".to_owned(),
name: ProjectName::new_unchecked("project2"),
id: Uuid::default(),
last_opened: Some(DateTime::parse_from_rfc3339("2020-02-02T13:15:20Z").unwrap()),
namespace: "local".to_owned(),
};
let project_list = response::ProjectList { projects: vec![project1, project2] };
let project_list_json = json!({
Expand All @@ -503,14 +495,12 @@ mod remote_client_tests {
"id" : "00000000-0000-0000-0000-000000000000",
"lastOpened" : "2020-01-07T21:25:26+00:00",
"name" : "project1",
"engineVersion" : "0.2.21",
"namespace" : "local"
},
{
"id" : "00000000-0000-0000-0000-000000000000",
"lastOpened" : "2020-02-02T13:15:20+00:00",
"name" : "project2",
"engineVersion" : "0.2.22",
"namespace" : "local"
}
]
Expand Down
9 changes: 4 additions & 5 deletions app/gui/src/ide/initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,10 @@ mod test {
let mock_client = project_manager::MockClient::default();
let project_name = ProjectName::new_unchecked("TestProject");
let project = project_manager::ProjectMetadata {
name: project_name.clone(),
id: uuid::Uuid::new_v4(),
last_opened: default(),
engine_version: Some("127.0.01".to_owned()),
namespace: "local".to_owned(),
name: project_name.clone(),
id: Uuid::new_v4(),
last_opened: default(),
namespace: "local".to_owned(),
};
let expected_id = project.id;
let projects = vec![project];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,11 @@ class JsonConnectionController(
receiver ! ResponseResult(
InitProtocolConnection,
request.id,
InitProtocolConnection.Result(allRoots.map(_.toContentRoot).toSet)
InitProtocolConnection.Result(
buildinfo.Info.ensoVersion,
buildinfo.Info.currentEdition,
allRoots.map(_.toContentRoot).toSet
)
)

initialize(webActor, rpcSession)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ object SessionApi {

case class Params(clientId: UUID)

case class Result(contentRoots: Set[ContentRoot])
case class Result(
ensoVersion: String,
currentEdition: String,
contentRoots: Set[ContentRoot]
)

implicit
val hasParams: HasParams.Aux[this.type, InitProtocolConnection.Params] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ object GlobalConfigurationManager {
val globalConfigName: String = "global-config.yaml"

/** Tries to read the global config from the given `path`. */
def readConfig(path: Path): Try[GlobalConfig] =
private def readConfig(path: Path): Try[GlobalConfig] =
Using(Files.newBufferedReader(path)) { reader =>
for {
json <- yaml.parser.parse(reader)
Expand All @@ -91,15 +91,15 @@ object GlobalConfigurationManager {
}.flatMap(_.toTry)

/** Tries to write the provided `config` to the given `path`. */
def writeConfig(path: Path, config: GlobalConfig): Try[Unit] =
private def writeConfig(path: Path, config: GlobalConfig): Try[Unit] =
writeConfigRaw(path, GlobalConfig.encoder(config))

/** Tries to write the config from a raw JSON value to the given `path`.
*
* The config will not be saved if it is invalid, instead an exception is
* thrown.
*/
def writeConfigRaw(path: Path, rawConfig: Json): Try[Unit] = {
private def writeConfigRaw(path: Path, rawConfig: Json): Try[Unit] = {
def verifyConfig: Try[Unit] =
rawConfig.as[GlobalConfig] match {
case Left(failure) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,18 @@ package org.enso.projectmanager.data
import java.time.OffsetDateTime
import java.util.UUID

import nl.gn0s1s.bump.SemVer

/** Contains project metadata.
*
* @param name the name of the project
* @param namespace the namespace of the project
* @param id the project id
* @param engineVersion version of the engine associated with the project, it
* may be missing if project's edition could not be loaded
* @param created the project creation time
* @param lastOpened the last opened datetime
*/
case class ProjectMetadata(
name: String,
namespace: String,
id: UUID,
engineVersion: Option[SemVer],
created: OffsetDateTime,
lastOpened: Option[OffsetDateTime]
)
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ class HeartbeatSession(
if (quietErrors) {
logger.debug(s"$message ($throwable)", arg)
} else {
logger.error(s"$message {}", arg, throwable.getMessage)
logger.error(s"$message {}", arg, throwable)
}
}

private def logError(throwable: Throwable, message: String): Unit = {
if (quietErrors) {
logger.debug(s"$message ($throwable)")
logger.debug(s"$message ({})", throwable.getMessage)
} else {
logger.error(message, throwable)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ object ProjectCreateHandler {

/** Creates a configuration object used to create a [[ProjectCreateHandler]].
*
* @param configurationService
* @param configurationService a global configuration service
* @param projectService a project service
* @param requestTimeout a request timeout
* @param timeoutRetries a number of timeouts to wait until a failure is reported
Expand Down
Loading
Loading