diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index b35b8f6..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,164 +0,0 @@ -# For a detailed guide to building and testing on iOS, read the docs: -# https://circleci.com/docs/2.0/testing-ios/ - -version: 2.1 - -orbs: - # codecov: codecov/codecov@3.2.5 - macos: circleci/macos@2 - -# Workflows orchestrate a set of jobs to be run; -workflows: - build-test: - jobs: - - validate-code - - test-ios: - requires: - - validate-code - - test-tvos: - requires: - - validate-code - - build_xcframework_and_app: - requires: - - validate-code - -commands: - install_dependencies: - steps: - # restore pods related caches - - restore_cache: - name: Restoring Gemfile Cache - keys: - - 1-gems-{{ checksum "Gemfile.lock" }} - - # make sure we're on the right version of cocoapods - - run: - name: Verify Cocoapods Version - command: bundle check || bundle install --path vendor/bundle - - # save cocoapods version gem data - - save_cache: - name: Saving Gemfile Cache - key: 1-gems-{{ checksum "Gemfile.lock" }} - paths: - - vendor/bundle - - # restore pods related caches - - restore_cache: - name: Restoring CocoaPods Cache - keys: - - cocoapods-cache-v1-{{ arch }}-{{ .Branch }}-{{ checksum "Podfile.lock" }} - - cocoapods-cache-v1-{{ arch }}-{{ .Branch }} - - cocoapods-cache-v1 - - # install CocoaPods - using default CocoaPods version, not the bundle - - run: - name: Repo Update & Install CocoaPods - command: make ci-pod-install - - # save pods related files - - save_cache: - name: Saving CocoaPods Cache - key: cocoapods-cache-v1-{{ arch }}-{{ .Branch }}-{{ checksum "Podfile.lock" }} - paths: - - ./Pods - - prestart_ios_simulator: - steps: - - macos/preboot-simulator: - platform: "iOS" - version: "17.2" - device: "iPhone 15" - - prestart_tvos_simulator: - steps: - - macos/preboot-simulator: - platform: "tvOS" - version: "17.2" - device: "Apple TV" - -jobs: - - working_directory: ~/project - - validate-code: - macos: - xcode: 15.1.0 # Specify the Xcode version to use - - steps: - - checkout - - - install_dependencies - - - run: - name: Lint Source Code - command: make lint - - test-ios: - macos: - xcode: 15.1.0 # Specify the Xcode version to use - - steps: - - checkout - - - install_dependencies - - # pre-start the simulator to prevent timeouts - - prestart_ios_simulator - - - run: - name: Run iOS Tests - command: make test-ios - - # Code coverage upload using Codecov - # See options explanation here: https://docs.codecov.com/docs/codecov-uploader - # - codecov/upload: - # flags: ios-tests - # upload_name: Coverage Report for iOS Tests - # xtra_args: -c -v --xc --xp iosresults.xcresult - - - test-tvos: - macos: - xcode: 15.1.0 # Specify the Xcode version to use - - steps: - - checkout - - - install_dependencies - - # pre-start the simulator to prevent timeouts - - prestart_tvos_simulator - - - run: - name: Run tvOS Tests - command: make test-tvos - - # Code coverage upload using Codecov - # See options explanation here: https://docs.codecov.com/docs/codecov-uploader - # - codecov/upload: - # flags: tvos-tests - # upload_name: Coverage Report for tvOS Tests - # xtra_args: -c -v --xc --xp tvosresults.xcresult - - build_xcframework_and_app: - macos: - xcode: 15.1.0 # Specify the Xcode version to use - - steps: - - checkout - # verify XCFramework archive builds - - run: - name: Build XCFramework - command: | - if [ "${CIRCLE_BRANCH}" == "main" ]; then - make archive - fi - - # verify test app builds - - run: - name: Build Test App - command: | - if [ "${CIRCLE_BRANCH}" == "main" ]; then - make build-app - fi \ No newline at end of file diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..273af00 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,35 @@ +# +# Copyright 2024 Adobe. All rights reserved. +# This file is licensed to you under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. You may obtain a copy +# of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +# OF ANY KIND, either express or implied. See the License for the specific language +# governing permissions and limitations under the License. +# + +name: Build and Test + +on: + pull_request: + +jobs: + build-and-test: + name: "CI" + uses: adobe/aepsdk-commons/.github/workflows/ios-build-and-test.yml@gha-ios-5.0.0 + with: + ios-device-names: '["iPhone 15"]' + ios-versions: '["18.1"]' + tvos-device-names: '["Apple TV"]' + tvos-versions: '["18.1"]' + run-test-ios-unit: true + run-test-ios-functional: true + run-test-ios-integration: true + run-test-tvos-unit: true + run-test-tvos-functional: true + run-test-tvos-integration: true + run-build-xcframework-and-app: true + enable-codecov: true + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0f07284..88b4e65 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,97 +1,44 @@ +# +# Copyright 2024 Adobe. All rights reserved. +# This file is licensed to you under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. You may obtain a copy +# of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +# OF ANY KIND, either express or implied. See the License for the specific language +# governing permissions and limitations under the License. +# + name: Release on: workflow_dispatch: inputs: tag: - description: 'tag/version' + description: 'The tag (version) to be released (ex: 1.2.3).' + type: string required: true - default: '1.0.0' - action_tag: - description: 'create tag ("no" to skip)' + create-github-release: + description: 'Create a GitHub release with uploaded artifacts. If the provided `tag` does not exist, it will be created.' + type: boolean required: true - default: 'yes' + default: true - release_AEPEdgeMedia: - description: 'release AEPEdgeMedia to Cocoapods ("no" to skip)' + pod-publish-extensions: + description: 'Publish AEPEdgeMedia to Cocoapods.' + type: boolean required: true - default: 'yes' - + default: true jobs: - release_edgemedia: - runs-on: macos-13 - steps: - - uses: actions/checkout@v2 - with: - ref: main - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: '15.0.1' - - - name: Install jq - run: brew install jq - - - name: Install cocoapods - run: gem install cocoapods - - - name: Install xcodegen - run: brew install xcodegen - - - name: Check version in Podspec - run: | - set -eo pipefail - echo Target version: ${{ github.event.inputs.tag }} - make check-version VERSION=${{ github.event.inputs.tag }} - - - name: SPM integration test - if: ${{ github.event.inputs.action_tag == 'yes' }} - run: | - set -eo pipefail - echo SPM integration test starts: - make test-SPM-integration - - - name: podspec file verification - if: ${{ github.event.inputs.action_tag == 'yes' }} - run: | - set -eo pipefail - echo podspec file verification starts: - make test-podspec - - - name: Build Artifacts - if: ${{ github.event.inputs.action_tag == 'yes' }} - run: | - make archive - make zip - - - name: Create GH Release - id: create_release - uses: release-drafter/release-drafter@v5 - if: ${{ github.event.inputs.action_tag == 'yes' }} - with: - name: v${{ github.event.inputs.tag }} - tag: ${{ github.event.inputs.tag }} - version: ${{ github.event.inputs.tag }} - publish: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload - AEPEdgeMedia - uses: actions/upload-release-asset@v1 - if: ${{ github.event.inputs.action_tag == 'yes' }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./build/AEPEdgeMedia.xcframework.zip - asset_name: AEPEdgeMedia-${{ github.event.inputs.tag }}.xcframework.zip - asset_content_type: application/zip - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Publish Pods - AEPEdgeMedia - if: ${{ github.event.inputs.release_AEPEdgeMedia == 'yes' }} - run: | - set -eo pipefail - pod trunk push AEPEdgeMedia.podspec --allow-warnings --synchronous - pod repo update - env: - COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} + release: + permissions: + contents: write + uses: adobe/aepsdk-commons/.github/workflows/ios-release.yml@gha-ios-5.0.0 + with: + tag: ${{ github.event.inputs.tag }} + create-github-release: ${{ github.event.inputs.create-github-release == 'true' && 'AEPEdgeMedia' || '' }} + pod-publish-extensions: ${{ github.event.inputs.pod-publish-extensions == 'true' && 'AEPEdgeMedia' || '' }} + version-validation-paths: AEPEdgeMedia.podspec, AEPEdgeMedia.xcodeproj/project.pbxproj, Sources/MediaConstants.swift + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/update-versions.yml b/.github/workflows/update-versions.yml new file mode 100644 index 0000000..9edacd6 --- /dev/null +++ b/.github/workflows/update-versions.yml @@ -0,0 +1,51 @@ +# +# Copyright 2024 Adobe. All rights reserved. +# This file is licensed to you under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. You may obtain a copy +# of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +# OF ANY KIND, either express or implied. See the License for the specific language +# governing permissions and limitations under the License. +# + +name: Update Versions + +on: + workflow_dispatch: + inputs: + version: + description: 'The new version to use for the extension (ex: 1.2.3).' + type: string + required: true + + branch: + description: 'The target branch where the version update will be applied and the pull request will be merged into.' + type: string + required: true + + core-dependency: + description: 'If a version is provided, update AEPCore dependency in podspec and Package.swift.' + type: string + required: false + default: '' + + edge-dependency: + description: 'If a version is provided, update AEPEdge dependency in podspec and Package.swift.' + type: string + required: false + default: '' + +jobs: + update-versions: + permissions: + contents: write + pull-requests: write + uses: adobe/aepsdk-commons/.github/workflows/versions.yml@gha-ios-5.0.0 + with: + version: ${{ github.event.inputs.version }} + branch: ${{ github.event.inputs.branch }} + dependencies: AEPCore ${{ github.event.inputs.core-dependency }}, AEPEdge ${{ github.event.inputs.edge-dependency }} + paths: Package.swift:swift_spm, AEPEdgeMedia.podspec, AEPEdgeMedia.xcodeproj/project.pbxproj, Sources/MediaConstants.swift + update: true \ No newline at end of file diff --git a/AEPEdgeMedia.xcodeproj/project.pbxproj b/AEPEdgeMedia.xcodeproj/project.pbxproj index 9c1df73..b09e21d 100644 --- a/AEPEdgeMedia.xcodeproj/project.pbxproj +++ b/AEPEdgeMedia.xcodeproj/project.pbxproj @@ -34,7 +34,7 @@ 2E4D75042979E02E00396819 /* XDMDataHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E459867290B8585003111EE /* XDMDataHelper.swift */; }; 2E4D75062979E02E00396819 /* TestUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EA7BC2228C02F79001A7C2A /* TestUtils.swift */; }; 2E4D75072979E02E00396819 /* XDMData+Equatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EA1FB46291DAC9000C4FFFE /* XDMData+Equatable.swift */; }; - 2E4D750E2979E02E00396819 /* FunctionalTestConstant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E224FC42971EA50005FB095 /* FunctionalTestConstant.swift */; }; + 2E4D750E2979E02E00396819 /* IntegrationTestConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E224FC42971EA50005FB095 /* IntegrationTestConstants.swift */; }; 2E4D75162979E02E00396819 /* XDMData+Comparable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EEA08E6291DD51100043C43 /* XDMData+Comparable.swift */; }; 2E4D75172979E02E00396819 /* EdgeEventHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E4D81702936942F005A4543 /* EdgeEventHelper.swift */; }; 2E4D751B2979E02E00396819 /* Media+Edge+EdgeIdentityFunctionalTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E224FC2297108A9005FB095 /* Media+Edge+EdgeIdentityFunctionalTests.swift */; }; @@ -194,7 +194,7 @@ 2E19666828B8236100298FD4 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 2E19666B28B824C300298FD4 /* AssuranceView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssuranceView.swift; sourceTree = ""; }; 2E224FC2297108A9005FB095 /* Media+Edge+EdgeIdentityFunctionalTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Media+Edge+EdgeIdentityFunctionalTests.swift"; sourceTree = ""; }; - 2E224FC42971EA50005FB095 /* FunctionalTestConstant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FunctionalTestConstant.swift; sourceTree = ""; }; + 2E224FC42971EA50005FB095 /* IntegrationTestConstants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IntegrationTestConstants.swift; sourceTree = ""; }; 2E37D33C28CFDD7800B782F8 /* MediaEventProcessor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaEventProcessor.swift; sourceTree = ""; }; 2E37D33E28CFDDF900B782F8 /* MediaSession.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaSession.swift; sourceTree = ""; }; 2E37D34028CFE44400B782F8 /* MediaRealTimeSession.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaRealTimeSession.swift; sourceTree = ""; }; @@ -362,7 +362,7 @@ 2E224FB929710881005FB095 /* Utils */ = { isa = PBXGroup; children = ( - 2E224FC42971EA50005FB095 /* FunctionalTestConstant.swift */, + 2E224FC42971EA50005FB095 /* IntegrationTestConstants.swift */, ); path = Utils; sourceTree = ""; @@ -1207,7 +1207,7 @@ 2E4D75042979E02E00396819 /* XDMDataHelper.swift in Sources */, 2E4D75062979E02E00396819 /* TestUtils.swift in Sources */, 2E4D75072979E02E00396819 /* XDMData+Equatable.swift in Sources */, - 2E4D750E2979E02E00396819 /* FunctionalTestConstant.swift in Sources */, + 2E4D750E2979E02E00396819 /* IntegrationTestConstants.swift in Sources */, 2EF95FF82A05849A00B7D77C /* Media+EdgeLocationHintTests.swift in Sources */, 2E4D75162979E02E00396819 /* XDMData+Comparable.swift in Sources */, 2E4D75172979E02E00396819 /* EdgeEventHelper.swift in Sources */, diff --git a/Gemfile b/Gemfile index 2ab46a2..20cc021 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,3 @@ source 'https://rubygems.org' -gem 'cocoapods', '= 1.14.3' +gem 'cocoapods', '= 1.16.2' diff --git a/Gemfile.lock b/Gemfile.lock index 66d883e..a89506d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,29 +5,32 @@ GEM base64 nkf rexml - activesupport (7.1.3.2) + activesupport (7.2.2) base64 + benchmark (>= 0.3) bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) - addressable (2.8.6) - public_suffix (>= 2.0.2, < 6.0) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) algoliasearch (1.27.5) httpclient (~> 2.8, >= 2.8.3) json (>= 1.5.1) atomos (0.1.3) base64 (0.2.0) - bigdecimal (3.1.7) + benchmark (0.4.0) + bigdecimal (3.1.8) claide (1.1.0) - cocoapods (1.14.3) + cocoapods (1.16.2) addressable (~> 2.8) claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.14.3) + cocoapods-core (= 1.16.2) cocoapods-deintegrate (>= 1.0.3, < 2.0) cocoapods-downloader (>= 2.1, < 3.0) cocoapods-plugins (>= 1.0.0, < 2.0) @@ -41,8 +44,8 @@ GEM molinillo (~> 0.8.0) nap (~> 1.0) ruby-macho (>= 2.3.0, < 3.0) - xcodeproj (>= 1.23.0, < 2.0) - cocoapods-core (1.14.3) + xcodeproj (>= 1.27.0, < 2.0) + cocoapods-core (1.16.2) activesupport (>= 5.0, < 8) addressable (~> 2.8) algoliasearch (~> 1.0) @@ -62,47 +65,68 @@ GEM netrc (~> 0.11) cocoapods-try (1.2.0) colored2 (3.1.2) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.4) connection_pool (2.4.1) drb (2.2.1) escape (0.0.4) ethon (0.16.0) ffi (>= 1.15.0) - ffi (1.16.3) + ffi (1.17.0) + ffi (1.17.0-aarch64-linux-gnu) + ffi (1.17.0-aarch64-linux-musl) + ffi (1.17.0-arm-linux-gnu) + ffi (1.17.0-arm-linux-musl) + ffi (1.17.0-arm64-darwin) + ffi (1.17.0-x86-linux-gnu) + ffi (1.17.0-x86-linux-musl) + ffi (1.17.0-x86_64-darwin) + ffi (1.17.0-x86_64-linux-gnu) + ffi (1.17.0-x86_64-linux-musl) fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) httpclient (2.8.3) - i18n (1.14.4) + i18n (1.14.6) concurrent-ruby (~> 1.0) - json (2.7.1) - minitest (5.22.3) + json (2.8.2) + logger (1.6.1) + minitest (5.25.2) molinillo (0.8.0) - mutex_m (0.2.0) - nanaimo (0.3.0) + nanaimo (0.4.0) nap (1.1.0) netrc (0.11.0) nkf (0.2.0) public_suffix (4.0.7) - rexml (3.2.6) + rexml (3.3.9) ruby-macho (2.5.1) + securerandom (0.3.2) typhoeus (1.4.1) ethon (>= 0.9.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - xcodeproj (1.24.0) + xcodeproj (1.27.0) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) - nanaimo (~> 0.3.0) - rexml (~> 3.2.4) + nanaimo (~> 0.4.0) + rexml (>= 3.3.6, < 4.0) PLATFORMS - arm64-darwin-23 + aarch64-linux-gnu + aarch64-linux-musl + arm-linux-gnu + arm-linux-musl + arm64-darwin + ruby + x86-linux-gnu + x86-linux-musl + x86_64-darwin + x86_64-linux-gnu + x86_64-linux-musl DEPENDENCIES - cocoapods (= 1.14.3) + cocoapods (= 1.16.2) BUNDLED WITH - 2.4.10 + 2.5.23 diff --git a/Makefile b/Makefile index 7e3663a..36064b4 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,48 @@ TVOS_SIMULATOR_ARCHIVE_DSYM_PATH = $(CURR_DIR)/build/tvos_simulator.xcarchive/dS TVOS_ARCHIVE_PATH = $(CURR_DIR)/build/tvos.xcarchive/Products/Library/Frameworks/ TVOS_ARCHIVE_DSYM_PATH = $(CURR_DIR)/build/tvos.xcarchive/dSYMs/ +# Values with defaults +IOS_DEVICE_NAME ?= iPhone 15 +# If OS version is not specified, uses the first device name match in the list of available simulators +IOS_VERSION ?= +ifeq ($(strip $(IOS_VERSION)),) + IOS_DESTINATION = "platform=iOS Simulator,name=$(IOS_DEVICE_NAME)" +else + IOS_DESTINATION = "platform=iOS Simulator,name=$(IOS_DEVICE_NAME),OS=$(IOS_VERSION)" +endif + +TVOS_DEVICE_NAME ?= Apple TV +# If OS version is not specified, uses the first device name match in the list of available simulators +TVOS_VERSION ?= +ifeq ($(strip $(TVOS_VERSION)),) + TVOS_DESTINATION = "platform=tvOS Simulator,name=$(TVOS_DEVICE_NAME)" +else + TVOS_DESTINATION = "platform=tvOS Simulator,name=$(TVOS_DEVICE_NAME),OS=$(TVOS_VERSION)" +endif + +clean-derived-data: + @if [ -z "$(SCHEME)" ]; then \ + echo "Error: SCHEME variable is not set."; \ + exit 1; \ + fi; \ + if [ -z "$(DESTINATION)" ]; then \ + echo "Error: DESTINATION variable is not set."; \ + exit 1; \ + fi; \ + echo "Cleaning derived data for scheme: $(SCHEME) with destination: $(DESTINATION)"; \ + DERIVED_DATA_PATH=`xcodebuild -workspace $(PROJECT_NAME).xcworkspace -scheme "$(SCHEME)" -destination "$(DESTINATION)" -showBuildSettings | grep -m1 'BUILD_DIR' | awk '{print $$3}' | sed 's|/Build/Products||'`; \ + echo "DerivedData Path: $$DERIVED_DATA_PATH"; \ + \ + LOGS_TEST_DIR=$$DERIVED_DATA_PATH/Logs/Test; \ + echo "Logs Test Path: $$LOGS_TEST_DIR"; \ + \ + if [ -d "$$LOGS_TEST_DIR" ]; then \ + echo "Removing existing .xcresult files in $$LOGS_TEST_DIR"; \ + rm -rf "$$LOGS_TEST_DIR"/*.xcresult; \ + else \ + echo "Logs/Test directory does not exist. Skipping cleanup."; \ + fi; + setup: pod install @@ -90,39 +132,49 @@ build-app: setup @echo "######################################################################" xcodebuild clean build -workspace $(PROJECT_NAME).xcworkspace -scheme $(TEST_APP_TVOS_SCHEME) -destination 'generic/platform=tvOS Simulator' -test: test-ios test-tvos +test: unit-test-ios functional-test-ios integration-test-ios unit-test-tvos functional-test-tvos integration-test-tvos -test-ios: +unit-test-ios: @echo "######################################################################" - @echo "### Testing iOS" + @echo "### Unit Testing iOS" @echo "######################################################################" - xcodebuild -workspace $(PROJECT_NAME).xcworkspace -list - final_scheme=""; \ - if xcodebuild -workspace $(PROJECT_NAME).xcworkspace -list | grep -q "($(PROJECT_NAME) project)"; \ - then \ - final_scheme="$(EXTENSION_NAME) ($(PROJECT_NAME) project)" ; \ - echo $$final_scheme ; \ - else \ - final_scheme="$(EXTENSION_NAME)" ; \ - echo $$final_scheme ; \ - fi; \ - xcodebuild test -workspace $(PROJECT_NAME).xcworkspace -scheme "$$final_scheme" -destination 'platform=iOS Simulator,name=iPhone 15' -derivedDataPath build/out -resultBundlePath build/reports/iosresults.xcresult -enableCodeCoverage YES ADB_SKIP_LINT=YES + @$(MAKE) clean-derived-data SCHEME=UnitTests DESTINATION=$(IOS_DESTINATION) + xcodebuild test -workspace $(PROJECT_NAME).xcworkspace -scheme "UnitTests" -destination $(IOS_DESTINATION) -enableCodeCoverage YES ADB_SKIP_LINT=YES -test-tvos: +functional-test-ios: @echo "######################################################################" - @echo "### Testing tvOS" + @echo "### Functional Testing iOS" @echo "######################################################################" - xcodebuild -workspace $(PROJECT_NAME).xcworkspace -list - final_scheme=""; \ - if xcodebuild -workspace $(PROJECT_NAME).xcworkspace -list | grep -q "($(PROJECT_NAME) project)"; \ - then \ - final_scheme="$(EXTENSION_NAME) ($(PROJECT_NAME) project)" ; \ - echo $$final_scheme ; \ - else \ - final_scheme="$(EXTENSION_NAME)" ; \ - echo $$final_scheme ; \ - fi; \ - xcodebuild test -workspace $(PROJECT_NAME).xcworkspace -scheme "$$final_scheme" -destination 'platform=tvOS Simulator,name=Apple TV' -derivedDataPath build/out -resultBundlePath build/reports/tvosresults.xcresult -enableCodeCoverage YES ADB_SKIP_LINT=YES + @$(MAKE) clean-derived-data SCHEME=FunctionalTests DESTINATION=$(IOS_DESTINATION) + xcodebuild test -workspace $(PROJECT_NAME).xcworkspace -scheme "FunctionalTests" -destination $(IOS_DESTINATION) -enableCodeCoverage YES ADB_SKIP_LINT=YES + +integration-test-ios: + @echo "######################################################################" + @echo "### Integration Testing iOS" + @echo "######################################################################" + $(MAKE) clean-derived-data SCHEME=IntegrationTests DESTINATION=$(IOS_DESTINATION) + xcodebuild test -workspace $(PROJECT_NAME).xcworkspace -scheme "IntegrationTests" -destination $(IOS_DESTINATION) -enableCodeCoverage YES ADB_SKIP_LINT=YES + +unit-test-tvos: + @echo "######################################################################" + @echo "### Unit Testing tvOS" + @echo "######################################################################" + @$(MAKE) clean-derived-data SCHEME=UnitTests DESTINATION=$(TVOS_DESTINATION) + xcodebuild test -workspace $(PROJECT_NAME).xcworkspace -scheme "UnitTests" -destination $(TVOS_DESTINATION) -enableCodeCoverage YES ADB_SKIP_LINT=YES + +functional-test-tvos: + @echo "######################################################################" + @echo "### Functional Testing tvOS" + @echo "######################################################################" + @$(MAKE) clean-derived-data SCHEME=FunctionalTests DESTINATION=$(TVOS_DESTINATION) + xcodebuild test -workspace $(PROJECT_NAME).xcworkspace -scheme "FunctionalTests" -destination $(TVOS_DESTINATION) -enableCodeCoverage YES ADB_SKIP_LINT=YES + +integration-test-tvos: + @echo "######################################################################" + @echo "### Integration Testing iOS" + @echo "######################################################################" + $(MAKE) clean-derived-data SCHEME=IntegrationTests DESTINATION=$(TVOS_DESTINATION) + xcodebuild test -workspace $(PROJECT_NAME).xcworkspace -scheme "IntegrationTests" -destination $(TVOS_DESTINATION) -enableCodeCoverage YES ADB_SKIP_LINT=YES install-githook: git config core.hooksPath .githooks @@ -133,10 +185,6 @@ lint-autocorrect: lint: ./Pods/SwiftLint/swiftlint lint Sources TestApps/$(APP_NAME) -# make check-version VERSION=5.0.0 -check-version: - sh ./Script/version.sh $(VERSION) - test-SPM-integration: sh ./Script/test-SPM.sh diff --git a/Podfile b/Podfile index f36ad9e..5118f8a 100644 --- a/Podfile +++ b/Podfile @@ -23,18 +23,18 @@ end target 'UnitTests' do core_pods - pod 'AEPTestUtils', :git => 'https://github.com/adobe/aepsdk-testutils-ios.git', :tag => '5.1.0' + pod 'AEPTestUtils', :git => 'https://github.com/adobe/aepsdk-core-ios.git', :tag => 'testutils-5.2.2' end target 'FunctionalTests' do core_pods - pod 'AEPTestUtils', :git => 'https://github.com/adobe/aepsdk-testutils-ios.git', :tag => '5.1.0' + pod 'AEPTestUtils', :git => 'https://github.com/adobe/aepsdk-core-ios.git', :tag => 'testutils-5.2.2' end target 'IntegrationTests' do core_pods edge_pods - pod 'AEPTestUtils', :git => 'https://github.com/adobe/aepsdk-testutils-ios.git', :tag => '5.1.0' + pod 'AEPTestUtils', :git => 'https://github.com/adobe/aepsdk-core-ios.git', :tag => 'testutils-5.2.2' end target 'TestAppiOS' do diff --git a/Podfile.lock b/Podfile.lock index bd87a29..23c32b8 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -2,19 +2,19 @@ PODS: - AEPAssurance (5.0.1): - AEPCore (< 6.0.0, >= 5.0.0) - AEPServices (< 6.0.0, >= 5.0.0) - - AEPCore (5.2.0): + - AEPCore (5.3.1): - AEPRulesEngine (< 6.0.0, >= 5.0.0) - - AEPServices (< 6.0.0, >= 5.2.0) - - AEPEdge (5.0.2): - - AEPCore (< 6.0.0, >= 5.1.0) + - AEPServices (< 6.0.0, >= 5.3.1) + - AEPEdge (5.0.3): + - AEPCore (< 6.0.0, >= 5.3.1) - AEPEdgeIdentity (< 6.0.0, >= 5.0.0) - AEPEdgeIdentity (5.0.0): - AEPCore (< 6.0.0, >= 5.0.0) - AEPRulesEngine (5.0.0) - - AEPServices (5.2.0) - - AEPTestUtils (5.1.0): - - AEPCore (>= 5.2.0) - - AEPServices (>= 5.2.0) + - AEPServices (5.3.1) + - AEPTestUtils (5.2.2): + - AEPCore (< 6.0.0, >= 5.2.0) + - AEPServices (< 6.0.0, >= 5.2.0) - SwiftLint (0.52.0) DEPENDENCIES: @@ -22,7 +22,7 @@ DEPENDENCIES: - AEPCore - AEPEdge - AEPEdgeIdentity - - AEPTestUtils (from `https://github.com/adobe/aepsdk-testutils-ios.git`, tag `5.1.0`) + - AEPTestUtils (from `https://github.com/adobe/aepsdk-core-ios.git`, tag `testutils-5.2.2`) - SwiftLint (= 0.52.0) SPEC REPOS: @@ -37,24 +37,24 @@ SPEC REPOS: EXTERNAL SOURCES: AEPTestUtils: - :git: https://github.com/adobe/aepsdk-testutils-ios.git - :tag: 5.1.0 + :git: https://github.com/adobe/aepsdk-core-ios.git + :tag: testutils-5.2.2 CHECKOUT OPTIONS: AEPTestUtils: - :git: https://github.com/adobe/aepsdk-testutils-ios.git - :tag: 5.1.0 + :git: https://github.com/adobe/aepsdk-core-ios.git + :tag: testutils-5.2.2 SPEC CHECKSUMS: AEPAssurance: df04baeace42befb0cc213fd6cdfe51651d11ba6 - AEPCore: db53082c207c28166ed6aa9ae6262a55e95c78aa - AEPEdge: edf73ae8900016940cd7fcb29a89a576a1c6b0ae + AEPCore: 28191f2df03225a5e88b6f8f343f7e18a604c9ef + AEPEdge: 105afc7958acd7c016d57f7ac1d6f632bf05e6ee AEPEdgeIdentity: 3161ff33434586962946912d6b8e9e8fca1c4d23 AEPRulesEngine: fe5800653a4bee07b1e41e61b4d5551f0dba557b - AEPServices: d959143d13fde7e8464c19527df6baacdef765ce - AEPTestUtils: b2c941b4f72deaff090e3e82b8c1ac31fedc1c84 + AEPServices: fcba979e90f6916b066aa66f016700d7b7534d96 + AEPTestUtils: 61de2086056f4aa3223dc7d035991ef4fdacbfdb SwiftLint: 13280e21cdda6786ad908dc6e416afe5acd1fcb7 -PODFILE CHECKSUM: 8fdd70d88335ab104239acaf3ffe5caae0ba0787 +PODFILE CHECKSUM: 2810837384d7bf354cc5ddeea4a7f7d71a5aa045 -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/Script/version.sh b/Script/version.sh deleted file mode 100755 index 70ee70d..0000000 --- a/Script/version.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright 2022 Adobe. All rights reserved. -# This file is licensed to you under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. You may obtain a copy -# of the License at http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under -# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS -# OF ANY KIND, either express or implied. See the License for the specific language -# governing permissions and limitations under the License. - -set -e - -if which jq >/dev/null; then - echo "jq is installed" -else - echo "error: jq not installed.(brew install jq)" -fi - -NC='\033[0m' -RED='\033[0;31m' -GREEN='\033[0;32m' -BLUE='\033[0;34m' - -echo "Target version - ${BLUE}$1${NC}" -echo "------------------AEPEdgeMedia-------------------" -PODSPEC_VERSION=$(pod ipc spec AEPEdgeMedia.podspec | jq '.version' | tr -d '"') -echo "Local podspec version - ${BLUE}${PODSPEC_VERSION}${NC}" -SOURCE_CODE_VERSION=$(cat ./Sources/MediaConstants.swift | egrep '\s*EXTENSION_VERSION\s*=\s*\"(.*)\"' | ruby -e "puts gets.scan(/\"(.*)\"/)[0] " | tr -d '"') -echo "Souce code version - ${BLUE}${SOURCE_CODE_VERSION}${NC}" - -if [[ "$1" == "$PODSPEC_VERSION" ]] && [[ "$1" == "$SOURCE_CODE_VERSION" ]]; then - echo "${GREEN}Pass!${NC}" -else - echo "${RED}[Error]${NC} Version do not match!" - exit -1 -fi -exit 0 diff --git a/Tests/IntegrationTests/Media+Edge+EdgeIdentityFunctionalTests.swift b/Tests/IntegrationTests/Media+Edge+EdgeIdentityFunctionalTests.swift index 541d38e..ca6b299 100644 --- a/Tests/IntegrationTests/Media+Edge+EdgeIdentityFunctionalTests.swift +++ b/Tests/IntegrationTests/Media+Edge+EdgeIdentityFunctionalTests.swift @@ -20,6 +20,7 @@ import Foundation import XCTest class EdgeMediaIntegrationTests: TestBase, AnyCodableAsserts { + private let TIMEOUT_SEC: TimeInterval = IntegrationTestConstants.Defaults.TIMEOUT_SEC private let mockNetworkService = MockNetworkService() private let sessionStartEdgeEndpoint = "https://edge.adobedc.net/ee/va/v1/sessionStart" @@ -49,11 +50,12 @@ class EdgeMediaIntegrationTests: TestBase, AnyCodableAsserts { public class override func setUp() { super.setUp() - TestBase.debugEnabled = true } override func setUp() { + loggingEnabled = true super.setUp() + ServiceProvider.shared.networkService = mockNetworkService continueAfterFailure = false @@ -70,7 +72,7 @@ class EdgeMediaIntegrationTests: TestBase, AnyCodableAsserts { print("Extensions registration is complete") waitForRegistration.countDown() }) - XCTAssertEqual(DispatchTimeoutResult.success, waitForRegistration.await(timeout: 2)) + XCTAssertEqual(DispatchTimeoutResult.success, waitForRegistration.await(timeout: TIMEOUT_SEC)) MobileCore.updateConfigurationWith(configDict: configuration) @@ -108,7 +110,7 @@ class EdgeMediaIntegrationTests: TestBase, AnyCodableAsserts { tracker.trackComplete() // verify - mockNetworkService.assertAllNetworkRequestExpectations(ignoreUnexpectedRequests: false) + mockNetworkService.assertAllNetworkRequestExpectations(ignoreUnexpectedRequests: false, timeout: TIMEOUT_SEC) let networkRequests = mockNetworkService.getNetworkRequests() assertXDMData(networkRequest: networkRequests[0], eventType: "sessionStart", info: mediaInfo, metadata: metadata, configuration: configuration) @@ -138,7 +140,7 @@ class EdgeMediaIntegrationTests: TestBase, AnyCodableAsserts { tracker.trackComplete() // verify - mockNetworkService.assertAllNetworkRequestExpectations(ignoreUnexpectedRequests: false) + mockNetworkService.assertAllNetworkRequestExpectations(ignoreUnexpectedRequests: false, timeout: TIMEOUT_SEC) let networkRequests = mockNetworkService.getNetworkRequests() assertXDMData(networkRequest: networkRequests[0], eventType: "sessionStart", info: mediaInfo, metadata: metadata, configuration: configuration) @@ -168,7 +170,7 @@ class EdgeMediaIntegrationTests: TestBase, AnyCodableAsserts { tracker.trackComplete() // verify - mockNetworkService.assertAllNetworkRequestExpectations(ignoreUnexpectedRequests: false) + mockNetworkService.assertAllNetworkRequestExpectations(ignoreUnexpectedRequests: false, timeout: TIMEOUT_SEC) let networkRequests = mockNetworkService.getNetworkRequests() assertXDMData(networkRequest: networkRequests[0], eventType: "sessionStart", info: mediaInfo, metadata: metadata, configuration: configuration) @@ -202,7 +204,7 @@ class EdgeMediaIntegrationTests: TestBase, AnyCodableAsserts { tracker.trackComplete() // verify - mockNetworkService.assertAllNetworkRequestExpectations(ignoreUnexpectedRequests: false) + mockNetworkService.assertAllNetworkRequestExpectations(ignoreUnexpectedRequests: false, timeout: TIMEOUT_SEC) let networkRequests = mockNetworkService.getNetworkRequests() assertXDMData(networkRequest: networkRequests[0], eventType: "sessionStart", info: mediaInfo, metadata: metadata, configuration: configuration) @@ -242,7 +244,7 @@ class EdgeMediaIntegrationTests: TestBase, AnyCodableAsserts { tracker.trackComplete() // verify - mockNetworkService.assertAllNetworkRequestExpectations(ignoreUnexpectedRequests: false) + mockNetworkService.assertAllNetworkRequestExpectations(ignoreUnexpectedRequests: false, timeout: TIMEOUT_SEC) let networkRequests = mockNetworkService.getNetworkRequests() assertXDMData(networkRequest: networkRequests[0], eventType: "sessionStart", info: mediaInfo, metadata: metadata, configuration: configuration) @@ -278,7 +280,7 @@ class EdgeMediaIntegrationTests: TestBase, AnyCodableAsserts { tracker.trackSessionEnd() // verify - mockNetworkService.assertAllNetworkRequestExpectations(ignoreUnexpectedRequests: false) + mockNetworkService.assertAllNetworkRequestExpectations(ignoreUnexpectedRequests: false, timeout: TIMEOUT_SEC) let networkRequests = mockNetworkService.getNetworkRequests() assertXDMData(networkRequest: networkRequests[0], eventType: "sessionStart", info: mediaInfo, metadata: metadata, configuration: configuration) @@ -311,7 +313,7 @@ class EdgeMediaIntegrationTests: TestBase, AnyCodableAsserts { tracker.trackSessionEnd() // verify - mockNetworkService.assertAllNetworkRequestExpectations(ignoreUnexpectedRequests: false) + mockNetworkService.assertAllNetworkRequestExpectations(ignoreUnexpectedRequests: false, timeout: TIMEOUT_SEC) let networkRequests = mockNetworkService.getNetworkRequests() assertXDMData(networkRequest: networkRequests[0], eventType: "sessionStart", info: mediaInfo, metadata: metadata, configuration: configuration) @@ -347,7 +349,7 @@ class EdgeMediaIntegrationTests: TestBase, AnyCodableAsserts { tracker.trackComplete() // verify - mockNetworkService.assertAllNetworkRequestExpectations(ignoreUnexpectedRequests: false) + mockNetworkService.assertAllNetworkRequestExpectations(ignoreUnexpectedRequests: false, timeout: TIMEOUT_SEC) let networkRequests = mockNetworkService.getNetworkRequests() assertXDMData(networkRequest: networkRequests[0], eventType: "sessionStart", info: mediaInfo, metadata: metadata, configuration: configuration) @@ -385,7 +387,7 @@ class EdgeMediaIntegrationTests: TestBase, AnyCodableAsserts { tracker.trackSessionEnd() // verify - mockNetworkService.assertAllNetworkRequestExpectations(ignoreUnexpectedRequests: false) + mockNetworkService.assertAllNetworkRequestExpectations(ignoreUnexpectedRequests: false, timeout: TIMEOUT_SEC) let networkRequests = mockNetworkService.getNetworkRequests() assertXDMData(networkRequest: networkRequests[0], eventType: "sessionStart", info: mediaInfo, metadata: metadata, configuration: configuration) diff --git a/Tests/IntegrationTests/Media+EdgeLocationHintTests.swift b/Tests/IntegrationTests/Media+EdgeLocationHintTests.swift index bbaa338..d00bbe5 100644 --- a/Tests/IntegrationTests/Media+EdgeLocationHintTests.swift +++ b/Tests/IntegrationTests/Media+EdgeLocationHintTests.swift @@ -20,6 +20,7 @@ import Foundation import XCTest class EdgeMediaLocationHintIntegrationTests: TestBase { + private let TIMEOUT_SEC: TimeInterval = IntegrationTestConstants.Defaults.TIMEOUT_SEC private let mockNetworkService = MockNetworkService() private let configuration = ["edge.configId": "12345-example", "edgeMedia.channel": "testChannel", @@ -34,10 +35,10 @@ class EdgeMediaLocationHintIntegrationTests: TestBase { public class override func setUp() { super.setUp() - TestBase.debugEnabled = true } override func setUp() { + loggingEnabled = true super.setUp() ServiceProvider.shared.networkService = mockNetworkService continueAfterFailure = false @@ -55,7 +56,7 @@ class EdgeMediaLocationHintIntegrationTests: TestBase { print("Extensions registration is complete") waitForRegistration.countDown() }) - XCTAssertEqual(DispatchTimeoutResult.success, waitForRegistration.await(timeout: 2)) + XCTAssertEqual(DispatchTimeoutResult.success, waitForRegistration.await(timeout: TIMEOUT_SEC)) MobileCore.updateConfigurationWith(configDict: configuration) @@ -94,7 +95,7 @@ class EdgeMediaLocationHintIntegrationTests: TestBase { tracker.trackComplete() // verify - mockNetworkService.assertAllNetworkRequestExpectations() + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) let networkRequests = mockNetworkService.getNetworkRequests() XCTAssertEqual(4, networkRequests.count) XCTAssertTrue(networkRequests[0].url.absoluteString.contains("https://edge.adobedc.net/ee/\(testLocationHint)/va/v1/sessionStart")) @@ -127,7 +128,7 @@ class EdgeMediaLocationHintIntegrationTests: TestBase { tracker.trackComplete() // verify - mockNetworkService.assertAllNetworkRequestExpectations() + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) let networkRequests = mockNetworkService.getNetworkRequests() XCTAssertEqual(4, networkRequests.count) XCTAssertTrue(networkRequests[0].url.absoluteString.contains("https://edge.adobedc.net/ee/va/v1/sessionStart")) diff --git a/Tests/IntegrationTests/Utils/FunctionalTestConstant.swift b/Tests/IntegrationTests/Utils/IntegrationTestConstants.swift similarity index 92% rename from Tests/IntegrationTests/Utils/FunctionalTestConstant.swift rename to Tests/IntegrationTests/Utils/IntegrationTestConstants.swift index a7125bf..5292a4d 100644 --- a/Tests/IntegrationTests/Utils/FunctionalTestConstant.swift +++ b/Tests/IntegrationTests/Utils/IntegrationTestConstants.swift @@ -12,7 +12,7 @@ import Foundation -enum FunctionalTestConstant { +enum IntegrationTestConstants { enum EventType { static let EDGE = "com.adobe.eventType.edge" @@ -42,9 +42,10 @@ enum FunctionalTestConstant { } enum Defaults { + // Default timeout for assertions. Set to a high value to accommodate slower CI runners. + static let TIMEOUT_SEC: TimeInterval = 15 static let WAIT_EVENT_TIMEOUT: TimeInterval = 2 static let WAIT_SHARED_STATE_TIMEOUT: TimeInterval = 3 static let WAIT_NETWORK_REQUEST_TIMEOUT: TimeInterval = 2 - static let WAIT_TIMEOUT: UInt32 = 3 // used when no expectation is set } } diff --git a/Tests/UnitTests/Media+PublicAPITests.swift b/Tests/UnitTests/Media+PublicAPITests.swift index 58b6249..d6e3325 100644 --- a/Tests/UnitTests/Media+PublicAPITests.swift +++ b/Tests/UnitTests/Media+PublicAPITests.swift @@ -19,7 +19,7 @@ import XCTest class MediaPublicAPITests: XCTestCase, AnyCodableAsserts { override func setUp() { - EventHub.reset() + MobileCore.resetSDK() MockExtension.reset() EventHub.shared.start() registerMockExtension(MockExtension.self)