#!/usr/bin/env bash # Runs the Linux matrix inside the swift:6.4-noble image: the CoreATProtocol # and PodcastIndexKit tests, the EffemModels product of EffemKit, and the # server's build and tests. `scripts/linux-build.sh` runs the same container # and only builds the server. # # The sources are copied into a Docker volume first, so the macOS build # directories stay untouched and the copied manifests can be pointed at the # local checkouts of every SparrowTek package, including helpers/NetworkingKit, # which CoreATProtocol otherwise resolves from GitHub. Unpushed changes to any # of them are therefore part of the run, which is what you want before pushing. # The server's Package.swift names CoreATProtocol, PodcastIndexKit and EffemKit # by URL; only the copy in the volume is rewritten, never the file in the # repository. # # Set EFFEM_TEST_DATABASE_URL to a database the container can reach to include # the database-backed server tests, for example with the compose Postgres: # EFFEM_TEST_DATABASE_URL='postgres://effem:effem@host.docker.internal:5433/effem?sslmode=disable' scripts/linux-test.sh set -euo pipefail ATPROTO="$(cd "$(dirname "$0")/../../.." && pwd)" HELPERS="$(cd "$ATPROTO/../helpers" && pwd)" IMAGE="${SWIFT_IMAGE:-swift:6.4-noble}" MODE="${1:-test}" exec docker run --rm -t \ --add-host=host.docker.internal:host-gateway \ -v "$ATPROTO/CoreATProtocol":/src/CoreATProtocol:ro \ -v "$ATPROTO/effem/PodcastIndexKit":/src/effem/PodcastIndexKit:ro \ -v "$ATPROTO/effem/EffemKit":/src/effem/EffemKit:ro \ -v "$ATPROTO/effem/AppView":/src/effem/AppView:ro \ -v "$HELPERS/NetworkingKit":/src/helpers/NetworkingKit:ro \ -v effem-linux-build:/cache \ -e "EFFEM_TEST_DATABASE_URL=${EFFEM_TEST_DATABASE_URL:-}" \ -e "MODE=$MODE" \ "$IMAGE" bash -euo pipefail -c ' copy() { # copy : sources only, never build products or local settings files rm -rf "/cache/src/$1" && mkdir -p "/cache/src/$1" tar -C "/src/$1" --exclude=./.build --exclude=./.build-linux --exclude=./.git --exclude=./Packages --exclude="./.env*" -cf - . | tar -C "/cache/src/$1" -xf - } for package in CoreATProtocol effem/PodcastIndexKit effem/EffemKit effem/AppView helpers/NetworkingKit; do copy "$package" done # Point the copied manifests at the copied checkouts. sed -E -i "s#\.package\(url: \"https://github.com/SparrowTek/NetworkingKit(\.git)?\"[^)]*\)#.package(path: \"../helpers/NetworkingKit\")#" /cache/src/CoreATProtocol/Package.swift sed -E -i "s#\.package\(url: \"https://tangled.org/@?sparrowtek.com/CoreATProtocol(\.git)?\"[^)]*\)#.package(path: \"../../CoreATProtocol\")#" /cache/src/effem/EffemKit/Package.swift sed -E -i \ -e "s#\.package\(url: \"https://tangled.org/@?sparrowtek.com/CoreATProtocol(\.git)?\"[^)]*\)#.package(path: \"../../CoreATProtocol\")#" \ -e "s#\.package\(url: \"https://github.com/SparrowTek/PodcastIndexKit(\.git)?\"[^)]*\)#.package(path: \"../PodcastIndexKit\")#" \ -e "s#\.package\(url: \"https://tangled.org/@?sparrowtek.com/EffemKit(\.git)?\"[^)]*\)#.package(path: \"../EffemKit\")#" \ /cache/src/effem/AppView/Package.swift # A rewrite that stopped matching would quietly build the pushed package # instead of the local checkout, so refuse to go on. if grep -nE "^[^/]*\.package\(url: \"https://(github\.com/SparrowTek|tangled\.org/@?sparrowtek\.com)/" \ /cache/src/CoreATProtocol/Package.swift /cache/src/effem/PodcastIndexKit/Package.swift /cache/src/effem/EffemKit/Package.swift \ /cache/src/effem/AppView/Package.swift /cache/src/helpers/NetworkingKit/Package.swift; then echo "error: a copied manifest still names a SparrowTek package by URL; update the rewrites in scripts/linux-test.sh" >&2 exit 1 fi if [ "$MODE" = build ]; then echo "== AppView build" && cd /cache/src/effem/AppView && swift build --scratch-path /cache/build/appview exit 0 fi echo "== CoreATProtocol" && cd /cache/src/CoreATProtocol && swift test --scratch-path /cache/build/coreatprotocol echo "== PodcastIndexKit" && cd /cache/src/effem/PodcastIndexKit && swift test --scratch-path /cache/build/podcastindexkit echo "== EffemModels" && cd /cache/src/effem/EffemKit && swift build --scratch-path /cache/build/effemkit --product EffemModels echo "== AppView" && cd /cache/src/effem/AppView && swift test --scratch-path /cache/build/appview '