Skip to content

Commit

Permalink
ci: initial GitHub Actions setup and test (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Seavenly authored Sep 7, 2023
1 parent 9a3b4cf commit 43d9ff0
Show file tree
Hide file tree
Showing 15 changed files with 181 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install Dependencies
run: bundle install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
runs-on: macOS-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install Dependencies
run: bundle install

- name: Run Linting
run: bundle exec fastlane lint
run: bundle exec fastlane lint summary:$GITHUB_STEP_SUMMARY
7 changes: 1 addition & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
workflow_dispatch: {}
push:
branches:
- release
- main

jobs:
linting:
Expand Down Expand Up @@ -33,11 +33,6 @@ jobs:
fetch-depth: '0'
persist-credentials: false

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "lts/*"

- name: Install Dependencies
run: |
bundle install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
runs-on: macOS-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install Dependencies
run: bundle install

- name: Run Unit Tests
run: bundle exec fastlane tests
run: bundle exec fastlane tests summary:$GITHUB_STEP_SUMMARY
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ SampleApps/SPMTest/SPMTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Pa
# Fastlane
/fastlane/report.xml
/fastlane/coverage
/fastlane/test_output/
/fastlane/test_output
/fastlane/swiftlint

4 changes: 2 additions & 2 deletions Demo/Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.1;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -360,7 +360,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.1;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand Down
1 change: 0 additions & 1 deletion Demo/Demo/SwiftUIContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ struct SwiftUIContentView: View {
}

Divider()
.overlay(.gray)

// MARK: PayPal Message

Expand Down
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import PackageDescription

let package = Package(
name: "PayPalMessages",
platforms: [.iOS(.v14)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
Expand Down
6 changes: 3 additions & 3 deletions PayPalMessages.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,10 @@
isa = PBXGroup;
children = (
C635F4A62A964A020096F9FF /* MessageRequest.swift */,
C635F4AA2A964A020096F9FF /* MessageResponse.swift */,
C635F4A72A964A020096F9FF /* MerchantProfileProvider.swift */,
C635F4A82A964A020096F9FF /* MerchantProfileRequest.swift */,
C635F4A92A964A020096F9FF /* MerchantProfileData.swift */,
C635F4AA2A964A020096F9FF /* MessageResponse.swift */,
);
path = IO;
sourceTree = "<group>";
Expand Down Expand Up @@ -570,7 +570,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.1;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -624,7 +624,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.1;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1420"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C635F4342A9645B10096F9FF"
BuildableName = "PayPalMessagesTests.xctest"
BlueprintName = "PayPalMessagesTests"
ReferencedContainer = "container:PayPalMessages.xcodeproj">
</BuildableReference>
</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">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
2 changes: 1 addition & 1 deletion Sources/PayPalMessages/Enums/BuildInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// If any of the names are changed the CI should be updated as well.
public enum BuildInfo {
/// Library version
public static let version: String = "0.1.0"
public internal(set) static var version: String = "0.1.0"
/// Message rendering environment
public static let integrationType: String = "NATIVE_IOS"
}
6 changes: 3 additions & 3 deletions Sources/PayPalMessages/Extensions/UIColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ extension UIColor {
let scanner = Scanner(string: hexString as String)

if hexString.hasPrefix("#") {
scanner.scanLocation = 1
scanner.currentIndex = scanner.string.index(after: scanner.currentIndex)
}
var color: UInt32 = 0
scanner.scanHexInt32(&color)
var color: UInt64 = 0
scanner.scanHexInt64(&color)

let mask = 0x000000FF
let redValue = Int(color >> 16) & mask
Expand Down
8 changes: 7 additions & 1 deletion Sources/PayPalMessages/Extensions/UIViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import UIKit
extension UIViewController {

static func getPresentingViewController() -> UIViewController? {
if var rootViewController = UIApplication.shared.keyWindow?.rootViewController {
let keyWindow = UIApplication
.shared
.connectedScenes
.flatMap { ($0 as? UIWindowScene)?.windows ?? [] }
.last { $0.isKeyWindow }

if var rootViewController = keyWindow?.rootViewController {
while let presentedViewController = rootViewController.presentedViewController {
rootViewController = presentedViewController
}
Expand Down
23 changes: 19 additions & 4 deletions Tests/PayPalMessagesTests/PayPalMessageLoggerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ final class PayPalMessageLoggerTests: XCTestCase {
override func setUp() {
super.setUp()

Logger.integrationName = "Test_SDK"
Logger.integrationVersion = "0.1.0"
Logger.deviceID = "987654321"
Logger.sessionID = "123456789"
BuildInfo.version = "1.0.0"

PayPalMessageConfig.setGlobalAnalytics(
integrationName: "Test_SDK",
integrationVersion: "0.1.0",
deviceID: "987654321",
sessionID: "123456789"
)

// Inject mock sender to intercept log requests
logger.sender = mockSender
Expand Down Expand Up @@ -49,6 +53,8 @@ final class PayPalMessageLoggerTests: XCTestCase {
}

let expectedPayload: [String: Any] = [
"lib_version": "1.0.0",
"integration_name": "Test_SDK",
"integration_type": "NATIVE_IOS",
"client_id": "testclientid",
"integration_version": "0.1.0",
Expand Down Expand Up @@ -117,6 +123,8 @@ final class PayPalMessageLoggerTests: XCTestCase {
}

let expectedPayload: [String: Any] = [
"lib_version": "1.0.0",
"integration_name": "Test_SDK",
"integration_type": "NATIVE_IOS",
"client_id": "testclientid",
"integration_version": "0.1.0",
Expand Down Expand Up @@ -189,6 +197,8 @@ final class PayPalMessageLoggerTests: XCTestCase {
}

let expectedPayload: [String: Any] = [
"lib_version": "1.0.0",
"integration_name": "Test_SDK",
"integration_type": "NATIVE_IOS",
"client_id": "testclientid",
"integration_version": "0.1.0",
Expand Down Expand Up @@ -260,6 +270,8 @@ final class PayPalMessageLoggerTests: XCTestCase {
}

let expectedPayload: [String: Any] = [
"lib_version": "1.0.0",
"integration_name": "Test_SDK",
"integration_type": "NATIVE_IOS",
"client_id": "testclientid",
"integration_version": "0.1.0",
Expand Down Expand Up @@ -314,6 +326,8 @@ final class PayPalMessageLoggerTests: XCTestCase {
}

let expectedPayload: [String: Any] = [
"lib_version": "1.0.0",
"integration_name": "Test_SDK",
"integration_type": "NATIVE_IOS",
"client_id": "testclientid",
"integration_version": "0.1.0",
Expand Down Expand Up @@ -389,3 +403,4 @@ final class PayPalMessageLoggerTests: XCTestCase {
XCTAssertTrue(isEqual)
}
}
// swiftlint:disable:this file_length
Loading

0 comments on commit 43d9ff0

Please sign in to comment.