Skip to content

Build IntegrationTest package as part of CI pipeline #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import PackageDescription

let package = Package(
name: "Simple",
name: "swift-openapi-integration-test",
platforms: [
.macOS(.v13)
],
Expand Down
File renamed without changes.
5 changes: 4 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
RUN ln -s $HOME/.tools/swift-format-source/.build/release/swift-format $HOME/.tools/swift-format

# jq
RUN apt-get install -y jq
2 changes: 2 additions & 0 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 48 additions & 0 deletions scripts/run-integration-test.sh
Original file line number Diff line number Diff line change
@@ -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."
2 changes: 1 addition & 1 deletion scripts/run-swift-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
1 change: 1 addition & 0 deletions scripts/soundness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down