Skip to content

Commit

Permalink
Move part of the script to pr-validation.yml
Browse files Browse the repository at this point in the history
wip
  • Loading branch information
diegojerezba committed Jun 13, 2024
1 parent 70950fe commit 71bc558
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 51 deletions.
37 changes: 34 additions & 3 deletions azure_pipelines/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,43 @@ jobs:
path: s

- script: |
/bin/bash -c "sudo xcode-select -s /Applications/Xcode_15.0.1.app"
displayName: 'Switch to use Xcode 15.0.1'
/bin/bash -c "sudo xcode-select -s /Applications/Xcode_14.3.app"
displayName: 'Switch to use Xcode 14.3'
- task: Bash@3
displayName: Set variable BRANCH_NAME to a temporary branch
inputs:
targetType: 'inline'
script: |
UUID_LOCAL=$(uuidgen)
BRANCH_NAME_LOCAL="$(Build.SourceBranchName)-temp-${UUID_LOCAL}"
echo "##vso[task.setvariable variable=BRANCH_NAME]${BRANCH_NAME_LOCAL}"
- task: Bash@3
displayName: Checkout to temporary branch
inputs:
targetType: 'inline'
script: |
git checkout -b "${BRANCH_NAME}"
- task: Bash@3
displayName: Run SPM integration test script
inputs:
targetType: 'inline'
script: |
sh spm-integration-test.sh "${BRANCH_NAME}"
continueOnError: true

- task: Bash@3
displayName: Cleanup
inputs:
targetType: 'inline'
script:
sh spm-integration-test.sh "$(Build.SourceBranchName)"
cd ../..
rm -rf "$SAMPLE_APP_TEMP_DIR" archive framework MSAL.zip
git checkout -- .
git fetch --quiet
git switch "$(Build.SourceBranchName)"
git branch -D "$BRANCH_NAME"
git push origin --delete "$BRANCH_NAME"

65 changes: 17 additions & 48 deletions spm-integration-test.sh
Original file line number Diff line number Diff line change
@@ -1,62 +1,47 @@
UUID=$(uuidgen)
BRANCH_NAME="$1-temp-${UUID}"
BRANCH_NAME="$1"
SAMPLE_APP_TEMP_DIR="NativeAuthSampleAppTemp"
current_date=$(date +"%Y-%m-%d %H:%M:%S")

set -e

# Build framework

git checkout -b "$BRANCH_NAME"
rm -rf archive framework MSAL.zip
echo "Building framework"

xcodebuild -sdk iphonesimulator -configuration Release -workspace MSAL.xcworkspace -scheme "MSAL (iOS Framework)" archive SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES -archivePath archive/iOSSimulator CODE_SIGNING_ALLOWED=NO -quiet > build.log 2>&1
XCBUILD_STATUS_SIM=$?
if [ $XCBUILD_STATUS_SIM -ne 0 ]; then
echo "** Build xcframework Error **"
exit 1
fi

xcodebuild -sdk iphoneos -configuration Release -workspace MSAL.xcworkspace -scheme "MSAL (iOS Framework)" archive SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES -archivePath archive/iOS CODE_SIGNING_ALLOWED=NO -quiet > build.log 2>&1
XCBUILD_STATUS_IPHONE=$?
if [ $XCBUILD_STATUS_IPHONE -ne 0 ]; then
echo "** Build xcframework Error **"
exit 1
fi

xcodebuild -sdk macosx -configuration Release -workspace MSAL.xcworkspace -scheme "MSAL (Mac Framework)" archive SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES -archivePath archive/macOS CODE_SIGNING_ALLOWED=NO -quiet > build.log 2>&1
XCBUILD_STATUS_MAC=$?
if [ $XCBUILD_STATUS_MAC -ne 0 ]; then
echo "** Build xcframework Error **"
exit 1
fi

xcodebuild -create-xcframework -framework archive/iOSSimulator.xcarchive/Products/Library/Frameworks/MSAL.framework -framework archive/iOS.xcarchive/Products/Library/Frameworks/MSAL.framework -framework archive/macOS.xcarchive/Products/Library/Frameworks/MSAL.framework -output framework/MSAL.xcframework > build.log 2>&1
XCBUILD_STATUS_FRAMEWORK=$?
if [ $XCBUILD_STATUS_FRAMEWORK -ne 0 ]; then
echo "** Build xcframework Error **"
exit 1
fi

echo "Creating MSAL.zip"
zip -r MSAL.zip framework/MSAL.xcframework -y -v

echo "Calculating checksum"
CHECKSUM=$(swift package compute-checksum MSAL.zip)
if [ -z "$CHECKSUM" ]; then
echo "** Checksum could not be obtained **"
exit 1
fi

NEW_URL="https://github.com/AzureAD/microsoft-authentication-library-for-objc/raw/$BRANCH_NAME/MSAL.zip/"
echo "Updating Package.swift"

NEW_URL="https://github.com/AzureAD/microsoft-authentication-library-for-objc/raw/$BRANCH_NAME/MSAL.zip"

sed -i '' "s#url: \"[^\"]*\"#url: \"$NEW_URL\"#" Package.swift
sed -i '' "s#checksum: \"[^\"]*\"#checksum: \"$CHECKSUM\"#" Package.swift

echo "Pushing MSAL.zip and Package.swift to $BRANCH_NAME"

git add MSAL.zip Package.swift

git commit -m "Publish temporary Swift Package $current_date"
git push -f origin "$BRANCH_NAME"

echo "MSAL.zip pushed to temporary branch: $BRANCH_NAME"

# Download Sample App

echo "Downloading and updating Sample App to use temporary Swift Package"

mkdir -p "$SAMPLE_APP_TEMP_DIR"
cd "$SAMPLE_APP_TEMP_DIR"

Expand All @@ -68,23 +53,7 @@ sed -i '' "s#minimumVersion = [0-9.]*;#branch = $BRANCH_NAME;#" NativeAuthSample

rm -f NativeAuthSampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

xcodebuild -resolvePackageDependencies
xcodebuild -scheme NativeAuthSampleApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14,OS=latest' clean build
BUILD_STATUS=$?
echo "Running the Sample App with the temporary Swift Package"

# Cleanup

cd ../..
rm -rf "$SAMPLE_APP_TEMP_DIR" archive framework MSAL.zip

git checkout -- .
git fetch --quiet
git switch "$1"

git branch -D "$BRANCH_NAME"
git push origin --delete "$BRANCH_NAME"

if [ $BUILD_STATUS -ne 0 ]; then
echo "** Sample App build error **"
exit 1
fi
xcodebuild -resolvePackageDependencies
xcodebuild -scheme NativeAuthSampleApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14,OS=16.4' clean build

0 comments on commit 71bc558

Please sign in to comment.