forked from mstahv/vaadin-ecosystem-build
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEcosystemBuild.java
More file actions
1999 lines (1782 loc) · 93.6 KB
/
EcosystemBuild.java
File metadata and controls
1999 lines (1782 loc) · 93.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
///usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 21+
//DEPS info.picocli:picocli:4.7.6
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import java.io.*;
import java.net.URI;
import java.net.http.*;
import java.nio.file.*;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.*;
@Command(name = "ecosystem-build", mixinStandardHelpOptions = true, version = "1.0",
description = "Tests Vaadin ecosystem projects against framework version changes")
public class EcosystemBuild implements Callable<Integer> {
// ============================================================
// PROJECT CONFIGURATION - Edit these lists to add/remove projects
// ============================================================
// Default version overrides applied to all projects (unless they specify their own)
// Projects can override by specifying their own versionOverrides for the same pattern
private static final Map<String, VersionConfig> DEFAULT_VERSION_OVERRIDES = Map.of(
"24.*", new VersionConfig() {{ ignored = true; ignoreReason = "v24 testing limited to selected projects"; }}
);
private static final List<AddonProject> ADDONS = List.of(
new AddonProject() {{
name = "hugerte-for-flow";
repoUrl = "https://github.com/parttio/hugerte-for-flow";
versionOverrides = Map.of("24.*", new VersionConfig() {{ branch = "v1"; }});
}},
new AddonProject() {{
name = "super-fields";
repoUrl = "https://github.com/vaadin-miki/super-fields";
buildSubdir = "superfields";
javaVersion = "21-tem";
}},
new AddonProject() {{
name = "flow-viritin";
repoUrl = "https://github.com/viritin/flow-viritin";
}},
new AddonProject() {{
name = "dramafinder";
repoUrl = "https://github.com/parttio/dramafinder";
notifyUsers = List.of("jcgueriaud1");
timeoutMinutes = 10;
gitClean = true;
}},
new AddonProject() {{
name = "sortable-layout";
repoUrl = "https://github.com/jcgueriaud1/sortable-layout";
notifyUsers = List.of("jcgueriaud1");
}},
new AddonProject() {{
name = "grid-pagination";
repoUrl = "https://github.com/parttio/grid-pagination";
}},
new AddonProject() {{
name = "vaadin-fullcalendar";
repoUrl = "https://github.com/stefanuebe/vaadin-fullcalendar";
}},
new AddonProject() {{
name = "vaadin-maps-leaflet-flow";
repoUrl = "https://github.com/xdev-software/vaadin-maps-leaflet-flow";
}},
new AddonProject() {{
name = "vaadin-ckeditor";
repoUrl = "https://github.com/wontlost-ltd/vaadin-ckeditor";
}},
new AddonProject() {{
name = "svg-visualizations";
repoUrl = "https://github.com/viritin/svg-visualizations";
extraMvnArgs = List.of("-DskipPerformanceValidation=true");
}},
new AddonProject() {{
name = "maplibre";
repoUrl = "https://github.com/parttio/maplibre";
versionOverrides = Map.of(
"25.*", new VersionConfig() {{ branch = "v25"; }},
"24.*", new VersionConfig() {{ branch = "v24"; }}
);
}},
new AddonProject() {{
name = "SimpleTimeline";
repoUrl = "https://github.com/samie/SimpleTimeline";
notifyUsers = List.of("samie");
versionOverrides = Map.of("24.*", new VersionConfig()); // Override default: use defaults for 24.*
}},
new AddonProject() {{
name = "Badge List Add-on";
repoUrl = "https://github.com/FlowingCode/BadgeList";
notifyUsers = List.of("javier-godoy", "scardanzan", "paodb");
versionOverrides = Map.of("24.*", new VersionConfig() {{ branch = "1.x"; }}, "25.*", new VersionConfig() {{ branch = "1.x"; profile = "v25"; }});
}},
new AddonProject() {{
name = "Carousel Addon";
repoUrl = "https://github.com/FlowingCode/CarouselAddon";
notifyUsers = List.of("javier-godoy", "scardanzan", "paodb");
versionOverrides = Map.of("24.*", new VersionConfig(), "25.*", new VersionConfig() {{ profile = "v25"; }});
}},
new AddonProject() {{
name = "Chat Assistant Add-on";
repoUrl = "https://github.com/FlowingCode/ChatAssistant";
notifyUsers = List.of("javier-godoy", "scardanzan", "paodb");
versionOverrides = Map.of("24.*", new VersionConfig(), "25.*", new VersionConfig() {{ profile = "v25"; }});
}},
new AddonProject() {{
name = "Day of Week Selector Add-on";
repoUrl = "https://github.com/FlowingCode/DayOfWeekSelectorAddon";
notifyUsers = List.of("javier-godoy", "scardanzan", "paodb");
versionOverrides = Map.of("24.*", new VersionConfig(), "25.*", new VersionConfig() {{ profile = "v25"; }});
}},
new AddonProject() {{
name = "Error Window Add-on";
repoUrl = "https://github.com/FlowingCode/ErrorWindowAddon";
notifyUsers = List.of("javier-godoy", "scardanzan", "paodb");
versionOverrides = Map.of("24.*", new VersionConfig() {{ profile = "v24"; }}, "25.*", new VersionConfig() {{ profile = "v25"; }});
}},
new AddonProject() {{
name = "Extended Login Add-on";
repoUrl = "https://github.com/FlowingCode/ExtendedLoginAddon";
notifyUsers = List.of("javier-godoy", "scardanzan", "paodb");
versionOverrides = Map.of("24.*", new VersionConfig(), "25.*", new VersionConfig() {{ profile = "v25"; }});
}},
new AddonProject() {{
name = "FontAwesomeIronIconset Add-on";
repoUrl = "https://github.com/FlowingCode/FontAwesomeIronIconset";
notifyUsers = List.of("javier-godoy", "scardanzan", "paodb");
versionOverrides = Map.of("24.*", new VersionConfig(), "25.*", new VersionConfig() {{ profile = "v25"; }});
}},
new AddonProject() {{
name = "Google Maps Add-on";
repoUrl = "https://github.com/FlowingCode/GoogleMapsAddon";
notifyUsers = List.of("javier-godoy", "scardanzan", "paodb");
versionOverrides = Map.of("24.*", new VersionConfig() {{ profile = "v24"; }}, "25.*", new VersionConfig() {{ profile = "v25"; }});
}},
new AddonProject() {{
name = "Grid Exporter Add-on";
repoUrl = "https://github.com/FlowingCode/GridExporterAddon";
notifyUsers = List.of("javier-godoy", "scardanzan", "paodb");
versionOverrides = Map.of("24.*", new VersionConfig(), "25.*", new VersionConfig() {{ profile = "v25"; }});
}},
new AddonProject() {{
name = "Image Crop Add-on";
repoUrl = "https://github.com/FlowingCode/ImageCrop";
notifyUsers = List.of("javier-godoy", "scardanzan", "paodb");
versionOverrides = Map.of("24.*", new VersionConfig(), "25.*", new VersionConfig() {{ profile = "v25"; }});
}},
new AddonProject() {{
name = "Markdown Editor Add-on";
repoUrl = "https://github.com/FlowingCode/MarkdownEditor";
notifyUsers = List.of("javier-godoy", "scardanzan", "paodb");
versionOverrides = Map.of("24.*", new VersionConfig(), "25.*", new VersionConfig() {{ profile = "v25"; }});
}},
new AddonProject() {{
name = "TwinColGrid Add-on";
repoUrl = "https://github.com/FlowingCode/TwinColGrid";
notifyUsers = List.of("javier-godoy", "scardanzan", "paodb");
versionOverrides = Map.of("24.*", new VersionConfig(), "25.*", new VersionConfig() {{ profile = "v25"; }});
}},
new AddonProject() {{
name = "Year-Month Calendar Add-on";
repoUrl = "https://github.com/FlowingCode/YearMonthCalendarAddon";
notifyUsers = List.of("javier-godoy", "scardanzan", "paodb");
versionOverrides = Map.of("24.*", new VersionConfig(), "25.*", new VersionConfig() {{ profile = "v25"; }});
}}
);
private static final List<AppProject> APPS = List.of(
new AppProject() {{
name = "spring-boot-spatial-example";
repoUrl = "https://github.com/mstahv/spring-boot-spatial-example";
}},
new AppProject() {{
name = "xsd-validator-ui";
repoUrl = "https://github.com/rucko24/xsd-validator-ui";
notifyUsers = List.of("rucko24");
}}
);
// ============================================================
// END OF PROJECT CONFIGURATION
// ============================================================
// ANSI color codes
private static final String RED = "\u001B[31m";
private static final String GREEN = "\u001B[32m";
private static final String YELLOW = "\u001B[33m";
private static final String CYAN = "\u001B[36m";
private static final String DIM = "\u001B[2m";
private static final String RESET = "\u001B[0m";
private static final String CLEAR_LINE = "\u001B[2K";
private static final String MOVE_UP = "\u001B[1A";
private static final int TAIL_LINES = 10;
private static final String FALLBACK_VERSION = "25.0.6";
private static final Pattern PRE_RELEASE_PATTERN = Pattern.compile(".*-(alpha|beta|rc)\\d*$", Pattern.CASE_INSENSITIVE);
@Option(names = {"--vaadin.version", "-v"}, description = "Vaadin version to test against (default: latest from Maven Central)")
private String vaadinVersion;
@Option(names = {"--work-dir", "-w"}, description = "Working directory for cloning projects", defaultValue = "work")
private String workDir;
@Option(names = {"--clean", "-c"}, description = "Clean version-specific output directory before running")
private boolean clean;
@Option(names = {"--projects", "-p"}, description = "Comma-separated list of project names to test (default: all)", split = ",")
private List<String> selectedProjects;
@Option(names = {"--quiet-downloads", "-q"}, description = "Silence Maven download progress messages")
private boolean quietDownloads;
@Option(names = {"--timeout", "-t"}, description = "Build timeout per project in minutes", defaultValue = "5")
private int timeoutMinutes;
@Option(names = {"--buildThreads", "-j"}, description = "Number of concurrent builds (default: 1)", defaultValue = "1")
private int buildThreads;
@Option(names = {"--pre-release"}, description = "Auto-detect and test the latest pre-release version from Maven Central")
private boolean preRelease;
@Option(names = {"--ci"}, description = "CI-friendly output: no terminal control, log-style progress")
private boolean ciMode;
private boolean useCustomSettings = false;
private String cachedMavenMetadataXml;
private Path versionOutputPath; // Version-specific output directory for logs and reports
// Project types
enum ProjectType { SMOKE_TEST, ADDON, APP }
// Version-specific configuration overrides
static class VersionConfig {
String branch; // Override branch for this version range
String javaVersion; // Override Java version (SDKMAN identifier)
boolean ignored; // Skip project for this version range
String ignoreReason; // Reason for skipping
List<String> extraMvnArgs; // Override Maven args (null = use default)
String profile; // Maven profile for this version range
}
// Project configuration
static class AddonProject {
String name;
String repoUrl;
String branch; // Git branch (null = auto-detect default)
String buildSubdir; // Subdirectory to run Maven in
String javaVersion; // SDKMAN Java version (e.g., "21-tem")
boolean useAddonsRepo; // Enable Vaadin Directory repository
int timeoutMinutes; // Per-project timeout (0 = use global default)
boolean gitClean; // Run git clean -fdx before build to remove all untracked files
List<String> extraMvnArgs = List.of();
List<String> notifyUsers = List.of(); // GitHub usernames to mention in issues
boolean ignored;
String ignoreReason;
Map<String, VersionConfig> versionOverrides = Map.of(); // Version pattern -> config
}
// App project configuration
static class AppProject {
String name;
String repoUrl;
String branch;
String buildSubdir;
String javaVersion;
boolean useAddonsRepo;
int timeoutMinutes; // Per-project timeout (0 = use global default)
boolean gitClean; // Run git clean -fdx before build to remove all untracked files
List<String> extraMvnArgs = List.of();
List<String> notifyUsers = List.of(); // GitHub usernames to mention in issues
boolean ignored;
String ignoreReason;
Map<String, VersionConfig> versionOverrides = Map.of(); // Version pattern -> config
}
// Test result
record TestResult(String projectName, ProjectType type, boolean success, String message, long durationMs, Path logFile) {
TestResult(String projectName, ProjectType type, boolean success, String message, long durationMs) {
this(projectName, type, success, message, durationMs, null);
}
}
// Build status for display
enum BuildStatus { PENDING, WAITING, BUILDING, PASSED, FAILED, KNOWN_ISSUE, IGNORED }
// Metadata about a failed build - used to provide context in GitHub issues
record FailureMetadata(String repoUrl, String originalVersion, boolean buildsWithOriginal, List<String> notifyUsers) {}
private final Map<String, BuildStatus> statusMap = new LinkedHashMap<>();
private final Map<String, ProjectType> projectTypes = new HashMap<>();
private final Map<String, Long> durationMap = new HashMap<>();
private final Map<String, Long> buildStartTimeMap = new HashMap<>();
private final Map<String, String> knownIssueUrls = new HashMap<>(); // Project -> GitHub issue URL
private final Map<String, FailureMetadata> failureMetadata = new HashMap<>(); // Project -> failure context
private final Set<String> flakyProjects = new HashSet<>(); // Projects that alternate between pass and fail
private int lastOutputLines = 0;
@Override
public Integer call() throws Exception {
// Auto-detect CI environment
if (!ciMode && System.getenv("CI") != null) {
ciMode = true;
}
// Resolve Vaadin version if not specified
if (vaadinVersion != null && !vaadinVersion.isBlank()) {
// Explicit version specified - use pre-release settings for snapshots/betas
useCustomSettings = true;
System.out.println("📦 Using custom Vaadin version: " + vaadinVersion);
System.out.println("🔓 Pre-release/snapshot repositories enabled via settings.xml");
System.out.println();
} else if (preRelease) {
System.out.println("🔍 Fetching latest pre-release version from Maven Central...");
String preReleaseVersion = fetchLatestPreReleaseVersion();
if (preReleaseVersion == null) {
System.out.println("ℹ️ No pre-release version found from a newer series. Nothing to test.");
return 0;
}
vaadinVersion = preReleaseVersion;
useCustomSettings = true;
System.out.println("📦 Using pre-release Vaadin version: " + vaadinVersion);
System.out.println("🔓 Pre-release repositories enabled via settings.xml");
System.out.println();
} else {
System.out.println("🔍 Fetching latest Vaadin version from Maven Central...");
vaadinVersion = fetchLatestVaadinVersion();
System.out.println("📦 Using Vaadin version: " + vaadinVersion);
System.out.println();
}
Path workPath = Path.of(workDir);
Files.createDirectories(workPath);
// Create version-specific output directory for logs and reports
versionOutputPath = workPath.resolve(vaadinVersion);
if (clean && Files.exists(versionOutputPath)) {
System.out.println("🧹 Cleaning version output directory: " + versionOutputPath);
deleteDirectory(versionOutputPath);
}
// Archive previous build logs before starting fresh
archivePreviousLogs(workPath, vaadinVersion);
Files.createDirectories(versionOutputPath);
// Run smoke test first to validate Vaadin version and cache artifacts
System.out.println("🔥 Running smoke test to validate Vaadin " + vaadinVersion + "...");
System.out.println();
TestResult smokeTestResult = runSmokeTest(workPath);
if (!smokeTestResult.success()) {
System.out.println();
System.out.printf("%s💥 Smoke test failed! Vaadin %s may not be available or compatible.%s%n",
RED, vaadinVersion, RESET);
System.out.println(" Check " + smokeTestResult.logFile() + " for details.");
// Still write report with failed smoke test
long totalTimeMs = System.currentTimeMillis() - System.currentTimeMillis(); // ~0
printFinalSummary(List.of(smokeTestResult), smokeTestResult.durationMs());
return 1;
}
System.out.println();
System.out.printf("%s✅ Smoke test passed - Vaadin %s artifacts cached (%.1fs)%s%n",
GREEN, vaadinVersion, smokeTestResult.durationMs() / 1000.0, RESET);
System.out.println();
// Build list of all projects to test
List<AddonProject> addonsToTest = ADDONS;
List<AppProject> appsToTest = APPS;
// Filter projects if specific ones are requested
if (selectedProjects != null && !selectedProjects.isEmpty()) {
addonsToTest = ADDONS.stream()
.filter(a -> selectedProjects.contains(a.name))
.toList();
appsToTest = APPS.stream()
.filter(a -> selectedProjects.contains(a.name))
.toList();
if (addonsToTest.isEmpty() && appsToTest.isEmpty()) {
System.err.println("❓ No matching projects found for: " + String.join(", ", selectedProjects));
var allNames = new ArrayList<String>();
ADDONS.forEach(a -> allNames.add(a.name));
APPS.forEach(a -> allNames.add(a.name));
System.err.println("📋 Available projects: " + allNames);
return 1;
}
}
// Initialize status map with project types (applying version-specific ignore status)
for (AddonProject addon : addonsToTest) {
VersionConfig vc = findVersionConfig(addon.versionOverrides, vaadinVersion);
boolean ignored = (vc != null && vc.ignored) || addon.ignored;
statusMap.put(addon.name, ignored ? BuildStatus.IGNORED : BuildStatus.PENDING);
projectTypes.put(addon.name, ProjectType.ADDON);
}
for (AppProject app : appsToTest) {
VersionConfig vc = findVersionConfig(app.versionOverrides, vaadinVersion);
boolean ignored = (vc != null && vc.ignored) || app.ignored;
statusMap.put(app.name, ignored ? BuildStatus.IGNORED : BuildStatus.PENDING);
projectTypes.put(app.name, ProjectType.APP);
}
List<TestResult> results = Collections.synchronizedList(new ArrayList<>());
results.add(smokeTestResult); // Include smoke test in report
long buildStartTime = System.currentTimeMillis();
// Print initial header
printHeader();
printStatusTable();
System.out.println();
// Collect all projects to build
record BuildTask(String name, String repoUrl, String branch, String buildSubdir,
String javaVersion, boolean useAddonsRepo, List<String> extraMvnArgs,
List<String> notifyUsers, ProjectType type, boolean ignored, String ignoreReason,
int timeoutMinutes, boolean gitClean, String profileId) {}
List<BuildTask> allTasks = new ArrayList<>();
for (AddonProject addon : addonsToTest) {
// Apply version-specific overrides if any
VersionConfig vc = findVersionConfig(addon.versionOverrides, vaadinVersion);
String branch = (vc != null && vc.branch != null) ? vc.branch : addon.branch;
String javaVersion = (vc != null && vc.javaVersion != null) ? vc.javaVersion : addon.javaVersion;
List<String> extraMvnArgs = (vc != null && vc.extraMvnArgs != null) ? vc.extraMvnArgs : addon.extraMvnArgs;
boolean ignored = (vc != null && vc.ignored) || addon.ignored;
String ignoreReason = (vc != null && vc.ignored) ? vc.ignoreReason : addon.ignoreReason;
String profileId = (vc != null) ? vc.profile : null;
allTasks.add(new BuildTask(addon.name, addon.repoUrl, branch, addon.buildSubdir,
javaVersion, addon.useAddonsRepo, extraMvnArgs, addon.notifyUsers,
ProjectType.ADDON, ignored, ignoreReason, addon.timeoutMinutes, addon.gitClean, profileId));
}
for (AppProject app : appsToTest) {
// Apply version-specific overrides if any
VersionConfig vc = findVersionConfig(app.versionOverrides, vaadinVersion);
String branch = (vc != null && vc.branch != null) ? vc.branch : app.branch;
String javaVersion = (vc != null && vc.javaVersion != null) ? vc.javaVersion : app.javaVersion;
List<String> extraMvnArgs = (vc != null && vc.extraMvnArgs != null) ? vc.extraMvnArgs : app.extraMvnArgs;
boolean ignored = (vc != null && vc.ignored) || app.ignored;
String ignoreReason = (vc != null && vc.ignored) ? vc.ignoreReason : app.ignoreReason;
String profileId = (vc != null) ? vc.profile : null;
allTasks.add(new BuildTask(app.name, app.repoUrl, branch, app.buildSubdir,
javaVersion, app.useAddonsRepo, extraMvnArgs, app.notifyUsers,
ProjectType.APP, ignored, ignoreReason, app.timeoutMinutes, app.gitClean, profileId));
}
if (buildThreads == 1) {
// Sequential execution with live output
for (BuildTask task : allTasks) {
if (task.ignored) {
results.add(new TestResult(task.name, task.type, false, "Ignored: " + task.ignoreReason, 0));
if (ciMode) {
System.out.printf(" ⏭️ %s IGNORED%n", task.name);
}
continue;
}
statusMap.put(task.name, BuildStatus.BUILDING);
buildStartTimeMap.put(task.name, System.currentTimeMillis());
if (ciMode) {
System.out.printf(" 🔨 Building %s...%n", task.name);
} else {
clearOutput();
printHeader();
printStatusTable();
System.out.println();
}
TestResult result = testProject(task.name, task.repoUrl, task.branch, task.buildSubdir,
task.javaVersion, task.useAddonsRepo, task.extraMvnArgs, task.type, workPath,
ciMode, task.timeoutMinutes, task.gitClean, task.profileId);
results.add(result);
durationMap.put(task.name, result.durationMs());
BuildStatus finalStatus;
if (result.success()) {
finalStatus = BuildStatus.PASSED;
} else {
String issueUrl = findOpenGitHubIssue(task.name, vaadinVersion);
if (issueUrl != null) {
finalStatus = BuildStatus.KNOWN_ISSUE;
knownIssueUrls.put(task.name, issueUrl);
} else {
finalStatus = BuildStatus.FAILED;
}
// For failures, verify if project builds with its original Vaadin version
Path projectPath = workPath.resolve(task.name);
Path buildPath = task.buildSubdir != null ? projectPath.resolve(task.buildSubdir) : projectPath;
if (!ciMode) {
System.out.println();
System.out.printf(" %s🔍 Verifying build with project's original Vaadin version...%s%n", DIM, RESET);
}
String originalVersion = detectProjectVaadinVersion(buildPath, task.javaVersion);
Path verifyLog = versionOutputPath.resolve(task.name + "-original-build.log");
boolean buildsWithOriginal = verifyWithOriginalVersion(buildPath, task.javaVersion,
task.useAddonsRepo, task.extraMvnArgs, verifyLog);
failureMetadata.put(task.name, new FailureMetadata(task.repoUrl, originalVersion, buildsWithOriginal, task.notifyUsers));
if (!ciMode && originalVersion != null) {
System.out.printf(" %s Original version: %s, builds: %s%s%n", DIM, originalVersion,
buildsWithOriginal ? "✅" : "❌", RESET);
}
}
statusMap.put(task.name, finalStatus);
if (ciMode) {
// Print one-line result
String duration = String.format("%.1fs", result.durationMs() / 1000.0);
switch (finalStatus) {
case PASSED -> System.out.printf(" ✅ %s PASSED (%s)%n", task.name, duration);
case FAILED -> System.out.printf(" ❌ %s FAILED (%s) — Log: %s%n", task.name, duration, result.logFile());
case KNOWN_ISSUE -> System.out.printf(" ⚠️ %s KNOWN ISSUE (%s) — Log: %s%n", task.name, duration, result.logFile());
default -> {}
}
} else {
clearOutput();
printHeader();
printStatusTable();
if (finalStatus == BuildStatus.FAILED) {
System.out.println();
System.out.printf(" %s💥 %s failed. Log: %s%s%n", RED, task.name, result.logFile(), RESET);
} else if (finalStatus == BuildStatus.KNOWN_ISSUE) {
System.out.println();
System.out.printf(" %s⚠️ %s failed (known issue). Log: %s%s%n", YELLOW, task.name, result.logFile(), RESET);
}
System.out.println();
}
}
} else {
// Concurrent execution with fixed builder slots
ExecutorService executor = Executors.newFixedThreadPool(buildThreads);
List<Future<TestResult>> futures = new ArrayList<>();
// Fixed slots for each builder thread - index is slot number
record BuilderSlot(String projectName, Path logFile) {}
BuilderSlot[] builderSlots = new BuilderSlot[buildThreads];
Object slotsLock = new Object();
// Track available slot numbers
Queue<Integer> availableSlots = new ConcurrentLinkedQueue<>();
for (int i = 0; i < buildThreads; i++) {
availableSlots.add(i);
}
// Handle ignored tasks first
for (BuildTask task : allTasks) {
if (task.ignored) {
results.add(new TestResult(task.name, task.type, false, "Ignored: " + task.ignoreReason, 0));
if (ciMode) {
System.out.printf(" ⏭️ %s IGNORED%n", task.name);
}
}
}
// Mark non-ignored tasks as WAITING
for (BuildTask task : allTasks) {
if (!task.ignored) {
statusMap.put(task.name, BuildStatus.WAITING);
}
}
// Submit build tasks
final Path finalWorkPath = workPath;
for (BuildTask task : allTasks) {
if (task.ignored) continue;
futures.add(executor.submit(() -> {
// Acquire a slot for this builder
Integer slot = availableSlots.poll();
if (slot == null) slot = 0; // Fallback
// Mark as building when actually starting
synchronized (slotsLock) {
statusMap.put(task.name, BuildStatus.BUILDING);
buildStartTimeMap.put(task.name, System.currentTimeMillis());
builderSlots[slot] = new BuilderSlot(task.name, finalWorkPath.resolve(task.name + "-build.log"));
}
TestResult result = testProject(task.name, task.repoUrl, task.branch, task.buildSubdir,
task.javaVersion, task.useAddonsRepo, task.extraMvnArgs, task.type, finalWorkPath,
true, task.timeoutMinutes, task.gitClean, task.profileId);
// For failures, verify if project builds with its original Vaadin version
FailureMetadata metadata = null;
if (!result.success()) {
Path projectPath = finalWorkPath.resolve(task.name);
Path buildPath = task.buildSubdir != null ? projectPath.resolve(task.buildSubdir) : projectPath;
String originalVersion = detectProjectVaadinVersion(buildPath, task.javaVersion);
Path verifyLog = versionOutputPath.resolve(task.name + "-original-build.log");
boolean buildsWithOriginal = verifyWithOriginalVersion(buildPath, task.javaVersion,
task.useAddonsRepo, task.extraMvnArgs, verifyLog);
metadata = new FailureMetadata(task.repoUrl, originalVersion, buildsWithOriginal, task.notifyUsers);
}
synchronized (slotsLock) {
durationMap.put(task.name, result.durationMs());
BuildStatus finalStatus;
if (result.success()) {
finalStatus = BuildStatus.PASSED;
} else {
String issueUrl = findOpenGitHubIssue(task.name, vaadinVersion);
if (issueUrl != null) {
finalStatus = BuildStatus.KNOWN_ISSUE;
knownIssueUrls.put(task.name, issueUrl);
} else {
finalStatus = BuildStatus.FAILED;
}
if (metadata != null) {
failureMetadata.put(task.name, metadata);
}
}
statusMap.put(task.name, finalStatus);
builderSlots[slot] = null;
}
// Release the slot
availableSlots.add(slot);
return result;
}));
}
if (ciMode) {
// CI mode: track state changes and print events once
Map<String, BuildStatus> previousStatus = new HashMap<>();
for (BuildTask task : allTasks) {
previousStatus.put(task.name, statusMap.get(task.name));
}
while (!futures.stream().allMatch(Future::isDone)) {
synchronized (slotsLock) {
for (BuildTask task : allTasks) {
if (task.ignored) continue;
BuildStatus prev = previousStatus.get(task.name);
BuildStatus curr = statusMap.get(task.name);
if (prev != curr) {
previousStatus.put(task.name, curr);
switch (curr) {
case BUILDING -> System.out.printf(" 🔨 Building %s...%n", task.name);
case PASSED -> {
Long dur = durationMap.get(task.name);
String duration = dur != null ? String.format("%.1fs", dur / 1000.0) : "";
System.out.printf(" ✅ %s PASSED (%s)%n", task.name, duration);
}
case FAILED -> {
Long dur = durationMap.get(task.name);
String duration = dur != null ? String.format("%.1fs", dur / 1000.0) : "";
System.out.printf(" ❌ %s FAILED (%s)%n", task.name, duration);
}
case KNOWN_ISSUE -> {
Long dur = durationMap.get(task.name);
String duration = dur != null ? String.format("%.1fs", dur / 1000.0) : "";
System.out.printf(" ⚠️ %s KNOWN ISSUE (%s)%n", task.name, duration);
}
default -> {}
}
}
}
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
break;
}
}
// Print any final state changes that happened after the last poll
synchronized (slotsLock) {
for (BuildTask task : allTasks) {
if (task.ignored) continue;
BuildStatus prev = previousStatus.get(task.name);
BuildStatus curr = statusMap.get(task.name);
if (prev != curr) {
switch (curr) {
case PASSED -> {
Long dur = durationMap.get(task.name);
String duration = dur != null ? String.format("%.1fs", dur / 1000.0) : "";
System.out.printf(" ✅ %s PASSED (%s)%n", task.name, duration);
}
case FAILED -> {
Long dur = durationMap.get(task.name);
String duration = dur != null ? String.format("%.1fs", dur / 1000.0) : "";
System.out.printf(" ❌ %s FAILED (%s)%n", task.name, duration);
}
case KNOWN_ISSUE -> {
Long dur = durationMap.get(task.name);
String duration = dur != null ? String.format("%.1fs", dur / 1000.0) : "";
System.out.printf(" ⚠️ %s KNOWN ISSUE (%s)%n", task.name, duration);
}
default -> {}
}
}
}
}
} else {
// Terminal mode: live-updating display with log tails
// Calculate lines per builder based on terminal size if available
int terminalHeight = getTerminalHeight();
int headerAndStatusLines = countOutputLines() + 2; // +2 for empty line and separator
int availableLines = terminalHeight > 0
? Math.max(buildThreads * 4, terminalHeight - headerAndStatusLines - 2)
: TAIL_LINES;
int linesPerBuilder = Math.max(3, availableLines / buildThreads);
// Update status display while waiting
while (!futures.stream().allMatch(Future::isDone)) {
clearOutput();
printHeader();
printStatusTable();
System.out.println();
// Show output areas for all builder slots (fixed layout)
System.out.println(" " + CYAN + "─── Build Output " + "─".repeat(40) + RESET);
synchronized (slotsLock) {
for (int slot = 0; slot < buildThreads; slot++) {
String builderId = String.format("Builder %d", slot + 1);
BuilderSlot slotInfo = builderSlots[slot];
if (slotInfo != null) {
System.out.println(" " + YELLOW + "▶ [" + builderId + "] " + slotInfo.projectName() + RESET);
printLogTail(slotInfo.logFile(), linesPerBuilder);
} else {
// Empty slot - always show with reserved space
System.out.println(" " + DIM + "▷ [" + builderId + "] (idle)" + RESET);
for (int i = 0; i < linesPerBuilder; i++) {
System.out.println();
}
}
}
}
// Track total lines printed for clearing (fixed size now)
// Header + status table + 1 empty + separator + (buildThreads * (header + linesPerBuilder))
lastOutputLines = countOutputLines() + 1 + (buildThreads * (1 + linesPerBuilder));
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
break;
}
}
}
// Collect results
for (Future<TestResult> future : futures) {
try {
results.add(future.get());
} catch (Exception e) {
// Error already handled in the task
}
}
executor.shutdown();
// Final status update
if (!ciMode) {
clearOutput();
printHeader();
printStatusTable();
}
// Show failures and known issues
for (TestResult result : results) {
if (!result.success() && !result.message().startsWith("Ignored:")) {
BuildStatus status = statusMap.get(result.projectName());
if (!ciMode) {
if (status == BuildStatus.KNOWN_ISSUE) {
System.out.println();
System.out.printf(" %s⚠️ %s failed (known issue). Log: %s%s%n", YELLOW, result.projectName(), result.logFile(), RESET);
} else {
System.out.println();
System.out.printf(" %s💥 %s failed. Log: %s%s%n", RED, result.projectName(), result.logFile(), RESET);
}
}
}
}
System.out.println();
}
// Detect flaky projects from build archives
detectFlakyProjects(Path.of(workDir));
// Print final summary
long totalTimeMs = System.currentTimeMillis() - buildStartTime;
printFinalSummary(results, totalTimeMs);
// Write list of failed projects for CI integration
writeFailedProjectsList();
return 0;
}
private void printHeader() {
System.out.println("=".repeat(60));
System.out.println("🏗️ Vaadin Ecosystem Build");
System.out.println("🎯 Testing against Vaadin version: " + CYAN + vaadinVersion + RESET);
System.out.println("=".repeat(60));
}
private void printStatusTable() {
// Group by project type
var addons = statusMap.entrySet().stream()
.filter(e -> projectTypes.get(e.getKey()) == ProjectType.ADDON)
.toList();
var apps = statusMap.entrySet().stream()
.filter(e -> projectTypes.get(e.getKey()) == ProjectType.APP)
.toList();
if (!addons.isEmpty()) {
System.out.println(" " + CYAN + "📦 Add-ons" + RESET);
for (var entry : addons) {
printStatusLine(entry.getKey(), entry.getValue());
}
}
if (!apps.isEmpty()) {
if (!addons.isEmpty()) System.out.println();
System.out.println(" " + CYAN + "🚀 Applications" + RESET);
for (var entry : apps) {
printStatusLine(entry.getKey(), entry.getValue());
}
}
}
private void printStatusLine(String name, BuildStatus status) {
Long duration = durationMap.get(name);
String durationStr = duration != null ? String.format(" (%.1fs)", duration / 1000.0) : "";
String buildingTime = "";
Long startTime = buildStartTimeMap.get(name);
if (status == BuildStatus.BUILDING && startTime != null) {
long elapsedSec = (System.currentTimeMillis() - startTime) / 1000;
buildingTime = String.format(" (%ds)", elapsedSec);
}
String statusStr = switch (status) {
case PENDING -> DIM + "⏳ PENDING" + RESET;
case WAITING -> CYAN + "⏳ WAITING..." + RESET;
case BUILDING -> YELLOW + "🔨 BUILDING..." + buildingTime + RESET;
case PASSED -> GREEN + "✅ PASSED" + RESET + durationStr;
case FAILED -> RED + "❌ FAILED" + RESET + durationStr;
case KNOWN_ISSUE -> YELLOW + "⚠️ KNOWN ISSUE" + RESET + durationStr;
case IGNORED -> DIM + "⏭️ IGNORED" + RESET;
};
System.out.printf(" %-28s %s%n", name, statusStr);
}
private void printLogTail(Path logFile, int lines) {
try {
if (!Files.exists(logFile)) {
System.out.println(" " + DIM + "(waiting for output...)" + RESET);
return;
}
List<String> allLines = Files.readAllLines(logFile);
int start = Math.max(0, allLines.size() - lines);
for (int i = start; i < allLines.size(); i++) {
String line = allLines.get(i);
if (line.length() > 100) {
line = line.substring(0, 97) + "...";
}
System.out.println(" " + DIM + line + RESET);
}
// Pad with empty lines if not enough output yet
for (int i = allLines.size(); i < lines; i++) {
System.out.println();
}
} catch (IOException e) {
System.out.println(" " + DIM + "(reading log...)" + RESET);
}
}
private int getTerminalHeight() {
// Try to get terminal height using tput
try {
ProcessBuilder pb = new ProcessBuilder("tput", "lines");
pb.redirectErrorStream(true);
Process process = pb.start();
try (var reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
String line = reader.readLine();
if (line != null && process.waitFor(1, TimeUnit.SECONDS)) {
return Integer.parseInt(line.trim());
}
}
} catch (Exception e) {
// Fallback: try LINES environment variable
String lines = System.getenv("LINES");
if (lines != null) {
try {
return Integer.parseInt(lines.trim());
} catch (NumberFormatException ignored) {}
}
}
return 0; // Unknown, use default
}
private void clearOutput() {
if (ciMode) return;
// Clear previous output lines
for (int i = 0; i < lastOutputLines; i++) {
System.out.print(MOVE_UP + CLEAR_LINE);
}
lastOutputLines = 0;
}
private void clearTailLines(int lines) {
if (ciMode) return;
for (int i = 0; i < lines; i++) {
System.out.print(MOVE_UP + CLEAR_LINE);
}
}
private int countOutputLines() {
// Header (4 lines) + group headers + status table + spacing + 1 empty line
int lines = 5 + statusMap.size();
boolean hasAddons = projectTypes.values().stream().anyMatch(t -> t == ProjectType.ADDON);
boolean hasApps = projectTypes.values().stream().anyMatch(t -> t == ProjectType.APP);
if (hasAddons) lines++; // Add-ons header
if (hasApps) lines++; // Apps header
if (hasAddons && hasApps) lines++; // Spacing between groups
return lines;
}
private TestResult runSmokeTest(Path workPath) {
long startTime = System.currentTimeMillis();
String name = "vaadin-project-archetype";
Path smokeTestPath = workPath.resolve("smoke-test");
Path logFile = versionOutputPath.resolve("smoke-test-build.log");
try {
// Clean up previous smoke test
if (Files.exists(smokeTestPath)) {
deleteDirectory(smokeTestPath);
}
// Generate project from archetype
System.out.println(" " + DIM + "📦 Generating project from Vaadin archetype..." + RESET);
List<String> archetypeArgs = List.of(
"archetype:generate",
"-B", // Batch mode
"-DarchetypeGroupId=com.vaadin",
"-DarchetypeArtifactId=vaadin-archetype-application",
"-DarchetypeVersion=LATEST",
"-DgroupId=com.example",
"-DartifactId=smoke-test",
"-Dversion=1.0-SNAPSHOT"
);
List<String> mvnCmd = new ArrayList<>();
mvnCmd.add("mvn");
mvnCmd.addAll(archetypeArgs);
mvnCmd.addAll(getCommonMvnArgs());
System.out.println(" " + DIM + "$ " + String.join(" ", mvnCmd) + RESET);
int archetypeResult = runMavenSilent(workPath, logFile, null, archetypeArgs);
if (archetypeResult != 0) {
System.out.println(" " + RED + "❌ Archetype generation failed" + RESET);
return new TestResult(name, ProjectType.SMOKE_TEST, false, "Archetype generation failed", elapsed(startTime), logFile);
}
// Set Vaadin version (in case archetype version differs from target version)
System.out.println(" " + DIM + "🔧 Setting Vaadin version to " + vaadinVersion + "..." + RESET);
List<String> setPropertyArgs = new ArrayList<>();
setPropertyArgs.add("versions:set-property");
setPropertyArgs.add("-Dproperty=vaadin.version");
setPropertyArgs.add("-DnewVersion=" + vaadinVersion);
setPropertyArgs.add("-DgenerateBackupPoms=false");
setPropertyArgs.addAll(getCommonMvnArgs());
runMavenSilent(smokeTestPath, logFile, null, setPropertyArgs);
// Run verify to download all dependencies and compile
System.out.println(" " + DIM + "🔨 Building smoke test project..." + RESET);
List<String> verifyArgs = new ArrayList<>();
verifyArgs.add("clean");
verifyArgs.add("verify");
verifyArgs.add("-DskipTests"); // Skip tests for smoke test, just need compilation
if (vaadinVersion != null && vaadinVersion.contains("SNAPSHOT")) verifyArgs.add("-U"); // Force snapshot updates
verifyArgs.addAll(getCommonMvnArgs());
List<String> verifyCmdDisplay = new ArrayList<>();
verifyCmdDisplay.add("mvn");
verifyCmdDisplay.addAll(verifyArgs);
System.out.println(" " + DIM + "$ " + String.join(" ", verifyCmdDisplay) + RESET);