add AppMode for best boundaries over stdlib
JaCoCo Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 61.98% (17344/27983)
* Branch Coverage: 53.07% (6720/12663)
* Lines of Code: 27983
* Cyclomatic Complexity: 11207
#### Quality Gates Summary
Output truncated.
Test / Build skipped: 11, passed: 581
Intrepid/Prometeu/Studio/pipeline/head This commit looks good
Intrepid/Prometeu/Studio/pipeline/pr-master This commit looks good
JaCoCo Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 61.98% (17344/27983)
* Branch Coverage: 53.07% (6720/12663)
* Lines of Code: 27983
* Cyclomatic Complexity: 11207
#### Quality Gates Summary
Output truncated.
Test / Build skipped: 11, passed: 581
Intrepid/Prometeu/Studio/pipeline/head This commit looks good
Intrepid/Prometeu/Studio/pipeline/pr-master This commit looks good
This commit is contained in:
+1
@@ -10,6 +10,7 @@ public record PrometeuManifestDTO(
|
||||
String version,
|
||||
String language,
|
||||
String stdlib,
|
||||
String target,
|
||||
List<DependencyDeclaration> dependencies) {
|
||||
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION)
|
||||
|
||||
+3
-1
@@ -1,5 +1,6 @@
|
||||
package p.studio.compiler.models;
|
||||
|
||||
import p.studio.AppMode;
|
||||
import p.studio.compiler.exceptions.BuildException;
|
||||
import p.studio.compiler.messages.DependencyConfig;
|
||||
import p.studio.compiler.source.identifiers.ProjectId;
|
||||
@@ -23,6 +24,7 @@ public final class DependencyContext {
|
||||
public Path mainProjectRootPathCanon;
|
||||
public FrontendSpec frontendSpec;
|
||||
public Integer rootStdlib;
|
||||
public AppMode target;
|
||||
public ProjectId rootProjectId;
|
||||
public BuildStack stack;
|
||||
|
||||
@@ -51,7 +53,7 @@ public final class DependencyContext {
|
||||
}
|
||||
final var dependenciesByProject = buildDependenciesByProject();
|
||||
final var workspaceGraph = new WorkspaceGraph(projectTable, dependenciesByProject);
|
||||
return new ResolvedWorkspace(rootProjectId, frontendSpec, rootStdlib, workspaceGraph, stack);
|
||||
return new ResolvedWorkspace(rootProjectId, frontendSpec, rootStdlib, target, workspaceGraph, stack);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
@@ -1,5 +1,6 @@
|
||||
package p.studio.compiler.models;
|
||||
|
||||
import p.studio.AppMode;
|
||||
import p.studio.compiler.workspaces.DependencyReference;
|
||||
import p.studio.utilities.structures.ReadOnlyList;
|
||||
|
||||
@@ -8,5 +9,6 @@ public record PrometeuManifest(
|
||||
String version,
|
||||
String language,
|
||||
int stdlib,
|
||||
AppMode target,
|
||||
ReadOnlyList<DependencyReference> dependencies) {
|
||||
}
|
||||
|
||||
+2
@@ -1,11 +1,13 @@
|
||||
package p.studio.compiler.models;
|
||||
|
||||
import p.studio.AppMode;
|
||||
import p.studio.compiler.source.identifiers.ProjectId;
|
||||
|
||||
public record ResolvedWorkspace(
|
||||
ProjectId mainProjectId,
|
||||
FrontendSpec frontendSpec,
|
||||
int stdlib,
|
||||
AppMode target,
|
||||
WorkspaceGraph graph,
|
||||
BuildStack stack) {
|
||||
public ProjectDescriptor mainProject() {
|
||||
|
||||
+14
-1
@@ -2,7 +2,9 @@ package p.studio.compiler.utilities;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import p.studio.AppMode;
|
||||
import p.studio.compiler.FrontendRegistryService;
|
||||
import p.studio.compiler.dtos.PrometeuManifestDTO;
|
||||
import p.studio.compiler.messages.BuildingIssueSink;
|
||||
@@ -45,7 +47,18 @@ public final class PrometeuManifestUtils {
|
||||
.error(true)
|
||||
.message("[DEPS]: manifest missing 'version': " + manifestPathCanon));
|
||||
}
|
||||
if (StringUtils.isBlank(dto.target())) {
|
||||
issuesLocal.report(builder -> builder
|
||||
.error(true)
|
||||
.message("[DEPS]: manifest missing 'target': " + manifestPathCanon));
|
||||
}
|
||||
final var stdlibMaybe = parseStdlib(dto.stdlib(), manifestPathCanon, issuesLocal);
|
||||
final var target = EnumUtils.getEnum(AppMode.class, dto.target());
|
||||
if (target == null) {
|
||||
issuesLocal.report(builder -> builder
|
||||
.error(true)
|
||||
.message("[DEPS]: invalid 'target' \"" + dto.target() + "\": " + manifestPathCanon));
|
||||
}
|
||||
final var language = StringUtils.isBlank(dto.language())
|
||||
? FrontendRegistryService.getDefaultFrontendSpec().getLanguageId()
|
||||
: dto.language();
|
||||
@@ -54,7 +67,7 @@ public final class PrometeuManifestUtils {
|
||||
issues.merge(issuesLocal);
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(new PrometeuManifest(dto.name(), dto.version(), language, stdlibMaybe.getAsInt(), ReadOnlyList.wrap(dependencies)));
|
||||
return Optional.of(new PrometeuManifest(dto.name(), dto.version(), language, stdlibMaybe.getAsInt(), target, ReadOnlyList.wrap(dependencies)));
|
||||
}
|
||||
|
||||
private static OptionalInt parseStdlib(
|
||||
|
||||
+1
@@ -53,6 +53,7 @@ public class DiscoverPhase implements DependencyPhase {
|
||||
}
|
||||
if (rootPathCanon.equals(ctx.mainProjectRootPathCanon)) {
|
||||
ctx.rootStdlib = manifest.get().stdlib();
|
||||
ctx.target = manifest.get().target();
|
||||
}
|
||||
final var frontendSpec = FrontendRegistryService.getFrontendSpec(manifest.get().language());
|
||||
// Returns empty when language is unknown
|
||||
|
||||
+1
@@ -89,6 +89,7 @@ public final class WireProjectsPhase implements DependencyPhase {
|
||||
.rootPath(projectInfo.rootDirectory)
|
||||
.name(projectInfo.manifest.name())
|
||||
.version(projectInfo.manifest.version())
|
||||
.target(projectInfo.manifest.target())
|
||||
.sourceRoots(ReadOnlyList.wrap(sourceRoots))
|
||||
.build();
|
||||
}
|
||||
|
||||
+42
@@ -23,6 +23,7 @@ class PrometeuManifestUtilsTest {
|
||||
"version": "1.0.0",
|
||||
"language": "pbs",
|
||||
"stdlib": "1",
|
||||
"target": "Game",
|
||||
"dependencies": []
|
||||
}
|
||||
""");
|
||||
@@ -74,6 +75,47 @@ class PrometeuManifestUtilsTest {
|
||||
assertTrue(issues.asCollection().stream().anyMatch(issue -> issue.getMessage().contains("invalid 'stdlib'")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildManifestRejectsNoTarget() throws IOException {
|
||||
final var manifestPath = writeManifest("""
|
||||
{
|
||||
"name": "main",
|
||||
"version": "1.0.0",
|
||||
"language": "pbs",
|
||||
"stdlib": "1",
|
||||
"dependencies": []
|
||||
}
|
||||
""");
|
||||
|
||||
final var issues = BuildingIssueSink.empty();
|
||||
final var manifest = PrometeuManifestUtils.buildManifest(tempDir, manifestPath, issues);
|
||||
|
||||
assertTrue(manifest.isEmpty());
|
||||
assertTrue(issues.hasErrors());
|
||||
assertTrue(issues.asCollection().stream().anyMatch(issue -> issue.getMessage().contains("missing 'target'")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildManifestRejectsInvalidTarget() throws IOException {
|
||||
final var manifestPath = writeManifest("""
|
||||
{
|
||||
"name": "main",
|
||||
"version": "1.0.0",
|
||||
"language": "pbs",
|
||||
"stdlib": "1",
|
||||
"target": "UnknownTarget",
|
||||
"dependencies": []
|
||||
}
|
||||
""");
|
||||
|
||||
final var issues = BuildingIssueSink.empty();
|
||||
final var manifest = PrometeuManifestUtils.buildManifest(tempDir, manifestPath, issues);
|
||||
|
||||
assertTrue(manifest.isEmpty());
|
||||
assertTrue(issues.hasErrors());
|
||||
assertTrue(issues.asCollection().stream().anyMatch(issue -> issue.getMessage().contains("invalid 'target'")));
|
||||
}
|
||||
|
||||
private Path writeManifest(final String content) throws IOException {
|
||||
final var manifestPath = tempDir.resolve("prometeu.json");
|
||||
Files.writeString(manifestPath, content);
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@ package p.studio.compiler.workspaces.phases;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import p.studio.AppMode;
|
||||
import p.studio.compiler.messages.DependencyConfig;
|
||||
import p.studio.compiler.models.DependencyContext;
|
||||
import p.studio.compiler.models.ProjectDescriptor;
|
||||
@@ -66,7 +67,7 @@ class StackPhaseTest {
|
||||
ctx.projectInfoTable.register(ProjectInfo.builder()
|
||||
.rootDirectory(root)
|
||||
.manifestPath(root.resolve("prometeu.json"))
|
||||
.manifest(new PrometeuManifest(name, "1.0.0", "pbs", 1, ReadOnlyList.wrap(List.of())))
|
||||
.manifest(new PrometeuManifest(name, "1.0.0", "pbs", 1, AppMode.Game, ReadOnlyList.wrap(List.of())))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
+7
-4
@@ -2,6 +2,7 @@ package p.studio.compiler.workspaces.phases;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import p.studio.AppMode;
|
||||
import p.studio.compiler.messages.DependencyConfig;
|
||||
import p.studio.compiler.models.DependencyContext;
|
||||
import p.studio.compiler.models.ProjectDescriptor;
|
||||
@@ -42,16 +43,17 @@ class ValidatePhaseTest {
|
||||
ctx.projectInfoTable.register(ProjectInfo.builder()
|
||||
.rootDirectory(rootPath)
|
||||
.manifestPath(rootPath.resolve("prometeu.json"))
|
||||
.manifest(new PrometeuManifest("root", "1.0.0", "pbs", 1, ReadOnlyList.wrap(List.of())))
|
||||
.manifest(new PrometeuManifest("root", "1.0.0", "pbs", 1, AppMode.Game, ReadOnlyList.wrap(List.of())))
|
||||
.build());
|
||||
ctx.projectInfoTable.register(ProjectInfo.builder()
|
||||
.rootDirectory(depPath)
|
||||
.manifestPath(depPath.resolve("prometeu.json"))
|
||||
.manifest(new PrometeuManifest("dep", "1.0.0", "pbs", 2, ReadOnlyList.wrap(List.of())))
|
||||
.manifest(new PrometeuManifest("dep", "1.0.0", "pbs", 2, AppMode.Game, ReadOnlyList.wrap(List.of())))
|
||||
.build());
|
||||
|
||||
ctx.rootProjectId = rootProjectId;
|
||||
ctx.rootStdlib = 1;
|
||||
ctx.target = AppMode.Game;
|
||||
ctx.dependenciesByProject.add(List.of());
|
||||
ctx.dependenciesByProject.add(List.of());
|
||||
ctx.projectNameAndVersions.put("root", new java.util.HashSet<>(List.of("1.0.0")));
|
||||
@@ -85,16 +87,17 @@ class ValidatePhaseTest {
|
||||
ctx.projectInfoTable.register(ProjectInfo.builder()
|
||||
.rootDirectory(rootPath)
|
||||
.manifestPath(rootPath.resolve("prometeu.json"))
|
||||
.manifest(new PrometeuManifest("root", "1.0.0", "pbs", 2, ReadOnlyList.wrap(List.of())))
|
||||
.manifest(new PrometeuManifest("root", "1.0.0", "pbs", 2, AppMode.Game, ReadOnlyList.wrap(List.of())))
|
||||
.build());
|
||||
ctx.projectInfoTable.register(ProjectInfo.builder()
|
||||
.rootDirectory(depPath)
|
||||
.manifestPath(depPath.resolve("prometeu.json"))
|
||||
.manifest(new PrometeuManifest("dep", "1.0.0", "pbs", 1, ReadOnlyList.wrap(List.of())))
|
||||
.manifest(new PrometeuManifest("dep", "1.0.0", "pbs", 1, AppMode.Game, ReadOnlyList.wrap(List.of())))
|
||||
.build());
|
||||
|
||||
ctx.rootProjectId = rootProjectId;
|
||||
ctx.rootStdlib = 2;
|
||||
ctx.target = AppMode.Game;
|
||||
ctx.dependenciesByProject.add(List.of());
|
||||
ctx.dependenciesByProject.add(List.of());
|
||||
ctx.projectNameAndVersions.put("root", new java.util.HashSet<>(List.of("1.0.0")));
|
||||
|
||||
Reference in New Issue
Block a user