feat: Adds Docker tests.

This commit is contained in:
2025-03-13 09:22:14 -04:00
parent c23e4c5f61
commit 491663969e
6 changed files with 41 additions and 3 deletions

2
.dockerignore Normal file
View File

@@ -0,0 +1,2 @@
.build
.env

28
Dockerfile Normal file
View File

@@ -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"]

View File

@@ -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. // The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription import PackageDescription

View File

@@ -223,7 +223,7 @@ private extension CoolingInterpolation.OneWayOutdoor {
private func interpolate( private func interpolate(
outdoorDesignTemperature: Int, outdoorDesignTemperature: Int,
aboveCapacity: KeyPath<CoolingInterpolation.OneWayOutdoor.Capacities.Capacity, Int>, aboveCapacity: KeyPath<CoolingInterpolation.OneWayOutdoor.Capacities.Capacity, Int>,
belowCapacity: KeyPath<CoolingInterpolation.OneWayOutdoor.Capacities.Capacity, Int>, belowCapacity: KeyPath<CoolingInterpolation.OneWayOutdoor.Capacities.Capacity, Int>
) async -> Int { ) async -> Int {
return await interpolateOutdoorCapacity( return await interpolateOutdoorCapacity(
outdoorDesignTemperature: outdoorDesignTemperature, outdoorDesignTemperature: outdoorDesignTemperature,

View File

@@ -209,7 +209,7 @@ struct ManualSTests {
@Dependency(\.manualS) var manualS @Dependency(\.manualS) var manualS
let limits = try await manualS.sizingLimits(.init( let limits = try await manualS.sizingLimits(.init(
systemType: .heatingOnly(type: heatingType), systemType: .heatingOnly(type: heatingType)
)) ))
#expect(limits.oversizing.heating == heatingType.oversizingLimit) #expect(limits.oversizing.heating == heatingType.oversizingLimit)

8
justfile Normal file
View File

@@ -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