-
Notifications
You must be signed in to change notification settings - Fork 242
GPTDriver Test Suite Automation Scripts #1539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
NidhiDixit09
wants to merge
35
commits into
master
Choose a base branch
from
Release-1.1.1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
cc9b5e1
Script for executing the GPTDriver Tests
NidhiDixit09 174bbd6
Updated Name
NidhiDixit09 8bbf823
Update gpt-driver-tests.yml
NidhiDixit09 ffe4f94
Initial Commit for merging into master.
NidhiDixit09 26fba62
Update gpt-driver-tests.yml
NidhiDixit09 4689ea3
Update gpt-driver-tests.yml
NidhiDixit09 a02244f
Update gpt-driver-tests.yml
NidhiDixit09 8c2d793
Update gpt-driver-tests.yml
NidhiDixit09 0ab2f4e
Update gpt-driver-tests.yml
NidhiDixit09 16f9d38
Update gpt-driver-tests.yml
NidhiDixit09 7404854
Update gpt-driver-tests.yml
NidhiDixit09 1f0e268
Update gpt-driver-tests.yml
NidhiDixit09 5bfc4f7
Update gpt-driver-tests.yml
NidhiDixit09 1c731e1
Update gpt-driver-tests.yml
NidhiDixit09 1d70cb6
Update gpt-driver-tests.yml
NidhiDixit09 76aa7e5
Update gpt-driver-tests.yml
NidhiDixit09 eaf5a61
Update gpt-driver-tests.yml
NidhiDixit09 6b0fc76
Update gpt-driver-tests.yml
NidhiDixit09 79716b9
Update gpt-driver-tests.yml
NidhiDixit09 1b488f7
Update gpt-driver-tests.yml
NidhiDixit09 6b12986
Update gpt-driver-tests.yml
NidhiDixit09 d513183
Update gpt-driver-tests.yml
NidhiDixit09 cfbc43f
Update gpt-driver-tests.yml
NidhiDixit09 6e789bd
Update gpt-driver-tests.yml
NidhiDixit09 4214ca0
Update gpt-driver-tests.yml
NidhiDixit09 a57d2ed
Update gpt-driver-tests.yml
NidhiDixit09 7bab60f
Update gpt-driver-tests.yml
NidhiDixit09 b97e8a2
Update gpt-driver-tests.yml
NidhiDixit09 ac46893
Update gpt-driver-tests.yml
NidhiDixit09 2eabc59
Added GPT Driver TestRun shell script
NidhiDixit09 2beed6a
Update gpt-driver-tests.yml
NidhiDixit09 411b063
Update gpt-driver-tests.yml
NidhiDixit09 6f0aa17
Update gpt-driver-tests.yml
NidhiDixit09 afed731
Update gpt-driver-tests.yml
NidhiDixit09 9544002
Update gpt-driver-tests.yml
NidhiDixit09 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -eo pipefail | ||
|
|
||
| # Constants should ideally be set as environment variables for security | ||
| readonly API_URL="https://api.mobileboost.io" | ||
| readonly API_ORG_KEY="${API_ORG_KEY}" | ||
| readonly API_TOKEN="${API_TOKEN:-null}" | ||
| readonly TEST_TIMEOUT="${TEST_TIMEOUT:-7200}" | ||
| readonly TEST_TAGS="${TEST_TAGS:-}" | ||
|
|
||
| # Function to post data using curl and handle errors | ||
| post_data() { | ||
| local url=$1 | ||
| local body=$2 | ||
| if ! response=$(curl -s -f -X POST -H "Authorization: Bearer $API_TOKEN" -H "Content-Type: application/json" -d "$body" "$url"); then | ||
| echo "Error: Network request failed with error $response" >&2 | ||
| exit 1 | ||
| fi | ||
| echo "$response" | ||
| } | ||
|
|
||
| # Validate inputs | ||
| if [[ -z "$1" || -z "$2" ]]; then | ||
| echo "Usage: $0 <build_filename> <build_platform>" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Validate environment variables | ||
| if [[ -z "$API_ORG_KEY" ]]; then | ||
| echo "Please set API_ORG_KEY to your organization key" | ||
| exit 1 | ||
| fi | ||
|
|
||
| buildFilename="$1" | ||
| buildPlatform="$2" | ||
| tags=() | ||
|
|
||
| # Check if TEST_TAGS is provided and split into an array | ||
| if [[ -n "$TEST_TAGS" ]]; then | ||
| IFS=',' read -ra tags <<< "$TEST_TAGS" | ||
| fi | ||
|
|
||
| # Upload build file | ||
| echo -n "Uploading build from $buildFilename for $buildPlatform: " | ||
| if ! uploadedBuildResponse=$(curl -s -f -X POST \ | ||
| -H "Authorization: Bearer $API_TOKEN" \ | ||
| -H "Content-Type: multipart/form-data" \ | ||
| -F "build=@$buildFilename" \ | ||
| -F "organisation_key=$API_ORG_KEY" \ | ||
| -F "platform=$buildPlatform" \ | ||
| -F "metadata={}" \ | ||
| "$API_URL/uploadBuild/"); then | ||
| echo "Error: Failed to upload build" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Extract the buildId | ||
| if ! buildId=$(jq -r '.buildId' <<< "$uploadedBuildResponse") || [ -z "$buildId" ]; then | ||
| echo "Error: Failed to extract build ID from the response" >&2 | ||
| exit 1 | ||
| fi | ||
| echo "uploaded (ID: $buildId), app link: $(jq -r '.app_link' <<< "$uploadedBuildResponse")" | ||
|
|
||
| # Execute test suite | ||
| echo "Executing test suite..." | ||
| jsonPayload="{\"organisationId\": \"$API_ORG_KEY\", \"uploadId\": \"$buildId\"" | ||
| if [ ${#tags[@]} -gt 0 ]; then | ||
| jsonTags=$(printf ',\"%s\"' "${tags[@]}") | ||
| jsonTags="[${jsonTags:1}]" | ||
| jsonPayload+=", \"tags\": $jsonTags" | ||
| fi | ||
| jsonPayload+="}" | ||
| if ! testSuiteRunId=$(post_data "$API_URL/tests/execute" "$jsonPayload" | jq -r '.test_suite_ids[0]') || [ -z "$testSuiteRunId" ]; then | ||
| echo "Error: Test suite execution failed" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Wait for test suite to finish | ||
| echo -n "Waiting for test suite to finish..." | ||
| startTime=$(date +%s) | ||
| while true; do | ||
| if ! testSuiteData=$(curl -s -f "$API_URL/testSuiteRuns/$testSuiteRunId/gh"); then | ||
| echo "Error: Failed to retrieve test suite data" >&2 | ||
| exit 1 | ||
| fi | ||
| testSuiteStatus=$(jq -r '.status' <<< "$testSuiteData") | ||
|
|
||
| if [[ | ||
| "$testSuiteStatus" == "completed" | ||
| ]]; then | ||
| echo "Status is $testSuiteStatus!" >&2 | ||
| break | ||
| fi | ||
|
|
||
| if (( $(date +%s) - startTime >= TEST_TIMEOUT )); then | ||
| echo "Timeout exceeded while waiting for test suite to finish." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo -n "." | ||
| sleep 1 | ||
| done | ||
| echo " done!" | ||
|
|
||
| # Write test suite summary to file if available | ||
| if [[ -n "$GITHUB_STEP_SUMMARY" && -w "$GITHUB_STEP_SUMMARY" ]]; then | ||
| jq -r '.markdown' <<< "$testSuiteData" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "Step summary written to $GITHUB_STEP_SUMMARY" | ||
| fi | ||
|
|
||
| # Check test suite result | ||
| if ! testSuiteResult=$(jq -r '.result' <<< "$testSuiteData"); then | ||
| echo "Test suite did not pass, result: $testSuiteResult" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "$testSuiteResult" == "succeeded" ]]; then | ||
| echo "Test passed successfully" | ||
| exit 0 | ||
| else | ||
| echo "Test suite did not pass, result: $testSuiteResult" >&2 | ||
| exit 1 | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| name: GPTDriver Test Suite Automation | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| push: | ||
| branches: | ||
| - 'Release-*' # Trigger for branches starting with "Release-" | ||
|
|
||
| jobs: | ||
| BuildAndTestAppOnGPTDriver: | ||
| runs-on: macos-latest | ||
| steps: | ||
| # --- Step 1: Extract version from branch name --- | ||
| - name: Extract version from branch name | ||
| id: extract_version_step | ||
| run: | | ||
| BRANCH_NAME="${{ github.ref }}" | ||
| # Remove 'refs/heads/' prefix (e.g., refs/heads/Release-0.0.0 -> Release-0.0.0) | ||
| BRANCH_NAME_WITHOUT_PREFIX="${BRANCH_NAME#refs/heads/}" | ||
| # Extract version after "Release-" (e.g., Release-0.0.0 -> 0.0.0) | ||
| VERSION=$(echo "$BRANCH_NAME_WITHOUT_PREFIX" | sed -n 's/^Release-\([0-9]*\.[0-9]*\.[0-9]*\)$/\1/p') | ||
|
|
||
| if [ -z "$VERSION" ]; then | ||
| echo "Error: Could not extract version from branch name '$BRANCH_NAME_WITHOUT_PREFIX'. Expected format: Release-X.Y.Z" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Extracted versionName: $VERSION" | ||
| echo "VERSION_STRING=$VERSION" >> $GITHUB_ENV | ||
|
|
||
| # Convert semantic version to an integer for CFBundleVersion (versionCode equivalent) | ||
| # Example: 1.2.3 -> 102003 (assuming max 2 digits for minor/patch) | ||
| # This should be adjusted based on the maximum expected values for major/minor/patch | ||
| MAJOR=$(echo "$VERSION" | cut -d. -f1) | ||
| MINOR=$(echo "$VERSION" | cut -d. -f2) | ||
| PATCH=$(echo "$VERSION" | cut -d. -f3) | ||
|
|
||
| # Calculate versionCode (CFBundleVersion) - ensure this fits in a 32-bit integer | ||
| # Standard Android-like conversion: Major * 10000 + Minor * 100 + Patch | ||
| # This provides sufficient uniqueness for most common versioning schemes. | ||
| VERSION_CODE_INT=$(( MAJOR * 10000 + MINOR * 100 + PATCH )) | ||
| echo "Calculated versionCode: $VERSION_CODE_INT" | ||
| echo "VERSION_CODE_INT=$VERSION_CODE_INT" >> $GITHUB_ENV | ||
|
|
||
|
|
||
| # --- Step 2: Checkout the iOS Branch SDK repository --- | ||
| - name: Checkout BranchMetrics/ios-branch-deep-linking-attribution (SDK) | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| repository: BranchMetrics/ios-branch-deep-linking-attribution | ||
| ref: ${{ github.ref }} # Use the same branch that triggered the workflow | ||
| path: ./branch-ios-sdk-repo # Checkout into a subdirectory | ||
|
|
||
| # --- Step 3: Build the iOS Branch SDK Framework --- | ||
| - name: Build Branch SDK Framework | ||
| run: | | ||
| # Build for simulator. Adjust scheme if necessary. | ||
| # The output framework will be in build/Debug-iphonesimulator/BranchSDK.framework | ||
| xcodebuild -scheme xcframework \ | ||
| BUILD_DIR="${{ github.workspace }}/branch-ios-sdk-repo/build" | ||
| working-directory: ./branch-ios-sdk-repo | ||
|
|
||
| # --- Step 4: Checkout the iOS Branch Link Simulator App repository --- | ||
| - name: Checkout BranchMetrics/BranchLinkSimulator (App) | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| repository: BranchMetrics/BranchLinkSimulator | ||
| ref: gptdriver/linkingTests # Checkout the specific app branch | ||
| path: ./ios-app-repo # Checkout into another subdirectory | ||
|
|
||
| # --- Step 5: Copy the generated SDK Framework to the App's project --- | ||
| - name: Copy generated SDK Framework to App's libs directory | ||
| run: | | ||
| # Create a 'Frameworks' directory within the app repo for the local SDK | ||
| mkdir -p ./ios-app-repo/Frameworks | ||
| # Copy the built framework | ||
| cp -R ./branch-ios-sdk-repo/build/BranchSDK.xcframework ./ios-app-repo/Frameworks/ | ||
| working-directory: ${{ github.workspace }} # Run from the root of the GITHUB_WORKSPACE | ||
|
|
||
| # --- Step 6: Install Code Sign Certificate and Provisioning profile | ||
| - name: Install the Apple certificate and provisioning profile | ||
| env: | ||
| BUILD_CERTIFICATE_BASE64: ${{ secrets.BS_BUILD_CERTIFICATE }} | ||
| P12_PASSWORD: ${{ secrets.BS_P12_PASSWORD }} | ||
| BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BS_BUILD_PROVISION_PROFILE_BASE64_PART_AA }} | ||
| KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} | ||
| run: | | ||
| # create variables | ||
| CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 | ||
| KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db | ||
| PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision | ||
|
|
||
| # import certificate | ||
| echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH | ||
|
|
||
| # Create Provisioning Profiles | ||
| echo "${{ secrets.BS_BUILD_PROVISION_PROFILE_BASE64_PART_AA }}" >> part_aa | ||
| #echo "${{ secrets.BS_BUILD_PROVISION_PROFILE_BASE64_PART_AB }}" >> part_aa | ||
| #echo "${{ secrets.BS_BUILD_PROVISION_PROFILE_BASE64_PART_AC }}" >> part_aa | ||
| base64 -D -i part_aa > $PP_PATH | ||
|
|
||
| # create temporary keychain | ||
| security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | ||
| security set-keychain-settings -lut 21600 $KEYCHAIN_PATH | ||
| security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | ||
|
|
||
| # import certificate to keychain | ||
| security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH | ||
| security list-keychain -d user -s $KEYCHAIN_PATH | ||
|
|
||
| # apply provisioning profile | ||
| mkdir -p ~/Library/Developer/Xcode/UserData/Provisioning\ Profiles | ||
| cp $PP_PATH ~/Library/Developer/Xcode/UserData/Provisioning\ Profiles/ | ||
|
|
||
| # --- Step 6: Build the iOS Branch Link Simulator App using the local SDK Framework --- | ||
| - name: Build iOS App with local SDK | ||
| run: | | ||
| # Build the app. Adjust project/workspace, scheme, and destination if necessary. | ||
| # We're passing MARKETING_VERSION (versionName) and CURRENT_PROJECT_VERSION (versionCode) | ||
| xcodebuild -scheme BranchLinkSimulator -allowProvisioningUpdates \ | ||
| MARKETING_VERSION=${{ env.VERSION_STRING }} \ | ||
| CURRENT_PROJECT_VERSION=${{ env.VERSION_CODE_INT }} \ | ||
| -sdk iphoneos archive -archivePath ./IPA/BranchLinkSimulator.xcarchive | ||
| xcodebuild -exportArchive -archivePath ./IPA/BranchLinkSimulator.xcarchive -exportOptionsPlist IPA/Info.plist -exportPath IPA/ | ||
| working-directory: ./ios-app-repo | ||
|
|
||
| # --- Step 7: Echo the location of the generated .app bundle --- | ||
| - name: Echo .app bundle location | ||
| run: | | ||
| APP_PATH="./ios-app-repo/IPA/BranchLinkSimulator.ipa" | ||
| echo "Generated IPA location: $APP_PATH" | ||
|
|
||
| # --- Step 8: Upload Build Artifacts --- | ||
| - name: Upload Build Artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: BranchLinkSimulator-iOS-Debug-Build | ||
| path: ./ios-app-repo/IPA/BranchLinkSimulator.ipa | ||
|
|
||
| # --- Step 9: Run tests on GPTDriver service. --- | ||
| - name: Run GPTDriver tests | ||
| run: | | ||
| chmod +x ./branch-ios-sdk-repo/.github/gptdriverrunscript.sh | ||
| ./branch-ios-sdk-repo/.github/gptdriverrunscript.sh ./ios-app-repo/IPA/BranchLinkSimulator.ipa ios | ||
| env: | ||
| API_ORG_KEY: ${{ secrets.MOBILEBOOST_API_ORG_KEY }} | ||
| API_KEY: ${{ secrets.MOBILEBOOST_API_ORG_KEY }} | ||
| TEST_TAGS: ios | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI 24 days ago
To fix this issue, we need to explicitly set the
permissionskey in the workflow file to restrict the permissions granted to the GITHUB_TOKEN in the workflow. The minimal, safest starting point iscontents: read, which grants read-only repository access. Since this workflow checks out code, builds, signs, and uploads artifacts, but does not push changes, open issues, or create pull requests, the minimalcontents: readpermission is appropriate. This should be added at the root level of the workflow file (aftername:and beforeon:), which will affect all jobs unless overridden.No changes to functionality will occur with this update, and all workflow steps will continue to work as before, but potential write access to repository content will be removed.