From 491663969e0e99a43a8026ef639e3bddf4816cb3 Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Thu, 13 Mar 2025 09:22:14 -0400 Subject: [PATCH] feat: Adds Docker tests. --- .dockerignore | 2 ++ Dockerfile | 28 +++++++++++++++++++ Package.swift | 2 +- .../Internal/CoolingInterpolation.swift | 2 +- Tests/ManualSTests/ManualSTests.swift | 2 +- justfile | 8 ++++++ 6 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 justfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..951bb34 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.build +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f6d41bb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +ARG SWIFT_IMAGE="swift:6.0-noble" + +FROM ${SWIFT_IMAGE} + +# Install OS updates +RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \ + && apt-get -q update \ + && apt-get -q dist-upgrade -y + +# Set up a build area +WORKDIR /build + +# First just resolve dependencies. +# This creates a cached layer that can be reused +# as long as your Package.swift/Package.resolved +# files do not change. +COPY ./Package.* ./ +RUN --mount=type=cache,target=/build/.build swift package resolve \ + $([ -f ./Package.resolved ] && echo "--force-resolved-versions" || true) + +# Copy entire repo into container +COPY . . + +# Build the application, with optimizations, with static linking, and using jemalloc +# N.B.: The static version of jemalloc is incompatible with the static Swift runtime. +RUN swift build + +CMD ["swift", "test"] diff --git a/Package.swift b/Package.swift index c88e347..bbabfb6 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 6.1 +// swift-tools-version: 6.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription diff --git a/Sources/ManualS/Internal/CoolingInterpolation.swift b/Sources/ManualS/Internal/CoolingInterpolation.swift index 78116de..ba82f26 100644 --- a/Sources/ManualS/Internal/CoolingInterpolation.swift +++ b/Sources/ManualS/Internal/CoolingInterpolation.swift @@ -223,7 +223,7 @@ private extension CoolingInterpolation.OneWayOutdoor { private func interpolate( outdoorDesignTemperature: Int, aboveCapacity: KeyPath, - belowCapacity: KeyPath, + belowCapacity: KeyPath ) async -> Int { return await interpolateOutdoorCapacity( outdoorDesignTemperature: outdoorDesignTemperature, diff --git a/Tests/ManualSTests/ManualSTests.swift b/Tests/ManualSTests/ManualSTests.swift index 32f4bd7..867b49b 100644 --- a/Tests/ManualSTests/ManualSTests.swift +++ b/Tests/ManualSTests/ManualSTests.swift @@ -209,7 +209,7 @@ struct ManualSTests { @Dependency(\.manualS) var manualS let limits = try await manualS.sizingLimits(.init( - systemType: .heatingOnly(type: heatingType), + systemType: .heatingOnly(type: heatingType) )) #expect(limits.oversizing.heating == heatingType.oversizingLimit) diff --git a/justfile b/justfile new file mode 100644 index 0000000..ea76d59 --- /dev/null +++ b/justfile @@ -0,0 +1,8 @@ +docker_image := "swift-manual-s" +docker_tag := "latest" + +build-docker: + @docker build -t {{docker_image}}:{{docker_tag}} . + +test-docker: build-docker + @docker run --rm -i {{docker_image}}:{{docker_tag}} swift test