Project updates from Template
This commit contains the latest updates from the generic Website template, which move the toolchain to Swift 6.4, gate analytics and structured data behind traits, and rework page routing: - Updated the Swift toolchain for all the package dependencies and the Website service to version 6.4. (345b305) - Adapted all the existing middlewares in the Infrastructure package to Swift 6.4. (26008df) - Moved test resource teardown in the Persistence and the Website library into defer blocks. (27984a9) - Gated analytics behind a trait and reworked structured data in the Infrastructure package. (c7d4769) - Enabled the Analytics trait in the Website service. (f6a6bbd) - Reworked page routing in the Website service. (d1cb2c1) - Gated the structured data features in the Infrastructure package behind a trait. (f0a8791) - Enabled the StructuredData trait of the Infrastructure package in the Website service. (bbfdeb3) - Fixed the asset pin and a build warning in the Dockerfile of the Website service. (6ed0f9b) The root README change in 345b305 was left out, as this project no longer carries that file. From d1cb2c1, the RootController rework was left out, as the prototype serves a session-aware landing page and routes its other pages through their own controllers; the view-event reporter was appended to the prototype's shared script instead. The prototype code was adapted to the stricter Swift 6.4 settings: `String(format:)` was swapped for safe formatting, the NoIndex middleware takes a `@concurrent` next handler, and the tests flagged by warnings-as-errors were tightened. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
326299fc35
commit
911424de24
57 files changed
+864
-273
No files matched your search
@@ -1,4 +1,4 @@
|
||||
// swift-tools-version: 6.3
|
||||
// swift-tools-version: 6.4
|
||||
|
||||
import PackageDescription
|
||||
|
||||
@@ -97,3 +97,15 @@ let package = Package(
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
// Applied to every target: strict memory safety and warnings as errors as guardrails — deprecations stay warnings, so a
|
||||
// dependency update cannot break the build — plus the upcoming concurrency features Swift 7 turns on by default.
|
||||
for target in package.targets {
|
||||
target.swiftSettings = (target.swiftSettings ?? []) + [
|
||||
.strictMemorySafety(),
|
||||
.treatAllWarnings(as: .error),
|
||||
.treatWarning("DeprecatedDeclaration", as: .warning),
|
||||
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances"),
|
||||
]
|
||||
}
|
||||
@@ -58,6 +58,6 @@ Outside the application's service group, a built `Fluent` service must be shut d
|
||||
Every suite carries a tag for the kind of API it exercises — `.enumeration` or `.method`, declared in `Tests/Utils/Extensions/Tag+Constants.swift` — so test plans and summaries can slice a run by kind. A new suite adopts the tag matching its subject, or adds one when none fits.
|
||||
|
||||
## Requirements
|
||||
- Swift 6.3 toolchain (`swift-tools-version:6.3`).
|
||||
- Swift 6.4 toolchain (`swift-tools-version:6.4`).
|
||||
- macOS 15, matching the sibling packages (the services deploy to Linux containers; the packages carry no UI platforms).
|
||||
- Package dependencies: `hummingbird-fluent`, `fluent-postgres-driver`, `fluent-sqlite-driver`, `sql-kit`, `postgres-nio`, and `swift-nio-ssl`; the test target additionally depends on `swift-nio` for the TLS fallback tests' fake server.
|
||||
@@ -136,7 +136,7 @@ public extension Listing {
|
||||
/// The grade or condition in a few words: `CGC 9.8` for a slab, `Raw · NM` for a raw issue, the condition alone for a collected edition.
|
||||
var gradeLabel: String {
|
||||
if let grader, let grade {
|
||||
return "\(grader) \(String(format: "%.1f", grade))"
|
||||
return "\(grader) \(grade.formatted(.number.precision(.fractionLength(1)).locale(.init(identifier: "en"))))"
|
||||
}
|
||||
|
||||
return format == "single-issues" ? "Raw · \(condition)" : condition
|
||||
|
||||
@@ -19,14 +19,18 @@ struct TLSTests {
|
||||
// With TLS disabled the client skips the `SSLRequest` and sends its startup message directly,
|
||||
// which the fake server answers in plaintext.
|
||||
let server = try await PlaintextPostgresServer.start()
|
||||
|
||||
defer {
|
||||
try? await server.stop()
|
||||
}
|
||||
|
||||
let connection = try await connect(to: server, tls: .off)
|
||||
|
||||
let isConnected = !connection.isClosed
|
||||
defer {
|
||||
try? await connection.close()
|
||||
}
|
||||
|
||||
try await connection.close()
|
||||
try await server.stop()
|
||||
|
||||
#expect(isConnected)
|
||||
#expect(!connection.isClosed)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -34,14 +38,18 @@ struct TLSTests {
|
||||
// The fake server refuses the `SSLRequest`, so this connection can only succeed by downgrading
|
||||
// to plaintext — pinning the driver behavior the `prefer` posture relies on.
|
||||
let server = try await PlaintextPostgresServer.start()
|
||||
|
||||
defer {
|
||||
try? await server.stop()
|
||||
}
|
||||
|
||||
let connection = try await connect(to: server, tls: .prefer)
|
||||
|
||||
let isConnected = !connection.isClosed
|
||||
defer {
|
||||
try? await connection.close()
|
||||
}
|
||||
|
||||
try await connection.close()
|
||||
try await server.stop()
|
||||
|
||||
#expect(isConnected)
|
||||
#expect(!connection.isClosed)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -64,6 +64,11 @@ struct ProbeTests {
|
||||
// ever be resolved by its deadline — without one, it would wait out the driver's own connect
|
||||
// timeout (10 seconds) instead.
|
||||
let server = try await SilentPostgresServer.start()
|
||||
|
||||
defer {
|
||||
try? await server.stop()
|
||||
}
|
||||
|
||||
let service = try Service(
|
||||
driver: .postgres(
|
||||
.init(
|
||||
@@ -91,7 +96,6 @@ struct ProbeTests {
|
||||
let elapsed = clock.now - start
|
||||
|
||||
try await fluent.shutdown()
|
||||
try await server.stop()
|
||||
|
||||
#expect(!isReachable)
|
||||
// Well past the 100-millisecond deadline to absorb scheduling noise, yet far below the driver's
|
||||
|
||||
@@ -69,17 +69,13 @@ struct ServiceTests {
|
||||
|
||||
let fluent = service()
|
||||
|
||||
do {
|
||||
let database = try #require(fluent.db() as? any SQLDatabase)
|
||||
|
||||
try await database.raw("SELECT 1").run()
|
||||
} catch {
|
||||
defer {
|
||||
try? await fluent.shutdown()
|
||||
|
||||
throw error
|
||||
}
|
||||
|
||||
try await fluent.shutdown()
|
||||
let database = try #require(fluent.db() as? any SQLDatabase)
|
||||
|
||||
try await database.raw("SELECT 1").run()
|
||||
}
|
||||
|
||||
@Test("in-memory: migrate, seed, read back")
|
||||
@@ -124,25 +120,21 @@ private extension ServiceTests {
|
||||
|
||||
let fluent = service()
|
||||
|
||||
do {
|
||||
await prepareDB(for: fluent)
|
||||
|
||||
try await fluent.migrate()
|
||||
|
||||
let repository = CatalogueRepository(fluent: fluent)
|
||||
|
||||
#expect(try await !repository.listings().isEmpty)
|
||||
|
||||
if revertAfter {
|
||||
try await fluent.revert()
|
||||
}
|
||||
} catch {
|
||||
defer {
|
||||
try? await fluent.shutdown()
|
||||
|
||||
throw error
|
||||
}
|
||||
|
||||
try await fluent.shutdown()
|
||||
await prepareDB(for: fluent)
|
||||
|
||||
try await fluent.migrate()
|
||||
|
||||
let repository = CatalogueRepository(fluent: fluent)
|
||||
|
||||
#expect(try await !repository.listings().isEmpty)
|
||||
|
||||
if revertAfter {
|
||||
try await fluent.revert()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user