Skip to content

Commit 2862e0f

Browse files
committed
refactor(project): Add ui5DataDir build option for cache isolation
Expose ui5DataDir as a programmatic option on ProjectGraph.build(), plumbed through ProjectBuilder, BuildContext, and CacheManager.create(). Previously the build cache location could only be configured via the UI5_DATA_DIR env var or the ~/.ui5rc config file, both of which are process-global and unsuitable for parallel test isolation. Builder integration tests now route the SQLite-backed build cache into a per-test directory via a new isolatedUi5DataDir helper. This fixes intermittent ERR_SQLITE_ERROR "database is locked" failures on Windows CI caused by parallel AVA workers contending on the shared ~/.ui5/buildCache database, and removes the UI5_DATA_DIR fallback from the builder ava.config.js.
1 parent de35965 commit 2862e0f

11 files changed

Lines changed: 106 additions & 24 deletions

File tree

packages/builder/ava.config.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
import path from "node:path";
2-
import {fileURLToPath} from "node:url";
31
import avaCommonConfig from "../../ava.common.config.js";
42

5-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
6-
7-
export default {
8-
...avaCommonConfig,
9-
environmentVariables: {
10-
...avaCommonConfig.environmentVariables,
11-
UI5_DATA_DIR: path.join(__dirname, "test", "tmp", ".ui5-data"),
12-
},
13-
};
3+
export default avaCommonConfig;

packages/builder/test/lib/builder/builder.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import sinon from "sinon";
99
import {graphFromObject, graphFromPackageDependencies} from "@ui5/project/graph";
1010
import * as taskRepository from "../../../lib/tasks/taskRepository.js";
1111
import {setLogLevel} from "@ui5/logger";
12+
import {isolatedUi5DataDir} from "../../utils/buildCacheIsolation.js";
1213

