Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions .github/workflows/build_soundness.yml

This file was deleted.

80 changes: 80 additions & 0 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: IntegrationTests

on:
workflow_call:
inputs:
name:
type: string
description: "The name of the workflow used for the concurrency group."
required: true
# We pass the list of examples here, but we can't pass an array as argument
# Instead, we pass a String with a valid JSON array.
# The workaround is mentioned here https://github.com/orgs/community/discussions/11692
examples:
type: string
description: "The list of examples to run. Pass a String with a valid JSON array such as \"[ 'Converse', 'ConverseStream' ]\""
required: true
default: ""
examples_enabled:
type: boolean
description: "Boolean to enable the compilation of examples. Defaults to true."
default: true
check_foundation_enabled:
type: boolean
description: "Boolean to enable the check for Foundation dependency. Defaults to true."
default: true
matrix_linux_command:
type: string
description: "The command of the current Swift version linux matrix job to execute."
required: true

## We are cancelling previously triggered workflow runs
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.name }}
cancel-in-progress: true

jobs:
test-examples:
name: Test Examples/${{ matrix.examples }} on ${{ matrix.swift.swift_version }}
if: ${{ inputs.examples_enabled }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
examples: ${{ fromJson(inputs.examples) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Mark the workspace as safe
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}

- name: Run matrix job
env:
COMMAND: ${{ inputs.matrix_linux_command }}
EXAMPLE: ${{ matrix.examples }}
run: |
.github/workflows/scripts/integration_tests.sh

playground-backend:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Web playground backend build
working-directory: Examples/web-playground/backend
run: swift build

check-foundation:
name: No dependencies on Foundation
if: ${{ inputs.check_foundation_enabled }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Mark the workspace as safe
# https://github.com/actions/checkout/issues/766
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Check for Foundation or ICU dependency
run: |
.github/workflows/scripts/check-link-foundation.sh
43 changes: 43 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build, tests & soundness checks

on: [pull_request, workflow_dispatch]

jobs:
swift-bedrock-library:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run tests
run: swift test

soundness:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
with:
license_header_check_enabled: true
license_header_check_project_name: "Swift Bedrock Library"
shell_check_enabled: false
python_lint_check_enabled: false
api_breakage_check_enabled: false
# api_breakage_check_container_image: "swift:6.1-noble"
docs_check_container_image: "swift:6.1-noble"
format_check_container_image: "swift:6.1-noble"
yamllint_check_enabled: true

integration-tests:
name: Integration Tests
uses: ./.github/workflows/integration_tests.yml
with:
name: "Integration tests"
examples_enabled: true
matrix_linux_command: "swift build"
check_foundation_enabled: true
# We pass the list of examples here, but we can't pass an array as argument
# Instead, we pass a String with a valid JSON array.
# The workaround is mentioned here https://github.com/orgs/community/discussions/11692
examples: "[ 'converse', 'converse-stream' ]"

swift-6-language-mode:
name: Swift 6 Language Mode
uses: ./.github/workflows/swift-6-language-mode.yml
61 changes: 61 additions & 0 deletions .github/workflows/scripts/check-link-foundation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash
##===----------------------------------------------------------------------===##
##
## This source file is part of the Swift Bedrock Library open source project
##
## Copyright (c) 2025 Amazon.com, Inc. or its affiliates
## and the Swift Bedrock Library project authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
## See CONTRIBUTORS.txt for the list of Swift Bedrock Library project authors
##
## SPDX-License-Identifier: Apache-2.0
##
##===----------------------------------------------------------------------===##

log() { printf -- "** %s\n" "$*" >&2; }
error() { printf -- "** ERROR: %s\n" "$*" >&2; }
fatal() { error "$@"; exit 1; }

EXAMPLE=converse
OUTPUT_DIR=.build/release
OUTPUT_FILE=${OUTPUT_DIR}/converse
LIBS_TO_CHECK="libFoundation.so libFoundationInternationalization.so lib_FoundationICU.so"

pushd Examples/${EXAMPLE} || fatal "Failed to change directory to Examples/${EXAMPLE}."

# recompile the example without the --static-swift-stdlib flag
LAMBDA_USE_LOCAL_DEPS=../.. swift build -c release -Xlinker -s || fatal "Failed to build the example."

# check if the binary exists
if [ ! -f "${OUTPUT_FILE}" ]; then
error "❌ ${OUTPUT_FILE} does not exist."
fi

# Checking for Foundation or ICU dependencies
echo "Checking for Foundation or ICU dependencies in ${OUTPUT_DIR}/${OUTPUT_FILE}."
LIBRARIES=$(ldd ${OUTPUT_FILE} | awk '{print $1}')
for LIB in ${LIBS_TO_CHECK}; do
echo -n "Checking for ${LIB}... "

# check if the binary has a dependency on Foundation or ICU
echo "${LIBRARIES}" | grep "${LIB}" # return 1 if not found

# 1 is success (grep failed to find the lib), 0 is failure (grep successly found the lib)
SUCCESS=$?
if [ "$SUCCESS" -eq 0 ]; then
log "❌ ${LIB} found." && break
else
log "✅ ${LIB} not found."
fi
done

popd || fatal "Failed to change directory back to the root directory."

# exit code is the opposite of the grep exit code
if [ "$SUCCESS" -eq 0 ]; then
fatal "❌ At least one foundation lib was found, reporting the error."
else
log "✅ No foundation lib found, congrats!" && exit 0
fi
33 changes: 33 additions & 0 deletions .github/workflows/scripts/integration_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
##===----------------------------------------------------------------------===##
##
## This source file is part of the Swift Bedrock Library open source project
##
## Copyright (c) 2025 Amazon.com, Inc. or its affiliates
## and the Swift Bedrock Library project authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
## See CONTRIBUTORS.txt for the list of Swift Bedrock Library project authors
##
## SPDX-License-Identifier: Apache-2.0
##
##===----------------------------------------------------------------------===##

set -euo pipefail

log() { printf -- "** %s\n" "$*" >&2; }
error() { printf -- "** ERROR: %s\n" "$*" >&2; }
fatal() { error "$@"; exit 1; }

SWIFT_VERSION=$(swift --version)
test -n "${SWIFT_VERSION:-}" || fatal "SWIFT_VERSION unset"
test -n "${COMMAND:-}" || fatal "COMMAND unset"
test -n "${EXAMPLE:-}" || fatal "EXAMPLE unset"

pushd Examples/"$EXAMPLE" > /dev/null

log "Running command with Swift $SWIFT_VERSION"
eval "$COMMAND"

popd
24 changes: 24 additions & 0 deletions .github/workflows/swift-6-language-mode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Swift 6 language mode

on:
workflow_call:

# We are cancelling previously triggered workflow runs
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-swift-6-language-mode
cancel-in-progress: true

jobs:
swift-6-language-mode:
name: Swift 6 language mode
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
submodules: true
- name: Set the language mode
run: swift package tools-version --set 6.0
- name: Build with Swift 6 language mode
run: swift build -Xswiftc -warnings-as-errors
2 changes: 1 addition & 1 deletion Examples/converse-stream/Package.swift
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Examples/converse/Package.swift
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -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
Expand Down