Skip to content

Commit d581634

Browse files
committed
mark snapshots with failed rebuilds as vintage
1 parent 3d50dc6 commit d581634

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed

Sources/UnidocDB/Snapshots/Unidoc.DB.Snapshots.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ extension Unidoc.DB.Snapshots
4040
}
4141

4242
public static
43-
let indexSymbolGraphABI:Mongo.CollectionIndex = .init("ABI",
43+
let indexSymbolGraphABI:Mongo.CollectionIndex = .init("ABI/2",
4444
unique: false)
4545
{
46+
$0[Unidoc.Snapshot[.vintage]] = (+)
4647
$0[Unidoc.Snapshot[.metadata] / SymbolGraphMetadata[.abi]] = (+)
4748
}
4849

@@ -207,6 +208,9 @@ extension Unidoc.DB.Snapshots
207208
{
208209
$0[.filter]
209210
{
211+
// This needs to be ``BSON.Null`` and not just `{ $0[.exists] = false }`,
212+
// otherwise it will not use the partial index.
213+
$0[Unidoc.Snapshot[.vintage]] = BSON.Null.init()
210214
$0[Unidoc.Snapshot[.metadata] / SymbolGraphMetadata[.abi]]
211215
{
212216
$0[.lt] = version

Sources/UnidocRecords/Packages/Unidoc.Snapshot.swift

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,34 @@ extension Unidoc
3939
public
4040
var size:Int64
4141

42-
@inlinable internal
42+
/// Indicates if the symbol graph is no longer buildable from source. This flag prevents
43+
/// the automated build system from repeatedly attempting to build the package.
44+
///
45+
/// Possible reasons for this include:
46+
///
47+
/// - The package no longer compiles using the latest version of its dependencies,
48+
/// and its manifest does not constrain the dependencies to compatible versions.
49+
///
50+
/// - The package, or one of its dependencies, has been taken down from GitHub.
51+
///
52+
/// - The package only builds on a platform that is no longer supported by the hosting
53+
/// service.
54+
///
55+
/// - The package suffers from a Swift (or Unidoc) compiler bug that prevents it from
56+
/// being built.
57+
public
58+
var vintage:Bool
59+
60+
@inlinable
4361
init(id:Edition,
4462
metadata:SymbolGraphMetadata,
4563
inline:SymbolGraph?,
4664
action:LinkerAction?,
4765
swift:PatchVersion?,
4866
pins:[Edition?],
4967
type:GraphType,
50-
size:Int64)
68+
size:Int64,
69+
vintage:Bool)
5170
{
5271
self.id = id
5372
self.metadata = metadata
@@ -57,6 +76,7 @@ extension Unidoc
5776
self.pins = pins
5877
self.type = type
5978
self.size = size
79+
self.vintage = vintage
6080
}
6181
}
6282
}
@@ -87,7 +107,8 @@ extension Unidoc.Snapshot
87107
swift: swift,
88108
pins: [],
89109
type: .bson,
90-
size: 0)
110+
size: 0,
111+
vintage: false)
91112
}
92113
}
93114
extension Unidoc.Snapshot
@@ -155,6 +176,7 @@ extension Unidoc.Snapshot
155176
case pins = "p"
156177
case type = "T"
157178
case size = "B"
179+
case vintage = "V"
158180

159181
@available(*, deprecated, renamed: "inline")
160182
@inlinable public static
@@ -179,6 +201,7 @@ extension Unidoc.Snapshot:BSONDocumentEncodable
179201
bson[.pins] = self.pins.isEmpty ? nil : self.pins
180202
bson[.type] = self.type
181203
bson[.size] = self.size
204+
bson[.vintage] = self.vintage ? true : nil
182205
}
183206
}
184207
extension Unidoc.Snapshot:BSONDocumentDecodable
@@ -193,6 +216,7 @@ extension Unidoc.Snapshot:BSONDocumentDecodable
193216
swift: try bson[.swift]?.decode(),
194217
pins: try bson[.pins]?.decode() ?? [],
195218
type: try bson[.type]?.decode() ?? .bson,
196-
size: try bson[.size]?.decode() ?? 0)
219+
size: try bson[.size]?.decode() ?? 0,
220+
vintage: try bson[.vintage]?.decode() ?? false)
197221
}
198222
}

Sources/UnidocServer/Operations/Procedures/Unidoc.BuilderUploadOperation.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,25 @@ extension Unidoc.BuilderUploadOperation:Unidoc.BlockingOperation
7272

7373
try await db.completeBuilds.upsert(complete)
7474

75-
if case .success(let snapshot) = build.outcome
75+
switch build.outcome
7676
{
77+
case .success(let snapshot):
7778
try await db.snapshots.upsert(snapshot)
7879

7980
/// A successful (labeled) build also sets the platform preference, since we now
8081
/// know that the package can be built on that platform.
8182
let _:Unidoc.PackageMetadata? = try await db.packages.reset(
8283
platformPreference: snapshot.metadata.triple,
8384
of: snapshot.id.package)
85+
86+
case .failure:
87+
// Mark the snapshot as unbuildable, so that automated plugins don’t try to
88+
// build it again.
89+
let _:Unidoc.Snapshot? = try await db.snapshots.modify(
90+
existing: complete.id.edition)
91+
{
92+
$0[.set] { $0[Unidoc.Snapshot[.vintage]] = true }
93+
}
8494
}
8595

8696
case .labeling:

0 commit comments

Comments
 (0)