S2 EsLint implementation
All checks were successful
Build, test and publish / verify (push) Successful in 1m40s
All checks were successful
Build, test and publish / verify (push) Successful in 1m40s
This commit is contained in:
@@ -102,6 +102,21 @@ class CiTests {
|
||||
equal(0L,f.calls("build")); equal(0L,f.calls("push"));
|
||||
}
|
||||
});
|
||||
test("Frontend lint runs after install and blocks tests and build on failure", () -> {
|
||||
try (Fixture f = new Fixture()) {
|
||||
f.fake.lintFailure = true;
|
||||
try { f.pipeline.verifyFrontend(); throw new AssertionError("Expected failure"); }
|
||||
catch (Commands.Failure error) { equal(1,error.exitCode); }
|
||||
equal(List.of(List.of("npm", "ci"), List.of("npm", "run", "lint")), f.fake.calls);
|
||||
}
|
||||
});
|
||||
test("Frontend verification checks before testing and building", () -> {
|
||||
try (Fixture f = new Fixture()) {
|
||||
f.pipeline.verifyFrontend();
|
||||
equal(List.of("ci", "run lint", "test -- --reporters=default --reporters=junit --output-file=unit-results/junit.xml", "run build"),
|
||||
f.fake.calls.stream().map(a -> String.join(" ", a.subList(1,a.size()))).toList());
|
||||
}
|
||||
});
|
||||
test("Process execution enforces its deadline", () -> {
|
||||
Path dir = Files.createTempDirectory("ci-process-test-");
|
||||
try {
|
||||
@@ -135,13 +150,14 @@ class CiTests {
|
||||
final List<List<String>> calls = new ArrayList<>();
|
||||
final Map<String,String> images = new HashMap<>(), tags = new HashMap<>();
|
||||
String head = SHA, pushFailure = "", pullFailure = "";
|
||||
boolean manifestError, mavenFailure;
|
||||
boolean manifestError, mavenFailure, lintFailure;
|
||||
boolean dockerAvailable = true;
|
||||
FakeCommands() { super(Duration.ofMinutes(1)); }
|
||||
@Override Result execute(List<String> args, Path cwd, Map<String,String> env, String input, boolean echo) {
|
||||
calls.add(List.copyOf(args));
|
||||
if (args.getFirst().equals("git")) return new Result(0,SHA);
|
||||
if (args.getFirst().equals("mvn") && mavenFailure) return new Result(42,"deliberate failure");
|
||||
if (args.equals(List.of("npm", "run", "lint")) && lintFailure) return new Result(1,"deliberate lint failure");
|
||||
if (!args.getFirst().equals("docker")) return new Result(0,"");
|
||||
String command = args.get(1), ref = args.getLast();
|
||||
if (command.equals("info")) return new Result(dockerAvailable ? 0 : 1,args.contains("{{.Architecture}}") ? "amd64" : "linux");
|
||||
|
||||
@@ -69,10 +69,7 @@ class Pipeline {
|
||||
run("java", "-version"); run("node", "--version"); run("mvn", "-B", "-ntp", "clean", "verify");
|
||||
CiTests.run();
|
||||
Path frontend = root.resolve("agiledancers-fe");
|
||||
commands.execute(List.of("npm", "ci"), frontend, env, null, true).checked();
|
||||
commands.execute(List.of("npm", "test", "--", "--reporters=default", "--reporters=junit",
|
||||
"--output-file=unit-results/junit.xml"), frontend, env, null, true).checked();
|
||||
commands.execute(List.of("npm", "run", "build"), frontend, env, null, true).checked();
|
||||
verifyFrontend();
|
||||
String platform = env.get("TARGET_PLATFORM");
|
||||
run("docker", "build", "--platform", platform, "--target", "prebuilt", "--label",
|
||||
"org.opencontainers.image.revision=" + commit, "-t", backendImage, ".");
|
||||
@@ -101,6 +98,14 @@ class Pipeline {
|
||||
}
|
||||
}
|
||||
}
|
||||
void verifyFrontend() throws Exception {
|
||||
Path frontend = root.resolve("agiledancers-fe");
|
||||
commands.execute(List.of("npm", "ci"), frontend, env, null, true).checked();
|
||||
commands.execute(List.of("npm", "run", "lint"), frontend, env, null, true).checked();
|
||||
commands.execute(List.of("npm", "test", "--", "--reporters=default", "--reporters=junit",
|
||||
"--output-file=unit-results/junit.xml"), frontend, env, null, true).checked();
|
||||
commands.execute(List.of("npm", "run", "build"), frontend, env, null, true).checked();
|
||||
}
|
||||
void waitForApplication() throws Exception {
|
||||
for (int i = 0; i < 60; i++) {
|
||||
if (result(false,"docker", "exec", runName + "-frontend", "wget", "-q", "-O", "-",
|
||||
|
||||
Reference in New Issue
Block a user