Skip to content

Commit

Permalink
Merge pull request #331 from tayloraswift/per-edition-builds
Browse files Browse the repository at this point in the history
track running builds and completed builds separately
  • Loading branch information
tayloraswift authored Sep 7, 2024
2 parents a26917a + edfecaf commit 48b03c2
Show file tree
Hide file tree
Showing 86 changed files with 4,575 additions and 2,020 deletions.
2,299 changes: 2,298 additions & 1 deletion Assets/css/Main.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Assets/css/Main.css.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extension Availability
case macCatalyst
case openBSD = "OpenBSD"
case tvOS
case visionOS
case watchOS
case windows = "Windows"

Expand Down Expand Up @@ -41,6 +42,7 @@ extension Availability.PlatformDomain:CustomStringConvertible
case .macCatalyst: "Mac Catalyst"
case .openBSD: "OpenBSD"
case .tvOS: "tvOS"
case .visionOS: "visionOS"
case .watchOS: "watchOS"
case .windows: "Windows"
case .iOSApplicationExtension: "iOS App Extension"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extension Availability.CodingKey:RawRepresentable
case "m": self.init(.platform(.macOS))
case "c": self.init(.platform(.macCatalyst))
case "t": self.init(.platform(.tvOS))
case "v": self.init(.platform(.visionOS))
case "w": self.init(.platform(.watchOS))
case "n": self.init(.platform(.windows))
case "o": self.init(.platform(.openBSD))
Expand All @@ -54,6 +55,7 @@ extension Availability.CodingKey:RawRepresentable
case .platform(.macOS): "m"
case .platform(.macCatalyst): "c"
case .platform(.tvOS): "t"
case .platform(.visionOS): "v"
case .platform(.watchOS): "w"
case .platform(.windows): "n"
case .platform(.openBSD): "o"
Expand Down
2 changes: 1 addition & 1 deletion Sources/SymbolGraphs/SymbolGraphABI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import SemanticVersions
@frozen public
enum SymbolGraphABI
{
@inlinable public static var version:PatchVersion { .v(0, 11, 0) }
@inlinable public static var version:PatchVersion { .v(0, 11, 1) }
}
41 changes: 0 additions & 41 deletions Sources/Symbols/Identifiers/Symbol.Edition.swift

This file was deleted.

23 changes: 11 additions & 12 deletions Sources/Symbols/Identifiers/Symbol.PackageAtRef.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ extension Symbol
{
public
var package:Package
/// A name corresponding to a git ref.
public
var ref:Substring?
var ref:String

@inlinable public
init(package:Package, ref:Substring?)
init(package:Package, ref:String)
{
self.package = package
self.ref = ref
Expand All @@ -19,24 +20,22 @@ extension Symbol
extension Symbol.PackageAtRef:CustomStringConvertible
{
@inlinable public
var description:String
{
self.ref.map { "\(self.package)/\($0)" } ?? "\(self.package)"
}
var description:String { "\(self.package)/\(self.ref)" }
}
extension Symbol.PackageAtRef:LosslessStringConvertible
{
public
init(_ trunk:String)
@inlinable public
init?(_ description:some StringProtocol)
{
if let slash:String.Index = trunk.firstIndex(of: "/")
if let slash:String.Index = description.firstIndex(of: "/")
{
self.init(package: .init(trunk[..<slash]),
ref: trunk[trunk.index(after: slash)...])
self.init(
package: .init(description[..<slash]),
ref: .init(description[description.index(after: slash)...]))
}
else
{
self.init(package: .init(trunk), ref: nil)
return nil
}
}
}
52 changes: 11 additions & 41 deletions Sources/UnidocAPI/Building/Unidoc.BuildStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ extension Unidoc
struct BuildStatus
{
public
let request:Unidoc.BuildRequest<Void>?
let request:Edition
public
let stage:Unidoc.BuildStage?
let pending:BuildStage?
public
let failure:Unidoc.BuildFailure?
let failure:BuildFailure?

@inlinable public
init(request:Unidoc.BuildRequest<Void>?,
stage:Unidoc.BuildStage?,
failure:Unidoc.BuildFailure?)
init(request:Edition,
pending:Unidoc.BuildStage?,
failure:BuildFailure?)
{
self.request = request
self.stage = stage
self.pending = pending
self.failure = failure
}
}
Expand All @@ -29,8 +29,6 @@ extension Unidoc.BuildStatus
enum CodingKey:String, Sendable
{
case version
case series
case force
case stage
case failure
}
Expand All @@ -40,21 +38,8 @@ extension Unidoc.BuildStatus:JSONObjectEncodable
public
func encode(to json:inout JSON.ObjectEncoder<CodingKey>)
{
if let request:Unidoc.BuildRequest<Void> = self.request
{
switch request.version
{
case .latest(let series, of: ()):
json[.series] = series

case .id(let id):
json[.version] = id
}

json[.force] = request.rebuild
}

json[.stage] = self.stage
json[.version] = request
json[.stage] = self.pending
json[.failure] = self.failure
}
}
Expand All @@ -63,23 +48,8 @@ extension Unidoc.BuildStatus:JSONObjectDecodable
public
init(json:JSON.ObjectDecoder<CodingKey>) throws
{
let request:Unidoc.BuildRequest<Void>?
if let series:Unidoc.VersionSeries = try json[.series]?.decode()
{
request = .init(version: .latest(series), rebuild: try json[.force].decode())
}
else if
let id:Unidoc.Edition = try json[.version]?.decode()
{
request = .init(version: .id(id), rebuild: try json[.force].decode())
}
else
{
request = nil
}

self.init(request: request,
stage: try json[.stage]?.decode(),
self.init(request: try json[.version].decode(),
pending: try json[.stage]?.decode(),
failure: try json[.failure]?.decode())
}
}
17 changes: 2 additions & 15 deletions Sources/UnidocAPI/Building/Unidoc.EditionStateReport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ extension Unidoc.EditionStateReport
}
}
else if
let stage:Unidoc.BuildStage = build.stage
let stage:Unidoc.BuildStage = build.pending
{
switch stage
{
Expand All @@ -75,20 +75,7 @@ extension Unidoc.EditionStateReport
}
else
{
switch build.request?.version
{
case .latest?:
return .QUEUED_FLOATING_VERSION

case .id(self.id)?:
return .QUEUED

case .id?:
return .QUEUED_DIFFERENT_VERSION

case .none:
return .DEFAULT
}
return self.id == build.request ? .QUEUED : .QUEUED_DIFFERENT_VERSION
}
}
}
Expand Down
15 changes: 9 additions & 6 deletions Sources/UnidocClient/Unidoc.Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ extension Unidoc.Client<HTTP.Client2>
/// Listens for SSGC updates over the provided pipe, uploading any intermediate reports to
/// Unidoc server and returning the final report, without uploading it.
private
func stream(from pipe:FilePath, package:Unidoc.Package) async throws -> Unidoc.BuildFailure?
func stream(from pipe:FilePath, edition:Unidoc.Edition) async throws -> Unidoc.BuildFailure?
{
try await SSGC.StatusStream.read(from: pipe)
{
// Acknowledge the build request.
try? await self.connect
{
try await $0.upload(.init(package: package, entered: .cloningRepository))
try await $0.upload(.init(edition: edition, entered: .cloningRepository))
}

while let update:SSGC.StatusUpdate = try $0.next()
Expand Down Expand Up @@ -119,7 +119,7 @@ extension Unidoc.Client<HTTP.Client2>

try await self.connect
{
try await $0.upload(.init(package: package, entered: stage))
try await $0.upload(.init(edition: edition, entered: stage))
}
}

Expand Down Expand Up @@ -237,9 +237,9 @@ extension Unidoc.Client<HTTP.Client2>
}

