Split test jobs (#855)

Move Core Data tests out of the Library package so that we can still use
the more efficient `swift test` for most tests.

Create a PassepartoutTests target only for tests that require
`xcodebuild`, like Core Data tests.

Eventually:

- PRs only run SwiftPM tests
- Releases run ALL tests with `scan` before `gym`
This commit is contained in:
Davide 2024-11-12 18:35:44 +01:00 committed by GitHub
parent e514ade036
commit 54f4364c33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 185 additions and 22 deletions

View File

@ -29,9 +29,14 @@ jobs:
- uses: passepartoutvpn/action-prepare-xcode-build@master
with:
access_token: ${{ secrets.ACCESS_TOKEN }}
- name: Run tests
id: run_tests
timeout-minutes: 15
run: |
bundle exec fastlane test
- name: Upload ${{ matrix.platform }} app
id: upload_app
timeout-minutes: 20
timeout-minutes: 30
env:
MATCH_USERNAME: ${{ secrets.MATCH_USERNAME }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}

View File

@ -15,16 +15,14 @@ concurrency:
cancel-in-progress: true
jobs:
run_tests:
name: Run tests
run_swift_tests:
name: Run SwiftPM tests
runs-on: macos-14
timeout-minutes: 10
steps:
- uses: passepartoutvpn/action-prepare-xcode-build@master
with:
access_token: ${{ secrets.ACCESS_TOKEN }}
- name: Run tests
run: |
#cd Passepartout/Library
#swift test
bundle exec fastlane test
- run: |
cd Passepartout/Library
swift test

View File

@ -8,6 +8,8 @@
/* Begin PBXBuildFile section */
0E182C6C2CD61CD800051DB2 /* AppUI in Frameworks */ = {isa = PBXBuildFile; productRef = 0E182C6B2CD61CD800051DB2 /* AppUI */; };
0E3FF4BA2CE3AFBC00BFF640 /* Profiles.sqlite in Resources */ = {isa = PBXBuildFile; fileRef = 0E3FF4B72CE3AFBC00BFF640 /* Profiles.sqlite */; };
0E3FF4BB2CE3AFBC00BFF640 /* LegacyV2CoreDataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3FF4B92CE3AFBC00BFF640 /* LegacyV2CoreDataTests.swift */; };
0E757F132CD0CFFC006E13E1 /* PassepartoutLoginItemApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E757F122CD0CFFC006E13E1 /* PassepartoutLoginItemApp.swift */; };
0E757F202CD0D22B006E13E1 /* PassepartoutLoginItem.app in Embed Login Item */ = {isa = PBXBuildFile; fileRef = 0E757F102CD0CFFC006E13E1 /* PassepartoutLoginItem.app */; platformFilters = (macos, ); settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
0E757F232CD0D2BD006E13E1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E757F212CD0D2B7006E13E1 /* AppDelegate.swift */; };
@ -32,6 +34,13 @@
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
0E3FF4B22CE3AF6F00BFF640 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0E06D1872B87629100176E1D /* Project object */;
proxyType = 1;
remoteGlobalIDString = 0E06D18E2B87629100176E1D;
remoteInfo = Passepartout;
};
0E757F242CD0D812006E13E1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0E06D1872B87629100176E1D /* Project object */;
@ -93,6 +102,9 @@
/* Begin PBXFileReference section */
0E06D18F2B87629100176E1D /* Passepartout.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Passepartout.app; sourceTree = BUILT_PRODUCTS_DIR; };
0E3FF4AE2CE3AF6F00BFF640 /* PassepartoutTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PassepartoutTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
0E3FF4B72CE3AFBC00BFF640 /* Profiles.sqlite */ = {isa = PBXFileReference; lastKnownFileType = file; path = Profiles.sqlite; sourceTree = "<group>"; };
0E3FF4B92CE3AFBC00BFF640 /* LegacyV2CoreDataTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LegacyV2CoreDataTests.swift; sourceTree = "<group>"; };
0E5DFDDC2CDB8F9100F2DE70 /* Passepartout.storekit */ = {isa = PBXFileReference; lastKnownFileType = text; path = Passepartout.storekit; sourceTree = "<group>"; };
0E757F102CD0CFFC006E13E1 /* PassepartoutLoginItem.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PassepartoutLoginItem.app; sourceTree = BUILT_PRODUCTS_DIR; };
0E757F122CD0CFFC006E13E1 /* PassepartoutLoginItemApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PassepartoutLoginItemApp.swift; sourceTree = "<group>"; };
@ -125,6 +137,13 @@
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
0E3FF4AB2CE3AF6F00BFF640 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
0E757F0D2CD0CFFC006E13E1 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@ -175,6 +194,7 @@
0EC332C82B8A1808000B9C2F /* PassepartoutTunnel.appex */,
0EDE56F02CABE42E0082D21C /* PassepartoutIntents.appex */,
0E757F102CD0CFFC006E13E1 /* PassepartoutLoginItem.app */,
0E3FF4AE2CE3AF6F00BFF640 /* PassepartoutTests.xctest */,
);
name = Products;
sourceTree = "<group>";
@ -187,6 +207,23 @@
name = Frameworks;
sourceTree = "<group>";
};
0E3FF4A92CE3AF4700BFF640 /* Tests */ = {
isa = PBXGroup;
children = (
0E3FF4B82CE3AFBC00BFF640 /* Resources */,
0E3FF4B92CE3AFBC00BFF640 /* LegacyV2CoreDataTests.swift */,
);
path = Tests;
sourceTree = "<group>";
};
0E3FF4B82CE3AFBC00BFF640 /* Resources */ = {
isa = PBXGroup;
children = (
0E3FF4B72CE3AFBC00BFF640 /* Profiles.sqlite */,
);
path = Resources;
sourceTree = "<group>";
};
0E757F112CD0CFFC006E13E1 /* LoginItem */ = {
isa = PBXGroup;
children = (
@ -207,6 +244,7 @@
0EDE56E82CABE40D0082D21C /* Intents */,
0E757F112CD0CFFC006E13E1 /* LoginItem */,
0E7E3D612B9345FD002BBDB4 /* Shared */,
0E3FF4A92CE3AF4700BFF640 /* Tests */,
0E7E3D652B9345FD002BBDB4 /* Tunnel */,
0EBE80DD2BF55C9100E36A20 /* Library */,
);
@ -298,6 +336,24 @@
productReference = 0E06D18F2B87629100176E1D /* Passepartout.app */;
productType = "com.apple.product-type.application";
};
0E3FF4AD2CE3AF6F00BFF640 /* PassepartoutTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0E3FF4B42CE3AF6F00BFF640 /* Build configuration list for PBXNativeTarget "PassepartoutTests" */;
buildPhases = (
0E3FF4AA2CE3AF6F00BFF640 /* Sources */,
0E3FF4AB2CE3AF6F00BFF640 /* Frameworks */,
0E3FF4AC2CE3AF6F00BFF640 /* Resources */,
);
buildRules = (
);
dependencies = (
0E3FF4B32CE3AF6F00BFF640 /* PBXTargetDependency */,
);
name = PassepartoutTests;
productName = PassepartoutTests;
productReference = 0E3FF4AE2CE3AF6F00BFF640 /* PassepartoutTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
0E757F0F2CD0CFFC006E13E1 /* PassepartoutLoginItem */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0E757F1E2CD0CFFD006E13E1 /* Build configuration list for PBXNativeTarget "PassepartoutLoginItem" */;
@ -366,6 +422,10 @@
0E06D18E2B87629100176E1D = {
CreatedOnToolsVersion = 15.2;
};
0E3FF4AD2CE3AF6F00BFF640 = {
CreatedOnToolsVersion = 15.4;
TestTargetID = 0E06D18E2B87629100176E1D;
};
0E757F0F2CD0CFFC006E13E1 = {
CreatedOnToolsVersion = 15.4;
};
@ -393,6 +453,7 @@
0E06D18E2B87629100176E1D /* Passepartout */,
0EDE56EF2CABE42E0082D21C /* PassepartoutIntents */,
0E757F0F2CD0CFFC006E13E1 /* PassepartoutLoginItem */,
0E3FF4AD2CE3AF6F00BFF640 /* PassepartoutTests */,
0EC332C72B8A1808000B9C2F /* PassepartoutTunnel */,
);
};
@ -410,6 +471,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
0E3FF4AC2CE3AF6F00BFF640 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0E3FF4BA2CE3AFBC00BFF640 /* Profiles.sqlite in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
0E757F0E2CD0CFFC006E13E1 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@ -469,6 +538,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
0E3FF4AA2CE3AF6F00BFF640 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0E3FF4BB2CE3AFBC00BFF640 /* LegacyV2CoreDataTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
0E757F0C2CD0CFFC006E13E1 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@ -498,6 +575,11 @@
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
0E3FF4B32CE3AF6F00BFF640 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 0E06D18E2B87629100176E1D /* Passepartout */;
targetProxy = 0E3FF4B22CE3AF6F00BFF640 /* PBXContainerItemProxy */;
};
0E6C0A032BF4047100450362 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = 0E6C0A022BF4047100450362 /* AppLibrary */;
@ -781,6 +863,30 @@
};
name = Release;
};
0E3FF4B52CE3AF6F00BFF640 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
ENABLE_USER_SCRIPT_SANDBOXING = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.algoritmico.ios.PassepartoutTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Passepartout.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Passepartout";
};
name = Debug;
};
0E3FF4B62CE3AF6F00BFF640 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
ENABLE_USER_SCRIPT_SANDBOXING = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.algoritmico.ios.PassepartoutTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Passepartout.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Passepartout";
};
name = Release;
};
0E757F1C2CD0CFFD006E13E1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@ -959,6 +1065,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0E3FF4B42CE3AF6F00BFF640 /* Build configuration list for PBXNativeTarget "PassepartoutTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0E3FF4B52CE3AF6F00BFF640 /* Debug */,
0E3FF4B62CE3AF6F00BFF640 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0E757F1E2CD0CFFD006E13E1 /* Build configuration list for PBXNativeTarget "PassepartoutLoginItem" */ = {
isa = XCConfigurationList;
buildConfigurations = (

View File

@ -33,6 +33,19 @@
default = "YES">
</TestPlanReference>
</TestPlans>
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0E3FF4AD2CE3AF6F00BFF640"
BuildableName = "PassepartoutTests.xctest"
BlueprintName = "PassepartoutTests"
ReferencedContainer = "container:Passepartout.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"

View File

@ -44,6 +44,19 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0E3FF4AD2CE3AF6F00BFF640"
BuildableName = "PassepartoutTests.xctest"
BlueprintName = "PassepartoutTests"
ReferencedContainer = "container:Passepartout.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"

View File

@ -43,6 +43,19 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0E3FF4AD2CE3AF6F00BFF640"
BuildableName = "PassepartoutTests.xctest"
BlueprintName = "PassepartoutTests"
ReferencedContainer = "container:Passepartout.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"

View File

@ -169,10 +169,7 @@ let package = Package(
),
.testTarget(
name: "LegacyV2Tests",
dependencies: ["LegacyV2"],
resources: [
.copy("Resources")
]
dependencies: ["LegacyV2"]
),
.testTarget(
name: "UILibraryTests",

View File

@ -42,7 +42,8 @@ private extension BundleConfiguration {
static var cachesURL: URL {
let groupId = mainString(for: .groupId)
guard let url = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: groupId) else {
fatalError("Unable to access App Group container")
pp_log(.app, .error, "Unable to access App Group container")
return FileManager.default.temporaryDirectory
}
return url.appending(components: "Library", "Caches")
}

View File

@ -39,6 +39,13 @@
"identifier" : "LegacyV2Tests",
"name" : "LegacyV2Tests"
}
},
{
"target" : {
"containerPath" : "container:Passepartout.xcodeproj",
"identifier" : "0E3FF4AD2CE3AF6F00BFF640",
"name" : "PassepartoutTests"
}
}
],
"version" : 1