1314
// Using CommonsJS require since JSON module imports are still experimental
1415
const require = createRequire(import.meta.url);
@@ -100,6 +101,7 @@ test.serial("Build application.a", async (t) => {
100101
});
101102
graph.setTaskRepository(taskRepository);
102103
await graph.build({
104+
ui5DataDir: isolatedUi5DataDir(t),
103105
destPath,
104106
excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo"]
105107
});
@@ -121,6 +123,7 @@ test.serial("Build application.a with dependencies", async (t) => {
121123
});
122124
graph.setTaskRepository(taskRepository);
123125
await graph.build({
126+
ui5DataDir: isolatedUi5DataDir(t),
124127
destPath,
125128
excludedTasks: [
126129
"generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo",
@@ -146,6 +149,7 @@ test.serial("Build application.a with dependencies exclude", async (t) => {
146149
});
147150
graph.setTaskRepository(taskRepository);
148151
await graph.build({
152+
ui5DataDir: isolatedUi5DataDir(t),
149153
destPath,
150154
excludedTasks: [
151155
"generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo",
@@ -172,6 +176,7 @@ test.serial("Build application.a self-contained", async (t) => {
172176
});
173177
graph.setTaskRepository(taskRepository);
174178
await graph.build({
179+
ui5DataDir: isolatedUi5DataDir(t),
175180
destPath,
176181
excludedTasks: ["generateComponentPreload", "generateVersionInfo"],
177182
selfContained: true
@@ -194,6 +199,7 @@ test.serial("Build application.a with dependencies self-contained", async (t) =>
194199
});
195200
graph.setTaskRepository(taskRepository);
196201
await graph.build({
202+
ui5DataDir: isolatedUi5DataDir(t),
197203
destPath,
198204
excludedTasks: [
199205
"generateComponentPreload", "generateVersionInfo", "escapeNonAsciiCharacters",
@@ -253,6 +259,7 @@ test.serial("Build application.g", async (t) => {
253259
});
254260
graph.setTaskRepository(taskRepository);
255261
await graph.build({
262+
ui5DataDir: isolatedUi5DataDir(t),
256263
destPath,
257264
excludedTasks: ["generateVersionInfo"]
258265
});
@@ -274,6 +281,7 @@ test.serial("Build application.g with component preload paths", async (t) => {
274281
});
275282
graph.setTaskRepository(taskRepository);
276283
await graph.build({
284+
ui5DataDir: isolatedUi5DataDir(t),
277285
destPath,
278286
excludedTasks: ["generateVersionInfo"]
279287
});
@@ -295,6 +303,7 @@ test.serial("Build application.g with excludes", async (t) => {
295303
});
296304
graph.setTaskRepository(taskRepository);
297305
await graph.build({
306+
ui5DataDir: isolatedUi5DataDir(t),
298307
destPath,
299308
excludedTasks: ["*"]
300309
});
@@ -316,6 +325,7 @@ test.serial("Build application.h", async (t) => {
316325
});
317326
graph.setTaskRepository(taskRepository);
318327
await graph.build({
328+
ui5DataDir: isolatedUi5DataDir(t),
319329
destPath,
320330
excludedTasks: ["generateComponentPreload",
321331
"generateStandaloneAppBundle", "generateVersionInfo"]
@@ -338,6 +348,7 @@ test.serial("Build application.h (no minify)", async (t) => {
338348
});
339349
graph.setTaskRepository(taskRepository);
340350
await graph.build({
351+
ui5DataDir: isolatedUi5DataDir(t),
341352
destPath,
342353
excludedTasks: ["minify", "generateComponentPreload",
343354
"generateStandaloneAppBundle", "generateVersionInfo"]
@@ -360,6 +371,7 @@ test.serial("Build application.i", async (t) => {
360371
});
361372
graph.setTaskRepository(taskRepository);
362373
await graph.build({
374+
ui5DataDir: isolatedUi5DataDir(t),
363375
destPath,
364376
excludedTasks: ["generateVersionInfo"]
365377
});
@@ -381,6 +393,7 @@ test.serial("Build application.j", async (t) => {
381393
});
382394
graph.setTaskRepository(taskRepository);
383395
await graph.build({
396+
ui5DataDir: isolatedUi5DataDir(t),
384397
destPath,
385398
excludedTasks: ["generateVersionInfo"]
386399
});
@@ -408,6 +421,7 @@ test.serial("Build application.j with resources.json and version info", async (t
408421
});
409422
graph.setTaskRepository(taskRepository);
410423
await graph.build({
424+
ui5DataDir: isolatedUi5DataDir(t),
411425
destPath,
412426
includedTasks: ["generateResourcesJson", "generateVersionInfo"]
413427
});
@@ -429,6 +443,7 @@ test.serial("Build application.k (componentPreload excludes)", async (t) => {
429443
});
430444
graph.setTaskRepository(taskRepository);
431445
await graph.build({
446+
ui5DataDir: isolatedUi5DataDir(t),
432447
destPath,
433448
includedTasks: ["generateComponentPreload"],
434449
excludedTasks: ["*"]
@@ -451,6 +466,7 @@ test.serial("Build application.k (package sub-components / componentPreload excl
451466
});
452467
graph.setTaskRepository(taskRepository);
453468
await graph.build({
469+
ui5DataDir: isolatedUi5DataDir(t),
454470
destPath,
455471
includedTasks: ["generateComponentPreload"],
456472
excludedTasks: ["*"]
@@ -473,6 +489,7 @@ test.serial("Build application.l: minification excludes, w/ namespace", async (t
473489
});
474490
graph.setTaskRepository(taskRepository);
475491
await graph.build({
492+
ui5DataDir: isolatedUi5DataDir(t),
476493
destPath,
477494
excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo"]
478495
});
@@ -494,6 +511,7 @@ test.serial("Build application.m: bundle should not contain hashbang but an empt
494511
});
495512
graph.setTaskRepository(taskRepository);
496513
await graph.build({
514+
ui5DataDir: isolatedUi5DataDir(t),
497515
destPath
498516
});
499517

@@ -514,6 +532,7 @@ test.serial("Build application.ø", async (t) => {
514532
});
515533
graph.setTaskRepository(taskRepository);
516534
await graph.build({
535+
ui5DataDir: isolatedUi5DataDir(t),
517536
destPath,
518537
excludedTasks: ["generateVersionInfo"]
519538
});
@@ -535,6 +554,7 @@ test.serial("Build library.d with copyright from .library file", async (t) => {
535554
});
536555
graph.setTaskRepository(taskRepository);
537556
await graph.build({
557+
ui5DataDir: isolatedUi5DataDir(t),
538558
destPath,
539559
excludedTasks: ["generateLibraryPreload"]
540560
});
@@ -556,6 +576,7 @@ test.serial("Build library.e with copyright from metadata configuration of tree"
556576
});
557577
graph.setTaskRepository(taskRepository);
558578
await graph.build({
579+
ui5DataDir: isolatedUi5DataDir(t),
559580
destPath,
560581
excludedTasks: ["generateLibraryPreload"]
561582
});
@@ -581,6 +602,7 @@ test.serial("Build library.e with build manifest", async (t) => {
581602
});
582603
graph.setTaskRepository(taskRepository);
583604
await graph.build({
605+
ui5DataDir: isolatedUi5DataDir(t),
584606
destPath,
585607
createBuildManifest: true
586608
});
@@ -656,6 +678,7 @@ test.serial("Build library.h with custom bundles and component-preloads", async
656678
});
657679
graph.setTaskRepository(taskRepository);
658680
await graph.build({
681+
ui5DataDir: isolatedUi5DataDir(t),
659682
destPath,
660683
excludedTasks: ["generateLibraryPreload"]
661684
});
@@ -677,6 +700,7 @@ test.serial("Build library.h with custom bundles and component-preloads (no mini
677700
});
678701
graph.setTaskRepository(taskRepository);
679702
await graph.build({
703+
ui5DataDir: isolatedUi5DataDir(t),
680704
destPath,
681705
excludedTasks: ["minify", "generateLibraryPreload"]
682706
});
@@ -702,6 +726,7 @@ test.serial("Build library.h w/ custom bundles, component-preloads, resources.js
702726
});
703727
graph.setTaskRepository(taskRepository);
704728
await graph.build({
729+
ui5DataDir: isolatedUi5DataDir(t),
705730
destPath,
706731
createBuildManifest: true,
707732
includedTasks: ["generateResourcesJson"],
@@ -851,6 +876,7 @@ test.serial("Build library.i with manifest info taken from .library and library.
851876
});
852877
graph.setTaskRepository(taskRepository);
853878
await graph.build({
879+
ui5DataDir: isolatedUi5DataDir(t),
854880
destPath,
855881
excludedTasks: ["generateLibraryPreload", "minify"]
856882
});
@@ -872,6 +898,7 @@ test.serial("Build library.j with JSDoc build only", async (t) => {
872898
});
873899
graph.setTaskRepository(taskRepository);
874900
await graph.build({
901+
ui5DataDir: isolatedUi5DataDir(t),
875902
destPath,
876903
includedTasks: ["generateJsdoc"],
877904
excludedTasks: ["*"]
@@ -898,6 +925,7 @@ test.serial("Build library.i, bundling library.h", async (t) => {
898925
});
899926
graph.setTaskRepository(taskRepository);
900927
await graph.build({
928+
ui5DataDir: isolatedUi5DataDir(t),
901929
destPath,
902930
excludedTasks: ["generateLibraryPreload"]
903931
});
@@ -1006,6 +1034,7 @@ test.serial("Build library.l", async (t) => {
10061034
});
10071035
graph.setTaskRepository(taskRepository);
10081036
await graph.build({
1037+
ui5DataDir: isolatedUi5DataDir(t),
10091038
destPath,
10101039
excludedTasks: ["generateLibraryManifest", "generateLibraryPreload"]
10111040
});
@@ -1027,6 +1056,7 @@ test.serial("Build theme.j even without an library", async (t) => {
10271056
});
10281057
graph.setTaskRepository(taskRepository);
10291058
await graph.build({
1059+
ui5DataDir: isolatedUi5DataDir(t),
10301060
destPath
10311061
});
10321062

@@ -1047,6 +1077,7 @@ test.serial("Build theme.j even without an library with resources.json", async (
10471077
});
10481078
graph.setTaskRepository(taskRepository);
10491079
await graph.build({
1080+
ui5DataDir: isolatedUi5DataDir(t),
10501081
destPath,
10511082
includedTasks: [
10521083
"generateResourcesJson"
@@ -1074,6 +1105,7 @@ test.serial("Build theme.j with build manifest", async (t) => {
10741105
});
10751106
graph.setTaskRepository(taskRepository);
10761107
await graph.build({
1108+
ui5DataDir: isolatedUi5DataDir(t),
10771109
destPath,
10781110
createBuildManifest: true
10791111
});
@@ -1130,6 +1162,7 @@ test.serial("Build library.ø", async (t) => {
11301162
});
11311163
graph.setTaskRepository(taskRepository);
11321164
await graph.build({
1165+
ui5DataDir: isolatedUi5DataDir(t),
11331166
destPath
11341167
});
11351168

@@ -1158,6 +1191,7 @@ test.serial("Build library.coreBuildtime: replaceBuildtime", async (t) => {
11581191
});
11591192
graph.setTaskRepository(taskRepository);
11601193
await graph.build({
1194+
ui5DataDir: isolatedUi5DataDir(t),
11611195
destPath,
11621196
excludedTasks: ["generateLibraryManifest", "generateLibraryPreload"]
11631197
});
@@ -1181,6 +1215,7 @@ test.serial("Build library with theme configured for CSS variables", async (t) =
11811215
});
11821216
graph.setTaskRepository(taskRepository);
11831217
await graph.build({
1218+
ui5DataDir: isolatedUi5DataDir(t),
11841219
destPath,
11851220
cssVariables: true,
11861221
});
@@ -1202,6 +1237,7 @@ test.serial("Build library with theme configured for CSS variables and theme des
12021237
});
12031238
graph.setTaskRepository(taskRepository);
12041239
await graph.build({
1240+
ui5DataDir: isolatedUi5DataDir(t),
12051241
destPath,
12061242
cssVariables: true,
12071243
includedTasks: ["generateThemeDesignerResources"]
@@ -1224,6 +1260,7 @@ test.serial("Build theme-library with CSS variables", async (t) => {
12241260
});
12251261
graph.setTaskRepository(taskRepository);
12261262
await graph.build({
1263+
ui5DataDir: isolatedUi5DataDir(t),
12271264
destPath,
12281265
cssVariables: true
12291266
});
@@ -1245,6 +1282,7 @@ test.serial("Build theme-library with CSS variables and theme designer resources
12451282
});
12461283
graph.setTaskRepository(taskRepository);
12471284
await graph.build({
1285+
ui5DataDir: isolatedUi5DataDir(t),
12481286
destPath,
12491287
cssVariables: true,
12501288
includedTasks: ["generateThemeDesignerResources"]
@@ -1267,6 +1305,7 @@ test.serial("Build library.o with terminologies and supportedLocales", async (t)
12671305
});
12681306
graph.setTaskRepository(taskRepository);
12691307
await graph.build({
1308+
ui5DataDir: isolatedUi5DataDir(t),
12701309
destPath
12711310
});
12721311

@@ -1287,6 +1326,7 @@ test.serial("Build application.o with terminologies and supportedLocales", async
12871326
});
12881327
graph.setTaskRepository(taskRepository);
12891328
await graph.build({
1329+
ui5DataDir: isolatedUi5DataDir(t),
12901330
destPath
12911331
});
12921332

packages/builder/test/lib/builder/sourceMaps.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import lineColumn from "line-column";
99
import {graphFromPackageDependencies} from "@ui5/project/graph";
1010
import * as taskRepository from "../../../lib/tasks/taskRepository.js";
11+
import {isolatedUi5DataDir} from "../../utils/buildCacheIsolation.js";
1112

1213
const applicationURL = new URL("../../fixtures/sourcemaps/test.application/", import.meta.url);
1314
const applicationDestRootURL = new URL("../../tmp/build/sourcemaps/test.application/", import.meta.url);
@@ -64,6 +65,7 @@ test.serial("Verify source maps (test.application)", async (t) => {
6465
graph.setTaskRepository(taskRepository);
6566

6667
await graph.build({
68+
ui5DataDir: isolatedUi5DataDir(t),
6769
destPath: fileURLToPath(destURL)
6870
});
6971

packages/builder/test/lib/tasks/bundlers/generateLibraryPreload.integration.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {graphFromObject} from "@ui5/project/graph";
66
import {directoryDeepEqual, fileEqual, findFiles} from "../../../utils/fshelper.js";
77
import generateLibraryPreload from "../../../../lib/tasks/bundlers/generateLibraryPreload.js";
88
import * as taskRepository from "../../../../lib/tasks/taskRepository.js";
9+
import {isolatedUi5DataDir} from "../../../utils/buildCacheIsolation.js";
910

1011
const __dirname = import.meta.dirname;
1112
const libraryDPath = path.join(__dirname, "..", "..", "..", "fixtures", "library.d");
@@ -24,6 +25,7 @@ test.serial("integration: build library.d with library preload", async (t) => {
2425
});
2526
graph.setTaskRepository(taskRepository);
2627
await t.notThrowsAsync(graph.build({
28+
ui5DataDir: isolatedUi5DataDir(t),
2729
destPath,
2830
excludedTasks,
2931
includedTasks
@@ -77,6 +79,7 @@ test.serial("integration: build library.d-minified with library preload", async
7779
});
7880
graph.setTaskRepository(taskRepository);
7981
await t.notThrowsAsync(graph.build({
82+
ui5DataDir: isolatedUi5DataDir(t),
8083
destPath,
8184
excludedTasks,
8285
includedTasks
@@ -130,6 +133,7 @@ test.serial("integration: build sap.ui.core with library preload", async (t) =>
130133
});
131134
graph.setTaskRepository(taskRepository);
132135
await t.notThrowsAsync(graph.build({
136+
ui5DataDir: isolatedUi5DataDir(t),
133137
destPath,
134138
excludedTasks,
135139
includedTasks
@@ -333,6 +337,7 @@ test.serial("integration: build library.n without enabled string bundling", asyn
333337
});
334338
graph.setTaskRepository(taskRepository);
335339
await t.notThrowsAsync(graph.build({
340+
ui5DataDir: isolatedUi5DataDir(t),
336341
destPath,
337342
excludedTasks,
338343
includedTasks
@@ -378,6 +383,7 @@ test.serial("integration: build library.n with enabled string bundling", async (
378383
});
379384
graph.setTaskRepository(taskRepository);
380385
await t.notThrowsAsync(graph.build({
386+
ui5DataDir: isolatedUi5DataDir(t),
381387
destPath,
382388
excludedTasks,
383389
includedTasks

0 commit comments

Comments
 (0)