let failure:Unidoc.BuildFailure? = try await self.stream(from: status,
package: labels.coordinate.package)
edition: labels.coordinate)

var artifact:Unidoc.BuildArtifact = .init(package: labels.coordinate.package,
var artifact:Unidoc.BuildArtifact = .init(edition: labels.coordinate,
outcome: .failure(failure ?? .failedForUnknownReason))

// Check the exit status of the child process.
Expand All @@ -254,10 +254,13 @@ extension Unidoc.Client<HTTP.Client2>
action: action))
}

/// Attach build logs.
// Attach build logs.
try artifact.attach(log: output, as: .ssgc)
try artifact.attach(log: diagnostics, as: .ssgcDiagnostics)

// If the repo URL contains a token, we should keep the logs secret.
artifact.logsAreSecret = labels.repo.contains("@")

artifact.seconds = (.now - started).components.seconds

try await self.connect
Expand Down
46 changes: 0 additions & 46 deletions Sources/UnidocDB/Building/Unidoc.BuildBehavior.swift

This file was deleted.

49 changes: 49 additions & 0 deletions Sources/UnidocDB/Building/Unidoc.BuildIdentifier.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import BSON
import MongoQL
import UnidocRecords
import UnixTime

extension Unidoc
{
@frozen public
struct BuildIdentifier:Equatable, Hashable, Sendable
{
public
let edition:Unidoc.Edition
public
let run:UnixMillisecond

@inlinable public
init(edition:Unidoc.Edition, run:UnixMillisecond)
{
self.edition = edition
self.run = run
}
}
}
extension Unidoc.BuildIdentifier:Mongo.MasterCodingModel
{
@frozen public
enum CodingKey:String, Sendable, BSONDecodable
{
case edition = "e"
case run = "T"
}
}
extension Unidoc.BuildIdentifier:BSONDocumentEncodable
{
public
func encode(to bson:inout BSON.DocumentEncoder<CodingKey>)
{
bson[.edition] = self.edition
bson[.run] = self.run
}
}
extension Unidoc.BuildIdentifier:BSONDocumentDecodable
{
@inlinable public
init(bson:BSON.DocumentDecoder<CodingKey>) throws
{
self.init(edition: try bson[.edition].decode(), run: try bson[.run].decode())
}
}
Loading

0 comments on commit 48b03c2

Please sign in to comment.