diff --git a/.github/workflows/examples_matrix.yml b/.github/workflows/examples_matrix.yml new file mode 100644 index 00000000..39ec1d26 --- /dev/null +++ b/.github/workflows/examples_matrix.yml @@ -0,0 +1,60 @@ +name: ExamplesMatrix + +on: + workflow_call: + inputs: + name: + type: string + description: "The name of the workflow used for the concurrency group." + required: true + # examples: + # type: sequence + # description: "The examples to run." + # required: true + matrix_linux_command: + type: string + description: "The command of the current Swift version linux matrix job to execute." + required: true + matrix_linux_swift_container_image: + type: string + description: "Container image for the matrix job. Defaults to matching latest Swift Ubuntu image." + default: "swift:latest" + +## We are cancelling previously triggered workflow runs +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.name }} + cancel-in-progress: true + +jobs: + linux: + name: Example/${{ matrix.examples }} on Linux ${{ matrix.swift.swift_version }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + # This should be passed as an argument in input. Can we pass arrays as argument ? + examples : [ "HelloWorld", "APIGateway" ] + # examples: ${{ inputs.examples }} + + # We are using only one Swift version + swift: + - image: ${{ inputs.matrix_linux_swift_container_image }} + swift_version: "6.0.1-noble" + container: + image: ${{ matrix.swift.image }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Mark the workspace as safe + # https://github.com/actions/checkout/issues/766 + run: git config --global --add safe.directory ${GITHUB_WORKSPACE} + - name: Run matrix job + env: + SWIFT_VERSION: ${{ matrix.swift.swift_version }} + COMMAND: ${{ inputs.matrix_linux_command }} + EXAMPLE: ${{ matrix.examples }} + run: | + apt-get -qq update && apt-get -qq -y install curl + ./scripts/integration_tests.sh \ No newline at end of file diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index f7522664..77f9a5af 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -24,6 +24,15 @@ jobs: linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error" linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error" + integration-tests: + name: Integration Tests + uses: ./.github/workflows/examples_matrix.yml + with: + # We should pass the list of examples here, but we can't pass an array as argument + # examples: [ "HelloWorld", "APIGateway" ] + name: "Integration tests" + matrix_linux_command: "LAMBDA_USE_LOCAL_DEPS=../.. swift build" + swift-6-language-mode: name: Swift 6 Language Mode uses: apple/swift-nio/.github/workflows/swift_6_language_mode.yml@main diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index ec97cef2..00000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -ARG swift_version=5.7 -ARG base_image=swift:$swift_version-amazonlinux2 -FROM $base_image -# needed to do again after FROM due to docker limitation -ARG swift_version - -# dependencies -RUN yum install -y wget perl-Digest-SHA -RUN yum install -y lsof dnsutils netcat-openbsd net-tools curl jq # used by integration tests - -# tools -RUN mkdir -p $HOME/.tools -RUN echo 'export PATH="$HOME/.tools:$PATH"' >> $HOME/.profile - -# swiftformat (until part of the toolchain) - -ARG swiftformat_version=0.50.1 -RUN git clone --branch $swiftformat_version --depth 1 https://github.com/nicklockwood/SwiftFormat $HOME/.tools/swift-format -RUN cd $HOME/.tools/swift-format && swift build -c release -RUN ln -s $HOME/.tools/swift-format/.build/release/swiftformat $HOME/.tools/swiftformat diff --git a/docker/docker-compose.al2.510.yaml b/docker/docker-compose.al2.510.yaml deleted file mode 100644 index a897f987..00000000 --- a/docker/docker-compose.al2.510.yaml +++ /dev/null @@ -1,18 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: swift-aws-lambda:al2-5.10 - build: - args: - base_image: "swiftlang/swift:nightly-5.10-amazonlinux2" - - test: - image: swift-aws-lambda:al2-5.10 - - test-examples: - image: swift-aws-lambda:al2-5.10 - - shell: - image: swift-aws-lambda:al2-5.10 diff --git a/docker/docker-compose.al2.57.yaml b/docker/docker-compose.al2.57.yaml deleted file mode 100644 index 1b19f1f0..00000000 --- a/docker/docker-compose.al2.57.yaml +++ /dev/null @@ -1,18 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: swift-aws-lambda:al2-5.7 - build: - args: - swift_version: "5.7" - - test: - image: swift-aws-lambda:al2-5.7 - - test-examples: - image: swift-aws-lambda:al2-5.7 - - shell: - image: swift-aws-lambda:al2-5.7 diff --git a/docker/docker-compose.al2.58.yaml b/docker/docker-compose.al2.58.yaml deleted file mode 100644 index 6127c65c..00000000 --- a/docker/docker-compose.al2.58.yaml +++ /dev/null @@ -1,18 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: swift-aws-lambda:al2-5.8 - build: - args: - swift_version: "5.8" - - test: - image: swift-aws-lambda:al2-5.8 - - test-examples: - image: swift-aws-lambda:al2-5.8 - - shell: - image: swift-aws-lambda:al2-5.8 diff --git a/docker/docker-compose.al2.59.yaml b/docker/docker-compose.al2.59.yaml deleted file mode 100644 index edea9327..00000000 --- a/docker/docker-compose.al2.59.yaml +++ /dev/null @@ -1,18 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: swift-aws-lambda:al2-5.9 - build: - args: - swift_version: "5.9" - - test: - image: swift-aws-lambda:al2-5.9 - - test-examples: - image: swift-aws-lambda:al2-5.9 - - shell: - image: swift-aws-lambda:al2-5.9 diff --git a/docker/docker-compose.al2.main.yaml b/docker/docker-compose.al2.main.yaml deleted file mode 100644 index b2f890c1..00000000 --- a/docker/docker-compose.al2.main.yaml +++ /dev/null @@ -1,18 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: swift-aws-lambda:al2-main - build: - args: - base_image: "swiftlang/swift:nightly-main-amazonlinux2" - - test: - image: swift-aws-lambda:al2-main - - test-examples: - image: swift-aws-lambda:al2-main - - shell: - image: swift-aws-lambda:al2-main diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml deleted file mode 100644 index 32507dcf..00000000 --- a/docker/docker-compose.yaml +++ /dev/null @@ -1,51 +0,0 @@ -# this file is not designed to be run directly -# instead, use the docker-compose.. files -# eg docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.al2.57.yaml run test -version: "3" - -services: - - runtime-setup: - image: swift-aws-lambda:default - build: - context: . - dockerfile: Dockerfile - - common: &common - image: swift-aws-lambda:default - depends_on: [runtime-setup] - volumes: - - ~/.ssh:/root/.ssh - - ..:/code:z - working_dir: /code - cap_drop: - - CAP_NET_RAW - - CAP_NET_BIND_SERVICE - - soundness: - <<: *common - command: /bin/bash -cl "./scripts/soundness.sh" - - test: - <<: *common - command: /bin/bash -cl "swift test -Xswiftc -warnings-as-errors $${SANITIZER_ARG-}" - - test-examples: - <<: *common - command: >- - /bin/bash -clx " - LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/Benchmark && - LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/Deployment && - LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/Echo && - LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/ErrorHandling && - LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/Foundation && - LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/JSON && - LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/LocalDebugging/MyLambda && - LAMBDA_USE_LOCAL_DEPS=true swift test --package-path Examples/Testing - " - - # util - - shell: - <<: *common - entrypoint: /bin/bash -l diff --git a/scripts/integration_tests.sh b/scripts/integration_tests.sh new file mode 100755 index 00000000..232d743d --- /dev/null +++ b/scripts/integration_tests.sh @@ -0,0 +1,34 @@ +#!/bin/bash +##===----------------------------------------------------------------------===## +## +## This source file is part of the SwiftAWSLambdaRuntime open source project +## +## Copyright (c) 2017-2018 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 +## +##===----------------------------------------------------------------------===## + +set -euo pipefail + +log() { printf -- "** %s\n" "$*" >&2; } +error() { printf -- "** ERROR: %s\n" "$*" >&2; } +fatal() { error "$@"; exit 1; } + +test -n "${SWIFT_VERSION:-}" || fatal "SWIFT_VERSION unset" +test -n "${COMMAND:-}" || fatal "COMMAND unset" +test -n "${EXAMPLE:-}" || fatal "EXAMPLE unset" +swift_version="$SWIFT_VERSION" +command="$COMMAND" +example="$EXAMPLE" + +pushd Examples/"$example" > /dev/null + +log "Running command with Swift $SWIFT_VERSION" +eval "$command" + +popd