implements PLN-0129
JaCoCo Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 62.10% (17811/28682)
* Branch Coverage: 52.81% (6878/13025)
* Lines of Code: 28682
* Cyclomatic Complexity: 11494
#### Quality Gates Summary
Output truncated.
Test / Build skipped: 15, passed: 654
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: 62.10% (17811/28682)
* Branch Coverage: 52.81% (6878/13025)
* Lines of Code: 28682
* Cyclomatic Complexity: 11494
#### Quality Gates Summary
Output truncated.
Test / Build skipped: 15, passed: 654
Intrepid/Prometeu/Studio/pipeline/head This commit looks good
Intrepid/Prometeu/Studio/pipeline/pr-master This commit looks good
Add ArchUnit guards for Java multi-frontend boundaries in a test-only module. Identify PBS by frontend-module origin, allow only the registry as composition root, and lock the wording in specs 19, 20, and 22. Housekeep DSC-0064 with LSN-0066.
This commit is contained in:
+63
@@ -0,0 +1,63 @@
|
||||
package p.studio.architecture;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
class CommonBackendPbsPrefixScanTest {
|
||||
private static final String COMPILER_SOURCE_ROOT =
|
||||
"prometeu-compiler/prometeu-build-pipeline/src/main/java/p/studio/compiler";
|
||||
private static final List<String> GUARDED_RELATIVE_ROOTS = List.of(
|
||||
"backend",
|
||||
"lifecycle",
|
||||
"workspaces/stages");
|
||||
private static final String FORBIDDEN_PBS_PREFIX = "__pbs.";
|
||||
|
||||
@Test
|
||||
void commonLifecycleAndBackendMustNotDiscoverRolesFromPbsNamePrefixes() throws IOException {
|
||||
final var violations = new ArrayList<String>();
|
||||
final var repoRoot = locateRepoRoot();
|
||||
final var compilerRoot = repoRoot.resolve(COMPILER_SOURCE_ROOT);
|
||||
for (final var relativeRoot : GUARDED_RELATIVE_ROOTS) {
|
||||
final var root = compilerRoot.resolve(relativeRoot);
|
||||
if (!Files.exists(root)) {
|
||||
fail("guarded source root is missing: " + root);
|
||||
}
|
||||
try (final var paths = Files.walk(root)) {
|
||||
paths.filter(path -> path.toString().endsWith(".java")).forEach(path -> {
|
||||
try {
|
||||
if (Files.readString(path).contains(FORBIDDEN_PBS_PREFIX)) {
|
||||
violations.add(repoRoot.relativize(path).toString());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("failed to read source file: " + path, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
assertTrue(
|
||||
violations.isEmpty(),
|
||||
"common lifecycle/backend code must not inspect __pbs. prefixes: " + violations);
|
||||
}
|
||||
|
||||
private static Path locateRepoRoot() {
|
||||
var cursor = Path.of(System.getProperty("user.dir")).toAbsolutePath().normalize();
|
||||
while (cursor != null) {
|
||||
final var hasDocs = Files.isDirectory(cursor.resolve("docs/specs/compiler"));
|
||||
final var hasCompiler = Files.isDirectory(cursor.resolve("prometeu-compiler"));
|
||||
if (hasDocs && hasCompiler) {
|
||||
return cursor;
|
||||
}
|
||||
cursor = cursor.getParent();
|
||||
}
|
||||
fail("could not locate repository root from working directory");
|
||||
throw new IllegalStateException("unreachable");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user