Skip to content

Conversation

@NidhiDixit09
Copy link
Collaborator

Reference

SDK-XXXX -- <TITLE>.

Summary

Motivation

Type Of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Testing Instructions

cc @BranchMetrics/saas-sdk-devs for visibility.

@matter-code-review
Copy link
Contributor

Code Quality refactoring testability ci-cd

Summary By MatterAI MatterAI logo

🔄 What Changed

Refactored SDK integration tests by consolidating test logic into shared source files, removing redundant test implementations across multiple test targets. Enhanced GitHub Actions workflows with test result bundling, artifact uploads, and timeout configurations. Added a centralized TestObserver for detailed test logging and visibility.

🔍 Impact of the Change

Improved test maintainability and consistency across iOS/tvOS integration test suites. Enabled structured test reporting in CI via .xcresult bundles. Removed code duplication, reducing future maintenance overhead. Strengthened CI/CD reliability with timeouts and artifact preservation.

📁 Total Files Changed

File ChangeLog
CI Refactor .github/workflows/post-release-qa.yml Added timeout-minutes, test result bundling, and artifact upload steps for all test jobs
CI Refactor .github/workflows/pre-release-qa.yml Standardized CI config: added timeouts, result paths, and artifact uploads
Build Ignore .gitignore Added .build to ignore SwiftPM build artifacts
Platform Config Podfile Set tvOS platform version to 18.0 for Cocoapods
Test Observer TestObserver.swift Introduced XCTest observer for enhanced logging in CI
Test Migration iOSReleaseTestTests.swift Moved to shared source with improved structure and expectations
Test Migration tvOSReleaseTestTests.swift Unified test logic with new observer pattern
SDK Test Abstraction BranchSDKTest.swift Centralized SDK init and CPP level control
Entitlements Reset iOSReleaseTest.entitlements Simplified entitlements with empty dict
Legacy Removal Various .swift, .storyboard, .entitlements Removed outdated test app files from integration test targets

🧪 Test Added/Recommended

Added

  • TestObserver: Captures test lifecycle events with timestamped logs for improved CI debugging.
  • Enhanced Test Cases: testInitSessionAndSetCPPLevel now uses expectations and proper async handling.
  • Dummy Test: Validates test setup with minimal assertion.

Recommended

  • Add negative test cases for invalid CPP levels.
  • Include network failure simulation in init session tests.
  • Add performance tests for SDK initialization under low-memory conditions.

🔒 Security Vulnerabilities

No security vulnerabilities detected. Code signing disabled in CI (via CODE_SIGNING_ALLOWED=NO) is safe in isolated test environments.

⏳ Estimated code review effort

HIGH (~35 minutes)

Tip

Quality Recommendations

  1. Add nullability checks for callback parameters in BranchSDKTest init to prevent runtime crashes

  2. Use XCTestCase setUpWithError() instead of setUp() to align with modern XCTest patterns

  3. Replace force-unwrapping of cppLevel with safe unwrapping or default value to avoid runtime exceptions

  4. Add documentation comments to TestObserver methods explaining their CI logging purpose

  5. Implement tearDown logic in test cases to reset SDK state between runs

♫ Tanka Poem

Code once scattered,
Now flows through one clear path.
Tests speak aloud,
CI beams with rich logs.
Progress, elegant.

Sequence Diagram

sequenceDiagram
    participant GH as GitHub Actions
    participant CI as CI Runner (macos-latest)
    participant Xcode as xcodebuild
    participant Test as XCTest
    participant Observer as TestObserver

    Note over CI: Setup & Dependencies
    GH->>CI: Trigger workflow (push/release)
    CI->>CI: mkdir -p test-results
    CI->>CI: Checkout code + scripts
    CI->>CI: Install deps (pod/carthage/SPM)

    Note over CI: Test Execution
    CI->>Xcode: xcodebuild clean test
    Xcode->>Test: Launch XCTestCase
    Test->>Observer: testBundleWillStart()
    Observer->>Observer: logMessage()
    Test->>Observer: testSuiteWillStart()
    Observer->>Observer: logMessage()
    Test->>Observer: testCaseWillStart()
    Observer->>Observer: logMessage()

    Note over Test: SDK Init & Test Logic
    Test->>Test: init BranchSDKTest(callback)
    Test->>Test: setCPPLevel(none)
    Test->>Test: waitForExpectations(timeout:180)
    Test->>Observer: testCaseDidFinish()
    Observer->>Observer: log duration/failure status

    Note over CI: Artifact Upload
    Xcode->>CI: Generate .xcresult bundle
    CI->>GH: Upload test-report-* via upload-artifact
Loading

@matter-code-review
Copy link
Contributor

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use MatterAI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with MatterAI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant