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

chore: SPM unit tests #842

Merged
merged 34 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
efb16fc
Rig up SPM test target
jnewc Apr 19, 2024
2bf8c71
CI setup
jnewc Apr 19, 2024
ec0a4b8
workflow mod
jnewc Apr 19, 2024
1fb9df5
update xcode version for spm workflow
jnewc Apr 19, 2024
2edcd11
xcode -> 15.3
jnewc Apr 19, 2024
798f094
15.2 + 17.2
jnewc Apr 19, 2024
9b6b200
Larger instance for spm tests
jnewc Apr 19, 2024
9fe6e48
Enable build for test target + tidy fastfile
jnewc Apr 19, 2024
be4e3bc
revert destination
jnewc Apr 19, 2024
0d83604
Fix analytics tests
jnewc Apr 19, 2024
411d55f
Enable debugging for spm test target
jnewc Apr 19, 2024
baa2aae
Add extension to retrieve windows for UIApplication
jnewc Apr 19, 2024
32285aa
Reduce network interval
jnewc Apr 19, 2024
5c2005d
project file update
jnewc Apr 19, 2024
3616e6b
Ensure web redirect presentation gracefully handles testing cases whe…
jnewc Apr 19, 2024
45eca62
Fix fastlane xcresult issue
jnewc Apr 19, 2024
bd7d9c2
Reduce mock network delay
jnewc Apr 19, 2024
bccd768
Normalise mock network delays
jnewc Apr 19, 2024
20a05a3
Whitespace
jnewc Apr 19, 2024
231a991
Fix fastlane sim version again
jnewc Apr 19, 2024
63f908a
Faster HUC tests
jnewc Apr 19, 2024
6ef8879
Fix issues with BankComponentTests
jnewc Apr 19, 2024
8e63aaf
Test fix
jnewc Apr 19, 2024
e08bbb1
HUC test fix
jnewc Apr 19, 2024
d2e9d46
HUC test fix #2
jnewc Apr 19, 2024
c246492
HUC test fix #3
jnewc Apr 19, 2024
18cfc80
Revert HUC tests
jnewc Apr 20, 2024
d56d29c
Reorganise tests + reinstate debug app tests
jnewc Apr 20, 2024
a5850c4
Update dangerfile with tests location filter
jnewc Apr 20, 2024
6d93a4f
Fully detach build jobs from 'edited' trigger
jnewc Apr 22, 2024
fdb448b
cleanup workflows
jnewc Apr 22, 2024
adc425c
Remove edited trigger from pod lint workflow
jnewc Apr 22, 2024
e06a694
More workflow cleanup + fix concurrency groups
jnewc Apr 22, 2024
ab16cb8
Wrap view presentation workaround in #if DEBUG
jnewc Apr 22, 2024
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
34 changes: 11 additions & 23 deletions .github/workflows/build_test_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,17 @@ on:
pull_request:
types:
- opened
- edited
- synchronize

concurrency:
group: ${{ github.ref }}
group: ${{ github.ref }}-tests
cancel-in-progress: true

jobs:
danger:
runs-on: ubuntu-latest
name: "Run Danger"
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Danger
uses: docker://ghcr.io/danger/danger-swift-with-swiftlint@sha256:ed07386a85f1328619b49e3cfd737ffce351fcd2620d858cfc997d7e3e401b59 #v3.15.0
with:
args: --failOnErrors --no-publish-check --remove-previous-comments
env:
GITHUB_TOKEN: ${{ github.token }}
unit-test:
needs: danger
debug-app-unit-tests:
runs-on: macos-13-large
timeout-minutes: 30
name: "Unit Tests"
name: "Debug App - Unit Tests"
steps:
- name: Git - Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down Expand Up @@ -62,11 +49,10 @@ jobs:
MATCH_KEYCHAIN_NAME: ${{ secrets.MATCH_KEYCHAIN_NAME }}
MATCH_KEYCHAIN_PASSWORD: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }}
SOURCE_BRANCH: ${{ github.head_ref }}
spm-build:
needs: unit-test
runs-on: macos-13
sdk-unit-tests:
runs-on: macos-13-large
timeout-minutes: 20
name: "Build app with SPM Integration"
name: "SDK - Unit Tests"
steps:
- name: Cancel previous jobs
uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1
Expand All @@ -79,7 +65,7 @@ jobs:
- name: Select Xcode Version
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
with:
xcode-version: '14.3.1'
xcode-version: '15.2'
- name: Install SSH key
uses: shimataro/ssh-key-action@d4fffb50872869abe2d9a9098a6d9c5aa7d16be4 #v2.7.0
with:
Expand All @@ -95,7 +81,7 @@ jobs:
bundler-cache: true
- name: Build SPM App
run: |
bundle exec fastlane build_spm
bundle exec fastlane test_spm
env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
MATCH_GIT_PRIVATE_KEY: ${{ secrets.SSH_KEY }}
Expand All @@ -105,7 +91,9 @@ jobs:
MATCH_KEYCHAIN_PASSWORD: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }}
SOURCE_BRANCH: ${{ github.head_ref }}
build-and-upload-to-appetize:
needs: unit-test
needs:
- debug-app-unit-tests
- sdk-unit-tests
runs-on: macos-13
timeout-minutes: 45
name: "Build and upload app to Appetize"
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/danger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Danger

