diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 11a5efb2..c0749bf0 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -6,14 +6,10 @@ on: jobs: build: name: Run unit tests and build dynamic SDK binary - runs-on: macos-13 + runs-on: self-hosted steps: - - name: Install xcbeautify - run: brew install xcbeautify - name: Checkout uses: actions/checkout@v3 - - name: "Switch to Xcode 15.2" - run: sudo xcode-select -switch /Applications/Xcode_15.2.app - name: "Baseline Unit Test Pass" run: ./scripts/run-baseline-unit-test-pass.sh - name: "🔨 Build Dynamic XCFramework" @@ -26,14 +22,10 @@ jobs: tests: name: Test the SDK with a Demo App needs: build - runs-on: macos-13 + runs-on: self-hosted steps: - - name: Install xcbeautify - run: brew install xcbeautify - name: Checkout uses: actions/checkout@v3 - - name: "Switch to Xcode 15.2" - run: sudo xcode-select -switch /Applications/Xcode_15.2.app - name: Download framework artifact uses: actions/download-artifact@v3 with: @@ -44,14 +36,10 @@ jobs: run: "scripts/run-tests-swift-package-manager-ventura.sh" build-static: name: Build static SDK binary - runs-on: macos-13 + runs-on: self-hosted steps: - - name: Install xcbeautify - run: brew install xcbeautify - name: Checkout uses: actions/checkout@v3 - - name: "Switch to Xcode 15.2" - run: sudo xcode-select -switch /Applications/Xcode_15.2.app - name: "🔨 Build Static XCFramework" run: ".github/workflows/scripts/build-static.sh" - name: "Upload xcframework artifact" diff --git a/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM-CI.xctestplan b/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM-CI.xctestplan new file mode 100644 index 00000000..36d70e4b --- /dev/null +++ b/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM-CI.xctestplan @@ -0,0 +1,46 @@ +{ + "configurations" : [ + { + "id" : "C9F5DF09-2B97-41D0-AEFF-9DDFA7BF2B96", + "name" : "Test Scheme Action", + "options" : { + + } + } + ], + "defaultOptions" : { + "environmentVariableEntries" : [ + { + "key" : "ENV_KEY", + "value" : "" + }, + { + "key" : "PLAYBACK_ID", + "value" : "" + } + ], + "targetForVariableExpansion" : { + "containerPath" : "container:MUXSDKStatsExampleSPM.xcodeproj", + "identifier" : "19CB35CB2ABD2B5C002DF48C", + "name" : "MUXSDKStatsExampleSPM" + } + }, + "testTargets" : [ + { + "enabled" : false, + "target" : { + "containerPath" : "container:MUXSDKStatsExampleSPM.xcodeproj", + "identifier" : "19CB35E12ABD2B5D002DF48C", + "name" : "MUXSDKStatsExampleSPMTests" + } + }, + { + "target" : { + "containerPath" : "container:MUXSDKStatsExampleSPM.xcodeproj", + "identifier" : "19CB35EB2ABD2B5D002DF48C", + "name" : "MUXSDKStatsExampleSPMUITests" + } + } + ], + "version" : 1 +} diff --git a/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM.xcodeproj/project.pbxproj b/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM.xcodeproj/project.pbxproj index b340fa88..192328d5 100644 --- a/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM.xcodeproj/project.pbxproj +++ b/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 190698952BB76EDE00CE0FF7 /* CustomSessionDataExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 190698942BB76EDE00CE0FF7 /* CustomSessionDataExampleViewController.swift */; }; + 190698972BB7769900CE0FF7 /* MUXSDKStatsExampleSPM-CI.xctestplan in Resources */ = {isa = PBXBuildFile; fileRef = 190698962BB7769900CE0FF7 /* MUXSDKStatsExampleSPM-CI.xctestplan */; }; 195762142AD64B2800128565 /* AudioOnlyPlaybackExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 195762132AD64B2800128565 /* AudioOnlyPlaybackExampleViewController.swift */; }; 19C386A82AD12344009AB018 /* MultiplePlayerItemPlaybackExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C386A72AD12343009AB018 /* MultiplePlayerItemPlaybackExampleViewController.swift */; }; 19C386AA2AD3194F009AB018 /* PlayerLayerScalingExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C386A92AD3194F009AB018 /* PlayerLayerScalingExampleViewController.swift */; }; @@ -42,6 +44,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 190698942BB76EDE00CE0FF7 /* CustomSessionDataExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomSessionDataExampleViewController.swift; sourceTree = ""; }; + 190698962BB7769900CE0FF7 /* MUXSDKStatsExampleSPM-CI.xctestplan */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "MUXSDKStatsExampleSPM-CI.xctestplan"; sourceTree = ""; }; 194C6D432ABD518A003F965E /* mux-stats-sdk-avplayer */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "mux-stats-sdk-avplayer"; path = ../..; sourceTree = ""; }; 195762132AD64B2800128565 /* AudioOnlyPlaybackExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioOnlyPlaybackExampleViewController.swift; sourceTree = ""; }; 19ABBEA92B650DB2004A3634 /* MUXSDKStatsExampleSPM.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = MUXSDKStatsExampleSPM.xctestplan; sourceTree = ""; }; @@ -102,6 +106,7 @@ isa = PBXGroup; children = ( 19ABBEA92B650DB2004A3634 /* MUXSDKStatsExampleSPM.xctestplan */, + 190698962BB7769900CE0FF7 /* MUXSDKStatsExampleSPM-CI.xctestplan */, 194C6D422ABD518A003F965E /* Packages */, 19CB35CE2ABD2B5C002DF48C /* MUXSDKStatsExampleSPM */, 19CB35E52ABD2B5D002DF48C /* MUXSDKStatsExampleSPMTests */, @@ -130,6 +135,7 @@ 19C386A72AD12343009AB018 /* MultiplePlayerItemPlaybackExampleViewController.swift */, 19C386A92AD3194F009AB018 /* PlayerLayerScalingExampleViewController.swift */, 195762132AD64B2800128565 /* AudioOnlyPlaybackExampleViewController.swift */, + 190698942BB76EDE00CE0FF7 /* CustomSessionDataExampleViewController.swift */, 19CB36042ABD2D63002DF48C /* ProcessInfo+Mux.swift */, 19CB35D52ABD2B5C002DF48C /* Main.storyboard */, 19CB35D82ABD2B5D002DF48C /* Assets.xcassets */, @@ -268,6 +274,7 @@ 19CB35DC2ABD2B5D002DF48C /* LaunchScreen.storyboard in Resources */, 19CB35D92ABD2B5D002DF48C /* Assets.xcassets in Resources */, 19CB35D72ABD2B5C002DF48C /* Main.storyboard in Resources */, + 190698972BB7769900CE0FF7 /* MUXSDKStatsExampleSPM-CI.xctestplan in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -293,6 +300,7 @@ buildActionMask = 2147483647; files = ( 19CB36052ABD2D63002DF48C /* ProcessInfo+Mux.swift in Sources */, + 190698952BB76EDE00CE0FF7 /* CustomSessionDataExampleViewController.swift in Sources */, 19C386AA2AD3194F009AB018 /* PlayerLayerScalingExampleViewController.swift in Sources */, 19C386A82AD12344009AB018 /* MultiplePlayerItemPlaybackExampleViewController.swift in Sources */, 19CB35D42ABD2B5C002DF48C /* BasicPlaybackExampleViewController.swift in Sources */, diff --git a/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM.xcodeproj/xcshareddata/xcschemes/MUXSDKStatsExampleSPM-CI.xcscheme b/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM.xcodeproj/xcshareddata/xcschemes/MUXSDKStatsExampleSPM-CI.xcscheme new file mode 100644 index 00000000..e3e276a9 --- /dev/null +++ b/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM.xcodeproj/xcshareddata/xcschemes/MUXSDKStatsExampleSPM-CI.xcscheme @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM.xctestplan b/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM.xctestplan index 36d70e4b..44973994 100644 --- a/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM.xctestplan +++ b/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM.xctestplan @@ -35,6 +35,9 @@ } }, { + "skippedTests" : [ + "MUXSDKStatsExampleSPMUITests\/testCustomSessionDataExample()" + ], "target" : { "containerPath" : "container:MUXSDKStatsExampleSPM.xcodeproj", "identifier" : "19CB35EB2ABD2B5D002DF48C", diff --git a/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM/Base.lproj/Main.storyboard b/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM/Base.lproj/Main.storyboard index 2b3618ab..f760f5d1 100644 --- a/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM/Base.lproj/Main.storyboard +++ b/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -42,6 +42,23 @@ + + + + + + + + + + + + + + + + + @@ -275,6 +292,34 @@ + + + + + + + + + + + + + + + + diff --git a/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM/CustomSessionDataExampleViewController.swift b/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM/CustomSessionDataExampleViewController.swift new file mode 100644 index 00000000..4dc399a4 --- /dev/null +++ b/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPM/CustomSessionDataExampleViewController.swift @@ -0,0 +1,94 @@ +// +// CustomSessionDataExampleViewController.swift +// MUXSDKStatsExampleSPM +// + +import UIKit +import AVKit +import MUXSDKStats + + +class CustomSessionDataExampleViewController: UIViewController { + + var playbackURL: URL { + let playbackID = ProcessInfo.processInfo.playbackID ?? "qxb01i6T202018GFS02vp9RIe01icTcDCjVzQpmaB00CUisJ4" + + return URL( + string: "http://127.0.0.1:8789/mux-tests/session-data/multivariant-with-other-session-data.m3u8" + )! + } + let playerName = "CustomSessionDataExample" + lazy var playerViewController = AVPlayerViewController() + + override func viewDidLoad() { + super.viewDidLoad() + + let playerData = MUXSDKCustomerPlayerData() + playerData.environmentKey = ProcessInfo.processInfo.environmentKey + + let videoData = MUXSDKCustomerVideoData() + videoData.videoId = "VideoBehindTheScenes" + videoData.videoTitle = "Video Behind the Scenes" + + let customerData = MUXSDKCustomerData( + customerPlayerData: playerData, + videoData: videoData, + viewData: nil + ) + + let player = AVPlayer(url: playbackURL) + playerViewController.player = player + + displayPlayerViewController() + + MUXSDKStats.monitorAVPlayerViewController( + playerViewController, + withPlayerName: playerName, + customerData: customerData! + ) + } + + func displayPlayerViewController() { + self.addChild(playerViewController) + playerViewController.view + .translatesAutoresizingMaskIntoConstraints = false + self.view.addSubview(playerViewController.view) + self.view.addConstraints([ + self.view.topAnchor.constraint( + equalTo: playerViewController.view.topAnchor + ), + self.view.bottomAnchor.constraint( + equalTo: playerViewController.view.bottomAnchor + ), + self.view.leadingAnchor.constraint( + equalTo: playerViewController.view.leadingAnchor + ), + self.view.trailingAnchor.constraint( + equalTo: playerViewController.view.trailingAnchor + ) + ]) + playerViewController.didMove(toParent:self) + } + + func hidePlayerViewController() { + playerViewController.willMove(toParent: nil) + playerViewController.view.removeFromSuperview() + playerViewController.removeFromParent() + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + + playerViewController.player?.play() + } + + override func viewWillDisappear(_ animated: Bool) { + playerViewController.player?.pause() + + MUXSDKStats.destroyPlayer( + playerName + ) + + super.viewWillDisappear(animated) + } +} diff --git a/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPMUITests/MUXSDKStatsExampleSPMUITests.swift b/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPMUITests/MUXSDKStatsExampleSPMUITests.swift index 0a33fa37..cc8cf4fc 100644 --- a/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPMUITests/MUXSDKStatsExampleSPMUITests.swift +++ b/apps/MUXSDKStatsExampleSPM/MUXSDKStatsExampleSPMUITests/MUXSDKStatsExampleSPMUITests.swift @@ -90,6 +90,20 @@ final class MUXSDKStatsExampleSPMUITests: XCTestCase { ) } + func testCustomSessionDataExample() throws { + let application = XCUIApplication() + + try launchAndWaitUntilInForeground( + application: application + ) + + try tapCell( + cellIdentifier: "CustomSessionDataExample", + waitFor: "CustomSessionDataExampleView", + application: application + ) + } + func launchAndWaitUntilInForeground( application: XCUIApplication ) throws { diff --git a/scripts/run-tests-cocoapods-ventura.sh b/scripts/run-tests-cocoapods-ventura.sh index 0d6da9bd..f7b22ccc 100755 --- a/scripts/run-tests-cocoapods-ventura.sh +++ b/scripts/run-tests-cocoapods-ventura.sh @@ -47,7 +47,7 @@ xcodebuild -list echo "▸ Available Simulators" xcrun simctl list -echo "▸ Testing SDK on iOS 17.2 - iPhone 14 Pro Max" +echo "▸ Testing Cocoapods Example Application on iOS 17.4 - iPhone 14 Pro Max" xcodebuild clean test \ -workspace $WORKSPACE \ -scheme $SCHEME \ diff --git a/scripts/run-tests-swift-package-manager-ventura.sh b/scripts/run-tests-swift-package-manager-ventura.sh index 46a11ced..2e0d0d71 100755 --- a/scripts/run-tests-swift-package-manager-ventura.sh +++ b/scripts/run-tests-swift-package-manager-ventura.sh @@ -11,6 +11,8 @@ then exit 1 fi +sh scripts/setup-local-hls-server.sh + echo "▸ Current Xcode: $(xcode-select -p)" echo "▸ Using Xcode Version: ${XCODE}" @@ -46,5 +48,5 @@ echo "▸ Testing SDK on iOS 17.2 - iPhone 14 Pro Max" xcodebuild clean test \ -project MUXSDKStatsExampleSPM.xcodeproj \ - -scheme "MUXSDKStatsExampleSPM" \ + -scheme "MUXSDKStatsExampleSPM-CI" \ -destination 'platform=iOS Simulator,OS=17.2,name=iPhone 14 Pro Max' | xcbeautify diff --git a/scripts/setup-local-hls-server.sh b/scripts/setup-local-hls-server.sh new file mode 100755 index 00000000..dccfe18a --- /dev/null +++ b/scripts/setup-local-hls-server.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -euo pipefail + +echo "▸ cloning simple-local-video-test-server repository" + +git clone https://github.com/muxinc/simple-local-video-test-server.git + +cd simple-local-video-test-server + +echo "▸ installing npm package" + +npm i + +echo "▸ starting server" + +npm run start