Use published dependency by default in examples (#665)

## Summary

Examples now default to the published `swift-aws-lambda-runtime` package
from GitHub, so they work out of the box when cloned standalone (as
described in the READMEs).

CI scripts swap the dependency to the local path (`../..`) before
building, ensuring we still test against the current branch.

### Changes

- **`Examples/APIGatewayV2/Package.swift`** — Default to remote URL,
local path is commented out with clear instructions.
- **`.github/workflows/scripts/use-local-deps.sh`** (new) — Shared
script that rewrites Package.swift to use the local dependency.
- **`integration_tests.sh`**, **`check-archive-plugin.sh`**,
**`check-link-foundation.sh`** — Source `use-local-deps.sh` before
building.
This commit is contained in:
Sébastien Stormacq
2026-05-11 21:38:11 +02:00
committed by GitHub
parent e1e4a15c14
commit ddad9b9bee
28 changed files with 108 additions and 97 deletions
@@ -19,6 +19,9 @@ fatal() { error "$@"; exit 1; }
test -n "${EXAMPLE:-}" || fatal "EXAMPLE unset"
# Use the local checkout of swift-aws-lambda-runtime instead of the published release
.github/workflows/scripts/use-local-deps.sh "Examples/${EXAMPLE}/Package.swift"
OUTPUT_DIR=.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager
OUTPUT_FILE=${OUTPUT_DIR}/MyLambda/bootstrap
ZIP_FILE=${OUTPUT_DIR}/MyLambda/MyLambda.zip
@@ -22,6 +22,9 @@ OUTPUT_DIR=.build/release
OUTPUT_FILE=${OUTPUT_DIR}/APIGatewayLambda
LIBS_TO_CHECK="libFoundation.so libFoundationInternationalization.so lib_FoundationICU.so"
# Use the local checkout of swift-aws-lambda-runtime instead of the published release
.github/workflows/scripts/use-local-deps.sh "Examples/${EXAMPLE}/Package.swift"
pushd Examples/${EXAMPLE} || fatal "Failed to change directory to Examples/${EXAMPLE}."
# recompile the example without the --static-swift-stdlib flag
@@ -24,6 +24,9 @@ test -n "${SWIFT_VERSION:-}" || fatal "SWIFT_VERSION unset"
test -n "${COMMAND:-}" || fatal "COMMAND unset"
test -n "${EXAMPLE:-}" || fatal "EXAMPLE unset"
# Use the local checkout of swift-aws-lambda-runtime instead of the published release
.github/workflows/scripts/use-local-deps.sh "Examples/$EXAMPLE/Package.swift"
pushd Examples/"$EXAMPLE" > /dev/null
log "Running command with Swift $SWIFT_VERSION"
+31
View File
@@ -0,0 +1,31 @@
#!/bin/bash
##===----------------------------------------------------------------------===##
##
## This source file is part of the SwiftAWSLambdaRuntime open source project
##
## Copyright (c) 2017-2024 Apple Inc. and the SwiftAWSLambdaRuntime project authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
## See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors
##
## SPDX-License-Identifier: Apache-2.0
##
##===----------------------------------------------------------------------===##
# Rewrites a Package.swift to use the local path dependency instead of the remote URL.
# This ensures CI tests against the current branch.
#
# Usage: .github/workflows/scripts/use-local-deps.sh <path-to-Package.swift>
set -euo pipefail
log() { printf -- "** %s\n" "$*" >&2; }
PACKAGE_FILE="${1:?Usage: use-local-deps.sh <path-to-Package.swift>}"
log "Switching swift-aws-lambda-runtime dependency to local path in $PACKAGE_FILE"
sed -i \
-e 's|// *\.package(name: "swift-aws-lambda-runtime", path: "\.\./\.\.")|.package(name: "swift-aws-lambda-runtime", path: "../..")|' \
-e 's|\.package(url: "https://github.com/awslabs/swift-aws-lambda-runtime\.git", from: "[^"]*")|// .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "0.0.0")|' \
"$PACKAGE_FILE"