on:
pull_request:
types:
- opened
- edited
- synchronize

concurrency:
group: ${{ github.ref }}-danger
cancel-in-progress: true

jobs:
danger:
runs-on: ubuntu-latest
name: "Run Danger"
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Danger
uses: docker://ghcr.io/danger/danger-swift-with-swiftlint@sha256:ed07386a85f1328619b49e3cfd737ffce351fcd2620d858cfc997d7e3e401b59 #v3.15.0
with:
args: --failOnErrors --no-publish-check --remove-previous-comments
env:
GITHUB_TOKEN: ${{ github.token }}
1 change: 0 additions & 1 deletion .github/workflows/pod_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
pull_request:
types:
- opened
- edited
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌 Thanks for this + the above. No more rebuilds for edits 😅

- synchronize

jobs:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Sonarcloud

on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]

jobs:
sonarcloud:
name: SonarCloud
Expand Down
79 changes: 79 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/PrimerSDKTests.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
version = "2.2">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<AutocreatedTestPlanReference>
</AutocreatedTestPlanReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "PrimerSDKTests"
BuildableName = "PrimerSDKTests"
BlueprintName = "PrimerSDKTests"
ReferencedContainer = "container:">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "HUC_TokenizationViewModelTests">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "PrimerSDKTests"
BuildableName = "PrimerSDKTests"
BlueprintName = "PrimerSDKTests"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
2 changes: 1 addition & 1 deletion Dangerfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let allCreatedAndModifiedFiles = danger.git.modifiedFiles + danger.git.createdFi
let sdkEditedFiles = allCreatedAndModifiedFiles
.filter { $0.name != "Dangerfile.swift" }
.filter { !$0.hasPrefix("Debug App/") }

.filter { !$0.hasPrefix("Tests/") }
// You can use these functions to send feedback:
// message("Highlight something in the table")
// warn("Something pretty bad, but not important enough to fail the build")
Expand Down
8 changes: 4 additions & 4 deletions Debug App/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ PODS:
- PrimerIPay88MYSDK (0.1.7)
- PrimerKlarnaSDK (1.1.1)
- PrimerNolPaySDK (1.0.1)
- PrimerSDK (2.26.1):
- PrimerSDK/Core (= 2.26.1)
- PrimerSDK/Core (2.26.1)
- PrimerSDK (2.26.2):
- PrimerSDK/Core (= 2.26.2)
- PrimerSDK/Core (2.26.2)

DEPENDENCIES:
- IQKeyboardManagerSwift
Expand Down Expand Up @@ -34,7 +34,7 @@ SPEC CHECKSUMS:
PrimerIPay88MYSDK: 436ee0be7e2c97e4e81456ccddee20175e9e3c4d
PrimerKlarnaSDK: 564105170cc7b467bf95c31851813ea41c468f8b
PrimerNolPaySDK: 08b140ed39b378a0b33b4f8746544a402175c0cc
PrimerSDK: 713186fdff6edb8c769b0d7fe67171b762c62437
PrimerSDK: 31a56fb3a0d12210e55a8c5af8b9382e7cffdc83

PODFILE CHECKSUM: 4070d0f559c86f4414e465a26e3de7b095420546

