Skip to content
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

wip: Run endtoend tests in CI #183

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion Docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG swift_version
ARG ubuntu_version

# set as UTF-8
RUN apt-get update && apt-get install -y locales locales-all libsqlite3-dev
RUN apt-get update && apt-get install -y locales locales-all libsqlite3-dev podman
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
Expand Down
4 changes: 3 additions & 1 deletion Docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ services:

test:
<<: *common
privileged: true
environment:
- JENKINS_URL
command: /bin/bash -xcl "swift test $${WARN_AS_ERROR_ARG-} $${SANITIZER_ARG-} $${IMPORT_CHECK_ARG-}"
- SWIFT_SDK_GENERATOR_CONTAINER_RUNTIME=podman
command: /bin/bash -xcl "swift test $${WARN_AS_ERROR_ARG-} $${SANITIZER_ARG-} $${IMPORT_CHECK_ARG-} --filter Swift59_UbuntuEndToEndTests.testX86_64FromContainer"

# util

Expand Down
26 changes: 12 additions & 14 deletions Tests/SwiftSDKGeneratorTests/EndToEndTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,18 @@ final class RepeatedBuildTests: XCTestCase {
private let logger = Logger(label: "swift-sdk-generator")

func testRepeatedSDKBuilds() async throws {
if ProcessInfo.processInfo.environment.keys.contains("JENKINS_URL") {
throw XCTSkip("EndToEnd tests cannot currently run in CI: https://github.com/swiftlang/swift-sdk-generator/issues/145")
}
// if ProcessInfo.processInfo.environment.keys.contains("JENKINS_URL") {
// throw XCTSkip("EndToEnd tests cannot currently run in CI: https://github.com/swiftlang/swift-sdk-generator/issues/145")
// }

var logger = logger
logger[metadataKey: "testcase"] = "testRepeatedSDKBuilds"

// Test that an existing SDK can be rebuilt without cleaning up.
// Test with no arguments by default:
var possibleArguments = ["--host-toolchain"]
var possibleArguments = ["--no-host-toolchain"]
do {
try await Shell.run("docker ps")
try await Shell.run("podman ps")
possibleArguments.append("--with-docker --linux-distribution-name rhel --linux-distribution-version ubi9")
} catch {
self.logger.warning("Docker CLI does not seem to be working, skipping tests that involve Docker.")
Expand Down Expand Up @@ -176,7 +176,7 @@ struct SDKConfiguration {
var sdkGeneratorArguments: String {
return [
"--sdk-name \(bundleName)",
"--host-toolchain",
"--no-host-toolchain",
withDocker ? "--with-docker" : nil,
"--swift-version \(swiftVersion)-RELEASE",
testLinuxSwiftSDKs ? "--host \(hostArch!)-unknown-linux-gnu" : nil,
Expand Down Expand Up @@ -231,7 +231,7 @@ func buildTestcase(_ logger: Logger, testcase: String, bundleName: String, tempD
logger.info("Building test project in 6.0-\(containerVersion) container")
buildOutput = try await Shell.readStdout(
"""
docker run --rm -v \(testPackageDir):/src \
podman run --rm -v \(testPackageDir):/src \
-v $HOME/.swiftpm/swift-sdks:/root/.swiftpm/swift-sdks \
--workdir /src swift:6.0-\(containerVersion) \
/bin/bash -c "swift build --scratch-path /root/.build --experimental-swift-sdk \(bundleName)"
Expand All @@ -243,7 +243,7 @@ func buildTestcase(_ logger: Logger, testcase: String, bundleName: String, tempD
logger.info("Building test project in 6.0-\(containerVersion) container with static-swift-stdlib")
buildOutput = try await Shell.readStdout(
"""
docker run --rm -v \(testPackageDir):/src \
podman run --rm -v \(testPackageDir):/src \
-v $HOME/.swiftpm/swift-sdks:/root/.swiftpm/swift-sdks \
--workdir /src swift:6.0-\(containerVersion) \
/bin/bash -c "swift build --scratch-path /root/.build --experimental-swift-sdk \(bundleName) --static-swift-stdlib"
Expand Down Expand Up @@ -275,13 +275,13 @@ func buildTestcases(config: SDKConfiguration) async throws {
var logger = Logger(label: "EndToEndTests")
logger[metadataKey: "testcase"] = "testPackageInitExecutable"

if ProcessInfo.processInfo.environment.keys.contains("JENKINS_URL") {
throw XCTSkip("EndToEnd tests cannot currently run in CI: https://github.com/swiftlang/swift-sdk-generator/issues/145")
}
// if ProcessInfo.processInfo.environment.keys.contains("JENKINS_URL") {
// throw XCTSkip("EndToEnd tests cannot currently run in CI: https://github.com/swiftlang/swift-sdk-generator/issues/145")
// }

if config.withDocker {
do {
try await Shell.run("docker ps")
try await Shell.run("podman ps")
} catch {
throw XCTSkip("Container runtime is not available - skipping tests which require it")
}
Expand Down Expand Up @@ -323,12 +323,10 @@ final class Swift59_UbuntuEndToEndTests: XCTestCase {
}

func testAarch64FromContainer() async throws {
try skipSlow()
try await buildTestcases(config: config.withArchitecture("aarch64").withDocker())
}

func testX86_64FromContainer() async throws {
try skipSlow()
try await buildTestcases(config: config.withArchitecture("x86_64").withDocker())
}
}
Expand Down