Skip to content

Commit 6a63f93

Browse files
Merge pull request #3467 from SwiftPackageIndex/add-rebuild-explainer
Add a PROCESSING_BUILD_BACKLOG flag and update the "missing compat info" message
2 parents 1583db5 + 29b5034 commit 6a63f93

File tree

6 files changed

+49
-24
lines changed

6 files changed

+49
-24
lines changed

Sources/App/Core/AppEnvironment.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ struct AppEnvironment: Sendable {
6464
var metricsPushGatewayUrl: @Sendable () -> String?
6565
var plausibleBackendReportingSiteID: @Sendable () -> String?
6666
var postPlausibleEvent: @Sendable (Client, Plausible.Event.Kind, Plausible.Path, User?) async throws -> Void
67+
var processingBuildBacklog: @Sendable () -> Bool
6768
var random: @Sendable (_ range: ClosedRange<Double>) -> Double
6869
var runnerIds: @Sendable () -> [String]
6970
var setHTTPClient: @Sendable (Client) -> Void
@@ -201,6 +202,9 @@ extension AppEnvironment {
201202
metricsPushGatewayUrl: { Environment.get("METRICS_PUSHGATEWAY_URL") },
202203
plausibleBackendReportingSiteID: { Environment.get("PLAUSIBLE_BACKEND_REPORTING_SITE_ID") },
203204
postPlausibleEvent: { client, kind, path, user in try await Plausible.postEvent(client: client, kind: kind, path: path, user: user) },
205+
processingBuildBacklog: {
206+
Environment.get("PROCESSING_BUILD_BACKLOG").flatMap(\.asBool) ?? false
207+
},
204208
random: { range in Double.random(in: range) },
205209
runnerIds: {
206210
Environment.get("RUNNER_IDS")

Sources/App/Views/PackageController/GetRoute.Model+ext.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,14 @@ extension API.PackageController.GetRoute.Model {
546546

547547
var hasBuildInfo: Bool { swiftVersionBuildInfo != nil || platformBuildInfo != nil }
548548

549+
func compatibilityInformation() -> Node<HTML.BodyContext> {
550+
.div(
551+
.class("matrices"),
552+
swiftVersionCompatibilityList(),
553+
platformCompatibilityList()
554+
)
555+
}
556+
549557
func swiftVersionCompatibilityList() -> Node<HTML.BodyContext> {
550558
guard let buildInfo = swiftVersionBuildInfo else { return .empty }
551559
let rows = Self.groupBuildInfo(buildInfo)
@@ -591,6 +599,35 @@ extension API.PackageController.GetRoute.Model {
591599
)
592600
)
593601
}
602+
603+
func noCompatibilityInformationExplainer() -> Node<HTML.BodyContext> {
604+
.if(Current.processingBuildBacklog(),
605+
.group(
606+
.p(
607+
.text("This package currently has no compatibility information. "),
608+
.strong("We are currently processing a large build job backlog and it may take much longer than usual for compatibility information to appear.")
609+
),
610+
.p(
611+
.text("You can see what builds the system is currently processing by checking the "),
612+
.a(
613+
.href(SiteURL.buildMonitor.relativeURL()),
614+
.text("build system monitoring page")
615+
),
616+
.text(".")
617+
)
618+
),
619+
else: .group(
620+
.p("This package currently has no compatibility information. The build jobs that determine compatibility have been queued and compatibility information will appear when they complete."),
621+
.p(
622+
.text("If this message persists for more than an hour, please "),
623+
.a(
624+
.href(ExternalURL.raiseNewIssue),
625+
.text("raise an issue")
626+
),
627+
.text(".")
628+
)
629+
))
630+
}
594631
}
595632

596633

Sources/App/Views/PackageController/PackageShow+View.swift

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -221,25 +221,8 @@ extension PackageShow {
221221
.text("Full Build Results")
222222
)
223223
),
224-
.div(
225-
.class("matrices"),
226-
.if(model.hasBuildInfo,
227-
.group(
228-
model.swiftVersionCompatibilityList(),
229-
model.platformCompatibilityList()
230-
),
231-
else: .group(
232-
.p(
233-
"This package currently has no compatibility information. Builds to determine package compatibility are starting, and compatibility information will appear soon. If this message persists for more than a few minutes, please ",
234-
.a(
235-
.href(ExternalURL.raiseNewIssue),
236-
"raise an issue"
237-
),
238-
"."
239-
)
240-
)
241-
)
242-
)
224+
.if(model.hasBuildInfo, model.compatibilityInformation(),
225+
else: model.noCompatibilityInformationExplainer())
243226
)
244227
}
245228

Tests/AppTests/Mocks/AppEnvironment+mock.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ extension AppEnvironment {
6363
metricsPushGatewayUrl: { "http://pushgateway:9091" },
6464
plausibleBackendReportingSiteID: { nil },
6565
postPlausibleEvent: { _, _, _, _ in },
66+
processingBuildBacklog: { false },
6667
random: { range in Double.random(in: range) },
6768
runnerIds: { [] },
6869
setHTTPClient: { client in Self.httpClient = client },

Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_no_builds.1.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,10 @@ <h4>When working with a Swift Package Manager manifest:</h4>
176176
<h3>Compatibility</h3>
177177
<a href="/Alamo/Alamofire/builds">Full Build Results</a>
178178
</div>
179-
<div class="matrices">
180-
<p>This package currently has no compatibility information. Builds to determine package compatibility are starting, and compatibility information will appear soon. If this message persists for more than a few minutes, please
181-
<a href="https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/new/choose">raise an issue</a>.
182-
</p>
183-
</div>
179+
<p>This package currently has no compatibility information. The build jobs that determine compatibility have been queued and compatibility information will appear when they complete.</p>
180+
<p>If this message persists for more than an hour, please
181+
<a href="https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/new/choose">raise an issue</a>.
182+
</p>
184183
</section>
185184
</section>
186185
<section>

app.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ x-shared: &shared
5656
MASTODON_ACCESS_TOKEN: ${MASTODON_ACCESS_TOKEN}
5757
METRICS_PUSHGATEWAY_URL: ${METRICS_PUSHGATEWAY_URL}
5858
PLAUSIBLE_BACKEND_REPORTING_SITE_ID: ${PLAUSIBLE_BACKEND_REPORTING_SITE_ID}
59+
PROCESSING_BUILD_BACKLOG: ${PROCESSING_BUILD_BACKLOG}
5960
RUNNER_IDS: ${RUNNER_IDS}
6061
SITE_URL: ${SITE_URL}
6162
SWIFT_BACKTRACE: ${SWIFT_BACKTRACE}

0 commit comments

Comments
 (0)