Expand Down
16 changes: 0 additions & 16 deletions Debug App/Primer.io Debug App SPM.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@
1B8CB5A11A44AA9F3D7FE356 /* UserInterfaceModuleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserInterfaceModuleTests.swift; sourceTree = "<group>"; };
1D05E65C196E6715D7D8B0C6 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/Main.strings; sourceTree = "<group>"; };
1F23211288F9B61390C0BF8D /* Pods_Debug_App_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Debug_App_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1F4E35F809D3FAF4354D5B05 /* URLSessionStackTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionStackTests.swift; sourceTree = "<group>"; };
1F79B50111AC4161CFB1EFE8 /* ApayaTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApayaTests.swift; sourceTree = "<group>"; };
229849A3DBE0858EE90673B9 /* CreateClientToken.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateClientToken.swift; sourceTree = "<group>"; };
25FD540BEA16ABBDFE7DE182 /* PayPalService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PayPalService.swift; sourceTree = "<group>"; };
2A328E38DA586FFE0ED2894B /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Main.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -145,7 +143,6 @@
A1604A656AF654D7422A2A5E /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Main.strings; sourceTree = "<group>"; };
A6AEF11B151368BF993C3EA9 /* TestScenario.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestScenario.swift; sourceTree = "<group>"; };
AD381E7E16D01D8D743232F7 /* ThemeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeTests.swift; sourceTree = "<group>"; };
AF07D2421252EA2AE5C2FC4F /* AnalyticsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsTests.swift; sourceTree = "<group>"; };
B18D7E7738BF86467B0F1465 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
B1FD8065D40A2D691F643F3B /* UIViewController+API.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+API.swift"; sourceTree = "<group>"; };
B266F9E1651BD20E45DCCF68 /* PrimerRawRetailerDataTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimerRawRetailerDataTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -176,7 +173,6 @@
E63F5C5C1FD2F3E6CB02EC5A /* HeadlessUniversalCheckoutTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlessUniversalCheckoutTests.swift; sourceTree = "<group>"; };
E7640DB186F9638C2F556F77 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Main.strings; sourceTree = "<group>"; };
E8DE1E4FB055B60582977315 /* Networking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Networking.swift; sourceTree = "<group>"; };
E90441E821B5FE76643B62A6 /* AnalyticsTests+Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AnalyticsTests+Constants.swift"; sourceTree = "<group>"; };
E9899972360BCA5992CEE5BC /* PrimerBancontactCardDataManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimerBancontactCardDataManagerTests.swift; sourceTree = "<group>"; };
EB6C18F747AEC20B8C63164C /* Pods_Debug_App.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Debug_App.framework; sourceTree = BUILT_PRODUCTS_DIR; };
EEB1E1B37192BF739461AFF1 /* PrimerRawCardDataManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimerRawCardDataManagerTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -267,7 +263,6 @@
2F23D3C9CC9CBC1B95329B1C /* Network */ = {
isa = PBXGroup;
children = (
1F4E35F809D3FAF4354D5B05 /* URLSessionStackTests.swift */,
);
path = Network;
sourceTree = "<group>";
Expand Down Expand Up @@ -429,7 +424,6 @@
D83EED4C1249B62B908781B0 /* Data Models */ = {
isa = PBXGroup;
children = (
1F79B50111AC4161CFB1EFE8 /* ApayaTests.swift */,
31CFA93A373A7DB78DA77283 /* ApplePayTests.swift */,
5F8DC3341BDBB9AEDBE8D6DD /* DecodedClientToken.swift */,
7A5E6F7A9C12C69CB66032E3 /* IPay88Tests.swift */,
Expand All @@ -447,7 +441,6 @@
D99811C39E1808A948623732 /* Unit Tests */ = {
isa = PBXGroup;
children = (
E1A2F78003351E14426E0B36 /* Analytics */,
D83EED4C1249B62B908781B0 /* Data Models */,
626776D8EFEF24D5C5A36307 /* Extensions */,
A95565BDB7031F41ECD023D7 /* Helpers */,
Expand Down Expand Up @@ -511,15 +504,6 @@
path = FormWithRedirect;
sourceTree = "<group>";
};
E1A2F78003351E14426E0B36 /* Analytics */ = {
isa = PBXGroup;
children = (
AF07D2421252EA2AE5C2FC4F /* AnalyticsTests.swift */,
E90441E821B5FE76643B62A6 /* AnalyticsTests+Constants.swift */,
);
path = Analytics;
sourceTree = "<group>";
};
E4C8DBB82E4149A7C4D26467 /* Mocks */ = {
isa = PBXGroup;
children = (
Expand Down
Loading