Skip to content

Commit 121c9ca

Browse files
committed
Drop client from triggerBuilds
1 parent 110a6a4 commit 121c9ca

File tree

3 files changed

+15
-47
lines changed

3 files changed

+15
-47
lines changed

Sources/App/Commands/TriggerBuilds.swift

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ struct TriggerBuildsCommand: AsyncCommand {
8585
}
8686

8787
do {
88-
try await triggerBuilds(on: context.application.db,
89-
client: context.application.client,
90-
mode: mode)
88+
try await triggerBuilds(on: context.application.db, mode: mode)
9189
} catch {
9290
Current.logger().critical("\(error)")
9391
}
@@ -122,10 +120,7 @@ extension TriggerBuildsCommand {
122120
/// - client: `Client` used for http request
123121
/// - parameter: `BuildTriggerCommand.Parameter` holding either a list of package ids
124122
/// or a fetch limit for candidate selection.
125-
#warning("remove client")
126-
func triggerBuilds(on database: Database,
127-
client: Client,
128-
mode: TriggerBuildsCommand.Mode) async throws {
123+
func triggerBuilds(on database: Database, mode: TriggerBuildsCommand.Mode) async throws {
129124
@Dependency(\.environment) var environment
130125
let start = DispatchTime.now().uptimeNanoseconds
131126

@@ -139,15 +134,12 @@ func triggerBuilds(on database: Database,
139134
AppMetrics.buildCandidatesCount?.set(candidates.count)
140135

141136
let limitedCandidates = Array(candidates.prefix(limit))
142-
try await triggerBuilds(on: database,
143-
client: client,
144-
packages: limitedCandidates)
137+
try await triggerBuilds(on: database, packages: limitedCandidates)
145138
AppMetrics.buildTriggerDurationSeconds?.time(since: start)
146139

147140
case let .packageId(id, force):
148141
Current.logger().info("Triggering builds (packageID: \(id)) ...")
149142
try await triggerBuilds(on: database,
150-
client: client,
151143
packages: [id],
152144
force: force)
153145
AppMetrics.buildTriggerDurationSeconds?.time(since: start)
@@ -173,9 +165,7 @@ func triggerBuilds(on database: Database,
173165
/// - client: `Client` used for http request
174166
/// - packages: list of `Package.Id`s to trigger
175167
/// - force: do not check pipeline capacity and ignore downscaling
176-
#warning("remove client")
177168
func triggerBuilds(on database: Database,
178-
client: Client,
179169
packages: [Package.Id],
180170
force: Bool = false) async throws {
181171
@Dependency(\.environment) var environment

Tests/AppTests/BuildTriggerTests.swift

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,7 @@ class BuildTriggerTests: AppTestCase {
550550
.save(on: app.db)
551551

552552
// MUT
553-
try await triggerBuilds(on: app.db,
554-
client: app.client,
555-
mode: .packageId(pkgId, force: false))
553+
try await triggerBuilds(on: app.db, mode: .packageId(pkgId, force: false))
556554

557555
// validate
558556
XCTAssertEqual(triggerCount.value, 0)
@@ -577,9 +575,7 @@ class BuildTriggerTests: AppTestCase {
577575
.save(on: app.db)
578576

579577
// MUT
580-
try await triggerBuilds(on: app.db,
581-
client: app.client,
582-
mode: .packageId(pkgId, force: false))
578+
try await triggerBuilds(on: app.db, mode: .packageId(pkgId, force: false))
583579

584580
// validate
585581
XCTAssertEqual(triggerCount.value, 27)
@@ -604,9 +600,7 @@ class BuildTriggerTests: AppTestCase {
604600
.save(on: app.db)
605601

606602
// MUT
607-
try await triggerBuilds(on: app.db,
608-
client: app.client,
609-
mode: .packageId(pkgId, force: true))
603+
try await triggerBuilds(on: app.db, mode: .packageId(pkgId, force: true))
610604

611605
// validate
612606
XCTAssertEqual(triggerCount.value, 27)
@@ -653,9 +647,7 @@ class BuildTriggerTests: AppTestCase {
653647
}
654648

655649
// MUT
656-
try await triggerBuilds(on: app.db,
657-
client: app.client,
658-
mode: .limit(4))
650+
try await triggerBuilds(on: app.db, mode: .limit(4))
659651

660652
// validate - only the first batch must be allowed to trigger
661653
XCTAssertEqual(triggerCount.value, 27)
@@ -692,9 +684,7 @@ class BuildTriggerTests: AppTestCase {
692684
try await XCTAssertEqualAsync(try await Build.query(on: db).count(), 1)
693685

694686
// MUT
695-
try await triggerBuilds(on: app.db,
696-
client: client,
697-
mode: .packageId(p.id!, force: false))
687+
try await triggerBuilds(on: app.db, mode: .packageId(p.id!, force: false))
698688

699689
// validate
700690
let count = try await Build.query(on: app.db).count()
@@ -736,9 +726,7 @@ class BuildTriggerTests: AppTestCase {
736726
try await v.save(on: app.db)
737727

738728
// MUT
739-
try await triggerBuilds(on: app.db,
740-
client: app.client,
741-
mode: .packageId(.id0, force: false))
729+
try await triggerBuilds(on: app.db, mode: .packageId(.id0, force: false))
742730

743731
// validate that one build record is saved, for the successful trigger
744732
let count = try await Build.query(on: app.db).count()
@@ -848,9 +836,7 @@ class BuildTriggerTests: AppTestCase {
848836
.save(on: app.db)
849837

850838
// MUT
851-
try await triggerBuilds(on: app.db,
852-
client: app.client,
853-
mode: .packageId(pkgId, force: false))
839+
try await triggerBuilds(on: app.db, mode: .packageId(pkgId, force: false))
854840

855841
// validate
856842
XCTAssertEqual(triggerCount.value, 0)
@@ -870,9 +856,7 @@ class BuildTriggerTests: AppTestCase {
870856
.save(on: app.db)
871857

872858
// MUT
873-
try await triggerBuilds(on: app.db,
874-
client: app.client,
875-
mode: .packageId(pkgId, force: false))
859+
try await triggerBuilds(on: app.db, mode: .packageId(pkgId, force: false))
876860

877861
// validate
878862
XCTAssertEqual(triggerCount.value, 27)
@@ -912,9 +896,7 @@ class BuildTriggerTests: AppTestCase {
912896
.save(on: app.db)
913897

914898
// MUT
915-
try await triggerBuilds(on: app.db,
916-
client: app.client,
917-
mode: .packageId(pkgId, force: false))
899+
try await triggerBuilds(on: app.db, mode: .packageId(pkgId, force: false))
918900

919901
// validate
920902
XCTAssertEqual(triggerCount.value, 0)
@@ -934,9 +916,7 @@ class BuildTriggerTests: AppTestCase {
934916
.save(on: app.db)
935917

936918
// MUT
937-
try await triggerBuilds(on: app.db,
938-
client: app.client,
939-
mode: .packageId(pkgId, force: false))
919+
try await triggerBuilds(on: app.db, mode: .packageId(pkgId, force: false))
940920

941921
// validate
942922
XCTAssertEqual(triggerCount.value, 27)
@@ -975,9 +955,7 @@ class BuildTriggerTests: AppTestCase {
975955
.save(on: app.db)
976956

977957
// MUT
978-
try await triggerBuilds(on: app.db,
979-
client: app.client,
980-
mode: .packageId(.id0, force: false))
958+
try await triggerBuilds(on: app.db, mode: .packageId(.id0, force: false))
981959

982960
// validate
983961
XCTAssertEqual(triggerCount.value, 27)

Tests/AppTests/MetricsTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class MetricsTests: AppTestCase {
147147
let pkg = try await savePackage(on: app.db, "1")
148148

149149
// MUT
150-
try await triggerBuilds(on: app.db, client: app.client, mode: .packageId(pkg.id!, force: true))
150+
try await triggerBuilds(on: app.db, mode: .packageId(pkg.id!, force: true))
151151

152152
// validation
153153
XCTAssert((AppMetrics.buildTriggerDurationSeconds?.get()) ?? 0 > 0)

0 commit comments

Comments
 (0)