From 09d69126ebd6d3647c87834cde54121e5cf5cf30 Mon Sep 17 00:00:00 2001 From: Oleksandr Pavliuchyk Date: Wed, 4 Sep 2019 18:56:12 +0300 Subject: [PATCH] scripts were changed and improved regarding new paths --- .gitignore | 2 +- scripts/buildPrebidMobile.sh | 60 +++++++++++++++--------------------- scripts/testPrebidDemo.sh | 11 ++++--- scripts/testPrebidMobile.sh | 17 ++++++---- 4 files changed, 44 insertions(+), 46 deletions(-) diff --git a/.gitignore b/.gitignore index 7336c6641..cb5c53f03 100644 --- a/.gitignore +++ b/.gitignore @@ -52,7 +52,7 @@ Temporary Items # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore ## Build generated -build/ +generated/ DerivedData/ ## Various settings diff --git a/scripts/buildPrebidMobile.sh b/scripts/buildPrebidMobile.sh index 8f4eac015..b916027fe 100755 --- a/scripts/buildPrebidMobile.sh +++ b/scripts/buildPrebidMobile.sh @@ -7,55 +7,45 @@ fi # Set bash script to exit immediately if any commands fail. set -e +cd ../ + # 2 # Setup some constants for use later on. +FRAMEWORK_NAME="PrebidMobile" +GENERATED_FOLDER_NAME="generated" +LOG_DIR="$GENERATED_FOLDER_NAME/log" +LOG_FILE="$LOG_DIR/prebid_mobile_build.log" +LOG_FILE_ABSOLUTE="$PWD/$LOG_FILE" -cd ../src/PrebidMobile/ +XCODE_BUILD_DIR="$GENERATED_FOLDER_NAME/xcodebuild" +XCODE_BUILD_IPHONE_FILE_ABSOLUTE="$PWD/$XCODE_BUILD_DIR/Build/Products/Release-iphoneos/$FRAMEWORK_NAME.framework" -FRAMEWORK_NAME="PrebidMobile" -LOGDIR=../../build/out/log -mkdir -p "$LOGDIR" +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' # No Color # 3 # If remnants from a previous build exist, delete them. -if [ -d "build" ]; then -rm -rf "build" +if [ -d "$GENERATED_FOLDER_NAME" ]; then +rm -rf "$GENERATED_FOLDER_NAME" fi -LOGFILE="$LOGDIR"/prebid_mobile_build.log -touch "$LOGFILE" +mkdir -p "$LOG_DIR" +touch "$LOG_FILE" +echo $PWD +gem install cocoapods --user-install +pod install --repo-update # 4 # Build the framework for device and for simulator (using # all needed architectures). -echo "Building the framework for device" -xcodebuild -target "${FRAMEWORK_NAME}" -configuration Release -arch arm64 only_active_arch=no defines_module=yes -sdk "iphoneos" > "$LOGFILE" 2>&1 || { echo "Error in build check log "$LOGFILE""; exit 1;} - -echo "Building the framework for simulator" -xcodebuild -target "${FRAMEWORK_NAME}" -configuration Release -arch x86_64 only_active_arch=no defines_module=yes -sdk "iphonesimulator" > "$LOGFILE" 2>&1 || { echo "Error in build check log "$LOGFILE""; exit 1;} -# 5 -# Remove .framework file if exists on Desktop from previous run. -if [ -d "${HOME}/Desktop/${FRAMEWORK_NAME}.framework" ]; then -rm -rf "${HOME}/Desktop/${FRAMEWORK_NAME}.framework" -fi +echo -e "${GREEN}-Building the framework for device${NC}" +xcodebuild -workspace PrebidMobile.xcworkspace -scheme "PrebidMobile" -configuration Release -arch arm64 only_active_arch=no defines_module=yes -sdk "iphoneos" -derivedDataPath $XCODE_BUILD_DIR > "$LOG_FILE" 2>&1 || { echo -e "${RED}Error in build check log "$LOG_FILE_ABSOLUTE"${NC}"; exit 1;} -# 6 -# Copy the device version of framework to Desktop. -cp -r "build/Release-iphoneos/${FRAMEWORK_NAME}.framework" "${HOME}/Desktop/${FRAMEWORK_NAME}.framework" +echo -e "${GREEN}-Building the framework for simulator${NC}" +xcodebuild -workspace PrebidMobile.xcworkspace -scheme "PrebidMobile" -configuration Release -arch x86_64 only_active_arch=no defines_module=yes -sdk "iphonesimulator" -derivedDataPath $XCODE_BUILD_DIR > "$LOG_FILE" 2>&1 || { echo -e "${RED}Error in build check log "$LOG_FILE_ABSOLUTE"${NC}"; exit 1;} -# 7 -# Replace the framework executable within the framework with -# a new version created by merging the device and simulator -# frameworks' executables with lipo. -lipo -create -output "${HOME}/Desktop/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" "build/Release-iphoneos/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" "build/Release-iphonesimulator/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" - -echo "Done! You can find the Prebid Mobile framework on your Desktop" -echo "Build logs are also available in the build/out/log/ folder." - -# 8 -# Delete the most recent build. -if [ -d "build" ]; then -rm -rf "build" -fi +echo -e "${GREEN}Done!${NC} \nPrebid Mobile framework for iPhone path is "$XCODE_BUILD_IPHONE_FILE_ABSOLUTE"" +echo "Build logs path is "$LOG_FILE_ABSOLUTE"" diff --git a/scripts/testPrebidDemo.sh b/scripts/testPrebidDemo.sh index 3f69a9ce8..a8a739f20 100755 --- a/scripts/testPrebidDemo.sh +++ b/scripts/testPrebidDemo.sh @@ -2,12 +2,15 @@ if [ -d "scripts" ]; then cd scripts/ fi -echo "Running integration tests" -cd ../example/Swift/PrebidDemo/ + +cd .. echo $PWD -gem install cocoapods --pre + +gem install cocoapods --user-install pod install --repo-update -xcodebuild -workspace PrebidDemo.xcworkspace test -scheme "PrebidDemoTests" -destination 'platform=iOS Simulator,name=iPhone 8 Plus,OS=12.2' | xcpretty -f `xcpretty-travis-formatter` --color --test + +echo "Running integration tests" +xcodebuild test -workspace PrebidMobile.xcworkspace -scheme "PrebidDemoSwiftTests" -destination 'platform=iOS Simulator,name=iPhone 8 Plus,OS=12.2' | xcpretty -f `xcpretty-travis-formatter` --color --test # Make the keychain the default so identities are found security default-keychain -s ios-build.keychain diff --git a/scripts/testPrebidMobile.sh b/scripts/testPrebidMobile.sh index 84d71aea7..c043a3169 100755 --- a/scripts/testPrebidMobile.sh +++ b/scripts/testPrebidMobile.sh @@ -2,13 +2,20 @@ if [ -d "scripts" ]; then cd scripts/ fi -cd ../src/PrebidMobile/ +set -e + +cd .. echo $PWD + +gem install xcpretty --user-install +gem install xcpretty-travis-formatter --user-install + +gem install cocoapods --user-install +pod install --repo-update + echo "Running unit tests" +xcodebuild test -workspace PrebidMobile.xcworkspace -scheme "PrebidMobileTests" -destination 'platform=iOS Simulator,name=iPhone 8 Plus,OS=12.2' | xcpretty -f `xcpretty-travis-formatter` --color --test -gem install xcpretty -gem install xcpretty-travis-formatter -xcodebuild test -project PrebidMobile.xcodeproj -scheme "PrebidMobileTests" -destination 'platform=iOS Simulator,name=iPhone 8 Plus,OS=12.2' | xcpretty -f `xcpretty-travis-formatter` --color --test if [[ ${PIPESTATUS[0]} == 0 ]]; then echo "✅ Unit Tests Passed" else @@ -16,7 +23,5 @@ else exit 1 fi -cd ../src/PrebidMobile/ -echo $PWD echo "Running swiftlint tests" swiftlint --config .swiftlint.yml