diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 1714f8073..10daaff8b 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM registry.gitlab.com/finestructure/spi-base:1.2.2 +FROM registry.gitlab.com/finestructure/spi-base:1.3.0 # Install SPM build dependencies RUN apt-get update && apt-get install -y curl git make unzip \ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c4b6c6d5..e00ed800c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: name: Test runs-on: ubuntu-latest container: - image: registry.gitlab.com/finestructure/spi-base:1.2.2 + image: registry.gitlab.com/finestructure/spi-base:1.3.0 options: --privileged steps: - name: GH Runner bug workaround @@ -160,7 +160,7 @@ jobs: name: Release build runs-on: ubuntu-latest container: - image: registry.gitlab.com/finestructure/spi-base:1.2.2 + image: registry.gitlab.com/finestructure/spi-base:1.3.0 options: --privileged steps: - name: GH Runner bug workaround diff --git a/.github/workflows/query-performance.yml b/.github/workflows/query-performance.yml index d3929e449..034cba8cb 100644 --- a/.github/workflows/query-performance.yml +++ b/.github/workflows/query-performance.yml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-latest continue-on-error: true container: - image: registry.gitlab.com/finestructure/spi-base:1.2.2 + image: registry.gitlab.com/finestructure/spi-base:1.3.0 steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/Dockerfile b/Dockerfile index 1bbfdc321..5d445b3c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ # ================================ # Build image # ================================ -FROM registry.gitlab.com/finestructure/spi-base:1.2.2 as build +FROM registry.gitlab.com/finestructure/spi-base:1.3.0 as build # Set up a build area WORKDIR /build @@ -62,7 +62,7 @@ RUN [ -d /build/Resources ] && { mv /build/Resources ./Resources && chmod -R a-w # ================================ # Run image # ================================ -FROM registry.gitlab.com/finestructure/spi-base:1.2.2 +FROM registry.gitlab.com/finestructure/spi-base:1.3.0 # NB sas 2022-09-23: We're not using a dedicated `vapor` user to run the executable, because it # makes managing the data in the checkouts volume difficult. See diff --git a/LOCAL_DEVELOPMENT_SETUP.md b/LOCAL_DEVELOPMENT_SETUP.md index 3387a4d58..8ec8dde73 100644 --- a/LOCAL_DEVELOPMENT_SETUP.md +++ b/LOCAL_DEVELOPMENT_SETUP.md @@ -238,7 +238,7 @@ The trickiest part of this is to ensure the test or app container can connect to So, in order to run the tests in a Linux container run: ``` -docker run --rm -v "$PWD":/host -w /host --add-host=host.docker.internal:host-gateway registry.gitlab.com/finestructure/spi-base:1.2.2 swift test +docker run --rm -v "$PWD":/host -w /host --add-host=host.docker.internal:host-gateway registry.gitlab.com/finestructure/spi-base:1.3.0 swift test ``` Make sure you use the most recent `spi-base` image. You can find the latest image name in the `test-docker` target, which also provides a convenient way to run all all tests in a docker container. diff --git a/Makefile b/Makefile index 0d5c210b8..52db1a2f7 100644 --- a/Makefile +++ b/Makefile @@ -89,7 +89,7 @@ test-docker: @# run tests inside a docker container docker run --rm -v "$(PWD)":/host -w /host \ --add-host=host.docker.internal:host-gateway \ - registry.gitlab.com/finestructure/spi-base:1.2.2 \ + registry.gitlab.com/finestructure/spi-base:1.3.0 \ make test test-e2e: db-reset reconcile ingest analyze diff --git a/Package.resolved b/Package.resolved index 4c695e8bd..ef2162a0b 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "9fe1cd64ccbd0c24f221187eb7bcf499926ef1cad211348cb7701fbeb1772d3c", + "originHash" : "2bcecf7e0a5d6f26686ba99934b5b5024efba0c1e11aff15ee2ca4f1b628fb90", "pins" : [ { "identity" : "async-http-client", @@ -195,8 +195,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/SwiftPackageIndex/ShellOut.git", "state" : { - "revision" : "e862e8866c9d5d3fbc394aefdc8428f31c99355c", - "version" : "3.1.4" + "revision" : "808c97cc684bceb58288db70e701fa66636cf31d", + "version" : "3.3.0" } }, { diff --git a/Package.swift b/Package.swift index 405890dae..80f7bdd2f 100644 --- a/Package.swift +++ b/Package.swift @@ -34,7 +34,7 @@ let package = Package( .package(url: "https://github.com/SwiftPackageIndex/DependencyResolution.git", from: "1.1.2"), .package(url: "https://github.com/SwiftPackageIndex/SPIManifest.git", from: "1.9.0"), .package(url: "https://github.com/SwiftPackageIndex/SemanticVersion.git", from: "0.3.0"), - .package(url: "https://github.com/SwiftPackageIndex/ShellOut.git", from: "3.1.4"), + .package(url: "https://github.com/SwiftPackageIndex/ShellOut.git", from: "3.3.0"), .package(url: "https://github.com/finestructure/swift-package-manager.git", branch: "release/6.1"), .package(url: "https://github.com/pointfreeco/swift-custom-dump.git", from: "1.0.0"), .package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.8.0"), diff --git a/Sources/App/Controllers/API/API+PackageCollectionController.swift b/Sources/App/Controllers/API/API+PackageCollectionController.swift index 8e788d8b2..6780cd2c1 100644 --- a/Sources/App/Controllers/API/API+PackageCollectionController.swift +++ b/Sources/App/Controllers/API/API+PackageCollectionController.swift @@ -61,7 +61,7 @@ extension API { } -extension PackageCollectionSigning.Model.SignedCollection: @retroactive @unchecked Sendable, Vapor.Content {} +extension PackageCollectionSigning.Model.SignedCollection: @retroactive Vapor.Content {} extension API { diff --git a/Sources/App/Core/Dependencies/RedisClient.swift b/Sources/App/Core/Dependencies/RedisClient.swift index d94d557db..4b4cfc623 100644 --- a/Sources/App/Core/Dependencies/RedisClient.swift +++ b/Sources/App/Core/Dependencies/RedisClient.swift @@ -17,6 +17,10 @@ import NIOCore import Dependencies import DependenciesMacros +@globalActor +actor RedisSingletonActor { + static let shared = RedisSingletonActor() +} @DependencyClient struct RedisClient { @@ -42,11 +46,11 @@ extension RedisClient: DependencyKey { static var liveValue: RedisClient { .init( set: { key, value, expiresIn in - try await Redis.shared.set(key: key, value: value, expiresIn: expiresIn) + try await Redis.shared().set(key: key, value: value, expiresIn: expiresIn) }, - get: { key in try await Redis.shared.get(key: key) }, - expire: { key, ttl in try await Redis.shared.expire(key: key, after: ttl) }, - increment: { key, value in try await Redis.shared.increment(key: key, by: value) } + get: { key in try await Redis.shared().get(key: key) }, + expire: { key, ttl in try await Redis.shared().expire(key: key, after: ttl) }, + increment: { key, value in try await Redis.shared().increment(key: key, by: value) } ) } } @@ -79,30 +83,27 @@ extension RedisClient { private actor Redis { var client: RediStack.RedisClient - static private var task: Task? + @RedisSingletonActor private static var _shared: Redis? - static var shared: Redis { - get async throws { - if let task { - return try await task.value - } - let task = Task { - var attemptsLeft = maxConnectionAttempts - while attemptsLeft > 0 { - do { - return try await Redis() - } catch { - attemptsLeft -= 1 - @Dependency(\.logger) var logger - logger.warning("Redis connection failed, \(attemptsLeft) attempts left. Error: \(error)") - try? await Task.sleep(for: .milliseconds(500)) - } - } - throw Error.unavailable + @RedisSingletonActor + static func shared() async throws -> Redis { + if let existing = _shared { + return existing + } + var attemptsLeft = maxConnectionAttempts + while attemptsLeft > 0 { + do { + let instance = try await Redis() + _shared = instance + return instance + } catch { + attemptsLeft -= 1 + @Dependency(\.logger) var logger + logger.warning("Redis connection failed, \(attemptsLeft) attempts left. Error: \(error)") + try? await Task.sleep(for: .milliseconds(500)) } - self.task = task - return try await task.value } + throw Error.unavailable } enum Error: Swift.Error { diff --git a/Sources/App/Core/Extensions/ShellOutCommand+ext.swift b/Sources/App/Core/Extensions/ShellOutCommand+ext.swift index d362d4562..301dafaaa 100644 --- a/Sources/App/Core/Extensions/ShellOutCommand+ext.swift +++ b/Sources/App/Core/Extensions/ShellOutCommand+ext.swift @@ -91,5 +91,5 @@ extension ShellOutCommand { extension Reference { - var quoted: Argument { description.quoted } + var quoted: ShellArgument { description.quoted } } diff --git a/Tests/AppTests/__Snapshots__/AnalyzerTests/dumpPackage_format.linux.json b/Tests/AppTests/__Snapshots__/AnalyzerTests/dumpPackage_format.linux.json index d2e2c2a86..9ac50bfc0 100644 --- a/Tests/AppTests/__Snapshots__/AnalyzerTests/dumpPackage_format.linux.json +++ b/Tests/AppTests/__Snapshots__/AnalyzerTests/dumpPackage_format.linux.json @@ -78,6 +78,9 @@ "products" : [ { "name" : "StaticMemberIterable", + "settings" : [ + + ], "targets" : [ "StaticMemberIterable" ], @@ -89,6 +92,9 @@ }, { "name" : "StaticMemberIterableClient", + "settings" : [ + + ], "targets" : [ "StaticMemberIterableClient" ],