diff --git a/IntegrationTests/Simple/.gitignore b/IntegrationTest/.gitignore similarity index 100% rename from IntegrationTests/Simple/.gitignore rename to IntegrationTest/.gitignore diff --git a/IntegrationTests/Simple/Package.swift b/IntegrationTest/Package.swift similarity index 98% rename from IntegrationTests/Simple/Package.swift rename to IntegrationTest/Package.swift index 1ae155a6..f9f8fb1a 100644 --- a/IntegrationTests/Simple/Package.swift +++ b/IntegrationTest/Package.swift @@ -15,7 +15,7 @@ import PackageDescription let package = Package( - name: "Simple", + name: "swift-openapi-integration-test", platforms: [ .macOS(.v13) ], diff --git a/IntegrationTests/Simple/README.md b/IntegrationTest/README.md similarity index 100% rename from IntegrationTests/Simple/README.md rename to IntegrationTest/README.md diff --git a/IntegrationTests/Simple/Sources/Client/Empty.swift b/IntegrationTest/Sources/Client/Empty.swift similarity index 100% rename from IntegrationTests/Simple/Sources/Client/Empty.swift rename to IntegrationTest/Sources/Client/Empty.swift diff --git a/IntegrationTests/Simple/Sources/Client/openapi-generator-config.yaml b/IntegrationTest/Sources/Client/openapi-generator-config.yaml similarity index 100% rename from IntegrationTests/Simple/Sources/Client/openapi-generator-config.yaml rename to IntegrationTest/Sources/Client/openapi-generator-config.yaml diff --git a/IntegrationTests/Simple/Sources/Client/openapi.yaml b/IntegrationTest/Sources/Client/openapi.yaml similarity index 100% rename from IntegrationTests/Simple/Sources/Client/openapi.yaml rename to IntegrationTest/Sources/Client/openapi.yaml diff --git a/IntegrationTests/Simple/Sources/MockTransportClient/Client.swift b/IntegrationTest/Sources/MockTransportClient/Client.swift similarity index 100% rename from IntegrationTests/Simple/Sources/MockTransportClient/Client.swift rename to IntegrationTest/Sources/MockTransportClient/Client.swift diff --git a/IntegrationTests/Simple/Sources/MockTransportServer/Server.swift b/IntegrationTest/Sources/MockTransportServer/Server.swift similarity index 100% rename from IntegrationTests/Simple/Sources/MockTransportServer/Server.swift rename to IntegrationTest/Sources/MockTransportServer/Server.swift diff --git a/IntegrationTests/Simple/Sources/Server/Empty.swift b/IntegrationTest/Sources/Server/Empty.swift similarity index 100% rename from IntegrationTests/Simple/Sources/Server/Empty.swift rename to IntegrationTest/Sources/Server/Empty.swift diff --git a/IntegrationTests/Simple/Sources/Server/openapi-generator-config.yaml b/IntegrationTest/Sources/Server/openapi-generator-config.yaml similarity index 100% rename from IntegrationTests/Simple/Sources/Server/openapi-generator-config.yaml rename to IntegrationTest/Sources/Server/openapi-generator-config.yaml diff --git a/IntegrationTests/Simple/Sources/Server/openapi.yaml b/IntegrationTest/Sources/Server/openapi.yaml similarity index 100% rename from IntegrationTests/Simple/Sources/Server/openapi.yaml rename to IntegrationTest/Sources/Server/openapi.yaml diff --git a/IntegrationTests/Simple/Sources/Types/Empty.swift b/IntegrationTest/Sources/Types/Empty.swift similarity index 100% rename from IntegrationTests/Simple/Sources/Types/Empty.swift rename to IntegrationTest/Sources/Types/Empty.swift diff --git a/IntegrationTests/Simple/Sources/Types/openapi-generator-config.yaml b/IntegrationTest/Sources/Types/openapi-generator-config.yaml similarity index 100% rename from IntegrationTests/Simple/Sources/Types/openapi-generator-config.yaml rename to IntegrationTest/Sources/Types/openapi-generator-config.yaml diff --git a/IntegrationTests/Simple/Sources/Types/openapi.yaml b/IntegrationTest/Sources/Types/openapi.yaml similarity index 100% rename from IntegrationTests/Simple/Sources/Types/openapi.yaml rename to IntegrationTest/Sources/Types/openapi.yaml diff --git a/IntegrationTests/Simple/Sources/openapi.yaml b/IntegrationTest/Sources/openapi.yaml similarity index 100% rename from IntegrationTests/Simple/Sources/openapi.yaml rename to IntegrationTest/Sources/openapi.yaml diff --git a/docker/Dockerfile b/docker/Dockerfile index 4b7014a7..33f860d9 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -20,4 +20,7 @@ RUN echo 'export PATH="$HOME/.tools:$PATH"' >> $HOME/.profile ARG swiftformat_version=508.0.0 RUN git clone --branch $swiftformat_version --depth 1 https://github.com/apple/swift-format $HOME/.tools/swift-format-source RUN cd $HOME/.tools/swift-format-source && swift build -c release -RUN ln -s $HOME/.tools/swift-format-source/.build/release/swift-format $HOME/.tools/swift-format \ No newline at end of file +RUN ln -s $HOME/.tools/swift-format-source/.build/release/swift-format $HOME/.tools/swift-format + +# jq +RUN apt-get install -y jq diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index bb42b187..3e6f33a2 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -27,6 +27,8 @@ services: soundness: <<: *common command: /bin/bash -xcl "swift -version && uname -a && ./scripts/soundness.sh" + environment: + SWIFT_OPENAPI_GENERATOR_REPO_URL: file:///code test: <<: *common diff --git a/scripts/run-integration-test.sh b/scripts/run-integration-test.sh new file mode 100644 index 00000000..f9928287 --- /dev/null +++ b/scripts/run-integration-test.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +##===----------------------------------------------------------------------===## +## +## This source file is part of the SwiftOpenAPIGenerator open source project +## +## Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors +## Licensed under Apache License v2.0 +## +## See LICENSE.txt for license information +## See CONTRIBUTORS.txt for the list of SwiftOpenAPIGenerator 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; } + +log "Checking required executables..." +SWIFT_BIN=${SWIFT_BIN:-$(command -v swift || xcrun -f swift)} || fatal "SWIFT_BIN unset and no swift on PATH" +JQ_BIN=${JQ_BIN:-$(command -v jq)} || fatal "JQ_BIN unset and no jq on PATH" + +CURRENT_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +REPO_ROOT="$(git -C "${CURRENT_SCRIPT_DIR}" rev-parse --show-toplevel)" +TMP_DIR=$(mktemp -d "${PWD}/tmp.$(basename "$0").XXXXXXXXXX.noindex") + +PACKAGE_PATH=${PACKAGE_PATH:-${REPO_ROOT}} + +SWIFT_OPENAPI_GENERATOR_REPO_URL="${SWIFT_OPENAPI_GENERATOR_REPO_URL:-https://github.com/apple/swift-openapi-generator}" +SWIFT_OPENAPI_GENERATOR_REPO_CLONE_DIR="${TMP_DIR}/$(basename "${SWIFT_OPENAPI_GENERATOR_REPO_URL}")" +INTEGRATION_TEST_PACKAGE_PATH="${SWIFT_OPENAPI_GENERATOR_REPO_CLONE_DIR}/IntegrationTest" + +log "Cloning ${SWIFT_OPENAPI_GENERATOR_REPO_URL} to ${SWIFT_OPENAPI_GENERATOR_REPO_CLONE_DIR}" +git clone --depth=1 "${SWIFT_OPENAPI_GENERATOR_REPO_URL}" "${SWIFT_OPENAPI_GENERATOR_REPO_CLONE_DIR}" + +log "Extracting name for Swift package: ${PACKAGE_PATH}" +PACKAGE_NAME=$(swift package --package-path "${PACKAGE_PATH}" describe --type json | "${JQ_BIN}" -r .name) + +log "Overriding dependency in ${INTEGRATION_TEST_PACKAGE_PATH} on ${PACKAGE_NAME} to use ${PACKAGE_PATH}" +swift package --package-path "${INTEGRATION_TEST_PACKAGE_PATH}" \ + edit "${PACKAGE_NAME}" --path "${PACKAGE_PATH}" + +log "Building integration test package: ${INTEGRATION_TEST_PACKAGE_PATH}" +swift build --package-path "${INTEGRATION_TEST_PACKAGE_PATH}" + +log "✅ Successfully built integration test package." diff --git a/scripts/run-swift-format.sh b/scripts/run-swift-format.sh index f6ab93d5..f29f6108 100644 --- a/scripts/run-swift-format.sh +++ b/scripts/run-swift-format.sh @@ -26,7 +26,7 @@ SWIFTFORMAT_BIN=${SWIFTFORMAT_BIN:-$(command -v swift-format)} || fatal "❌ SWI "${SWIFTFORMAT_BIN}" lint \ --parallel --recursive --strict \ "${REPO_ROOT}/Examples" \ - "${REPO_ROOT}/IntegrationTests" \ + "${REPO_ROOT}/IntegrationTest" \ "${REPO_ROOT}/Plugins" \ "${REPO_ROOT}/Sources" \ "${REPO_ROOT}/Tests" \ diff --git a/scripts/soundness.sh b/scripts/soundness.sh index 9d6009bc..06c63e18 100755 --- a/scripts/soundness.sh +++ b/scripts/soundness.sh @@ -28,6 +28,7 @@ SCRIPT_PATHS=( "${CURRENT_SCRIPT_DIR}/check-license-headers.sh" "${CURRENT_SCRIPT_DIR}/run-swift-format.sh" "${CURRENT_SCRIPT_DIR}/check-for-docc-warnings.sh" + "${CURRENT_SCRIPT_DIR}/run-integration-test.sh" ) for SCRIPT_PATH in "${SCRIPT_PATHS[@]}"; do