Skip to content

Add testing trait to indicate a CI environment that has restricted network access #8406

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
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ extension Trait where Self == Testing.ConditionTrait {
}
}

/// Skip test if the test environment has a restricted network access, i.e. cannot get to internet.
public static func requireUnrestrictedNetworkAccess(_ comment: Comment? = nil) -> Self {
disabled(comment ?? "CI Environment has restricted network access") {
ProcessInfo.processInfo.environment["SWIFTCI_RESTRICTED_NETWORK_ACCESS"] != nil
}
}

/// Skip test if built by XCode.
public static func skipIfXcodeBuilt() -> Self {
disabled("Tests built by Xcode") {
Expand Down
3 changes: 2 additions & 1 deletion IntegrationTests/Tests/IntegrationTests/BasicTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ private struct BasicTests {
@Test(
.skipSwiftCISelfHosted(
"These packages don't use the latest runtime library, which doesn't work with self-hosted builds."
)
),
.requireUnrestrictedNetworkAccess("Test requires access to https://github.com")
)
func testExamplePackageDealer() throws {
try withTemporaryDirectory { tempDir in
Expand Down