Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Commit 6a1efa4

Browse files
authored
Merge pull request #20 from vector-im/dbkr/pull_artifacts_before_all_builds
Pull the artifacts before doing any builds
2 parents 81b6dc9 + 54e0955 commit 6a1efa4

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/desktop_develop.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -241,19 +241,30 @@ class DesktopDevelopBuilder {
241241
poll = async () => {
242242
if (this.building) return;
243243

244-
const built = [];
244+
const toBuild = [];
245245
for (const type of TYPES) {
246246
const nextBuildDue = getNextBuildTime(new Date(Math.max(
247247
this.lastBuildTimes[type], this.lastFailTimes[type],
248248
)));
249249
//logger.debug("Next build due at " + nextBuildDue);
250250
if (nextBuildDue.getTime() < Date.now()) {
251+
toBuild.push(type);
252+
}
253+
}
254+
255+
if (toBuild.length === 0) return;
256+
257+
try {
258+
this.building = true;
259+
260+
// Sync all the artifacts from the server before we start
261+
await pullArtifacts(this.pubDir, this.rsyncRoot);
262+
263+
for (const type of toBuild) {
251264
try {
252-
this.building = true;
253265
logger.info("Starting build of " + type);
254266
const thisBuildVersion = getBuildVersion();
255267
await this.build(type, thisBuildVersion);
256-
built.push(type);
257268
this.lastBuildTimes[type] = Date.now();
258269
await putLastBuildTime(type, this.lastBuildTimes[type]);
259270
} catch (e) {
@@ -262,16 +273,14 @@ class DesktopDevelopBuilder {
262273
// if one fails, bail out of the whole process: probably better
263274
// to have all platforms not updating than just one
264275
return;
265-
} finally {
266-
this.building = false;
267276
}
268277
}
269-
}
270278

271-
if (built.length > 0) {
272-
logger.info("Built packages for: " + built.join(', ') + ": pushing packages...");
279+
logger.info("Built packages for: " + toBuild.join(', ') + ": pushing packages...");
273280
await pushArtifacts(this.pubDir, this.rsyncRoot);
274281
logger.info("...push complete!");
282+
} finally {
283+
this.building = false;
275284
}
276285
}
277286

@@ -378,11 +387,6 @@ class DesktopDevelopBuilder {
378387
await pruneBuilds(path.join(this.appPubDir, 'update', 'macos'), /-mac.zip$/);
379388
} else if (type === 'linux') {
380389
await pullDebDatabase(this.debDir, this.rsyncRoot);
381-
// This is a bit of an odd place to do this, but we only actually need it for the
382-
// debian repo (but we may as well keep everything in sync). Doing it here means we
383-
// do it as soon as possible before modifying the content so minimises any chance of
384-
// conflict.
385-
await pullArtifacts(this.pubDir, this.rsyncRoot);
386390
for (const f of await getMatchingFilesInDir(path.join(repoDir, 'dist'), /\.deb$/)) {
387391
await addDeb(this.debDir, path.resolve(repoDir, 'dist', f));
388392
}

0 commit comments

Comments
 (0)