View File

@ -1,5 +1,5 @@
//
// LegacyV2Tests.swift
// LegacyV2CoreDataTests.swift
// Passepartout
//
// Created by Davide De Rosa on 11/12/24.
@ -29,7 +29,7 @@ import Foundation
import PassepartoutKit
import XCTest
final class LegacyV2Tests: XCTestCase {
final class LegacyV2CoreDataTests: XCTestCase {
func test_givenStore_whenFetchV2_thenReturnsProfilesV2() async throws {
let sut = newStore()
@ -217,9 +217,9 @@ final class LegacyV2Tests: XCTestCase {
}
}
private extension LegacyV2Tests {
private extension LegacyV2CoreDataTests {
func newStore() -> LegacyV2 {
guard let baseURL = Bundle.module.url(forResource: "Resources", withExtension: nil) else {
guard let baseURL = Bundle(for: LegacyV2CoreDataTests.self).resourceURL else {
fatalError()
}
return LegacyV2(

View File

@ -19,6 +19,8 @@ Dotenv.load ".env.secret"
setup_ci if ENV["CI"]
logname = "CHANGELOG.txt"
build_path = "build"
derived_data_path = "build/derived_data"
desc "Bump version"
lane :bump do |options|
@ -61,12 +63,11 @@ lane :bump do |options|
)
end
desc "Run app tests"
desc "Run Xcode tests"
lane :test do
scan(
clean: true,
xcargs: "CODE_SIGNING_ALLOWED=NO",
verbose: true
derived_data_path: derived_data_path
)
end
@ -78,8 +79,8 @@ lane :beta do
match(type: "appstore")
gym(
clean: true,
build_path: "build",
derived_data_path: "build/derived_data"
build_path: build_path,
derived_data_path: derived_data_path
)
pilot(
changelog: changelog,