Skip to content

test branch name use rand hex #24

test branch name use rand hex

test branch name use rand hex #24

name: Integration Test
on:
pull_request:
branches: [ "*" ]
push:
branches: [ "*" ]
jobs:
test:
runs-on: macos-13-xl
permissions:
contents: write
checks: write
pull-requests: write
id-token: write
env:
iam_role_to_assume: ${{ secrets.ROLE_ARN }}
device_farm_project_arn: ${{ secrets.DEVICE_FARM_PROJECT_ARN }}
device_farm_pool_arn: ${{ secrets.DEVICE_FARM_POOL_ARN }}
device_farm_test_spec_arn: ${{ secrets.DEVICE_FARM_TEST_SPEC_ARN }}
clickstream_app_id: ${{ secrets.CLICKSTREAM_APP_ID }}
clickstream_endpoint: ${{ secrets.CLICKSTREAM_ENDPOINT }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.PROJECT_TOKEN }}
- name: Modify SDK for integration test
run: |
sed -i '' -e "s#private(set) var bundleSequenceId: Int#private(set) var bundleSequenceId: Int\n var allEventJson: String = \"\"#g" Sources/Clickstream/Dependency/Clickstream/Analytics/EventRecorder.swift
sed -i '' -e "s#toPrettierJsonString())\")#toPrettierJsonString())\")\n allEventJson.append(\"Saved event /\(event.eventType):/\(eventObject.toJsonString())\\\n\")\n UIPasteboard.general.string = allEventJson#g" Sources/Clickstream/Dependency/Clickstream/Analytics/EventRecorder.swift
sed -i '' -e "s#batchEvent.eventCount) events\")#batchEvent.eventCount) events\")\n allEventJson.append(\"Saved event /\(event.eventType):/\(eventObject.toJsonString())\\\n\")\n UIPasteboard.general.string = allEventJson#g" Sources/Clickstream/Dependency/Clickstream/Analytics/EventRecorder.swift
git diff
git config user.name "github-actions"
git config user.email "github-actions@github.com"
branch=pastboard-$(openssl rand -hex 5)
echo $branch
echo "tempbranch=$branch" >> "$GITHUB_ENV"
git checkout -b $branch
git push --set-upstream origin $branch
- name: Prepare sample iOS app
run: |
git clone https://github.com/aws-samples/clickstream-sdk-samples
cd clickstream-sdk-samples/ios
sed -i "s#\"appId\": \"your appId\"#\"appId\": \"${{ env.clickstream_app_id }}\"#g" ModerneShopping/amplifyconfiguration.json
sed -i "s#\"endpoint\": \"your endpoint\"#\"endpoint\": \"${{ env.clickstream_endpoint }}\"#g" ModerneShopping/amplifyconfiguration.json
cat ModerneShopping/amplifyconfiguration.json
sed -i "s#if index==0 || index==1 {}#if index==0 || index==1 {\n cart.addToCart(addedProduct: product, quantity: 1)\n }#g" ModerneShopping/Views/ProductViews/ProductList.swift
cat ModerneShopping/Views/ProductViews/ProductList.swift
# - name: Build sample iOS app
# - uses: yukiarrr/ios-build-action@v1.11.2
# with:
# project-path: Unity-iPhone.xcodeproj
# p12-base64: ${{ secrets.P12_BASE64 }}
# mobileprovision-base64: ${{ secrets.MOBILEPROVISION_BASE64 }}
# code-signing-identity: ${{ secrets.CODE_SIGNING_IDENTITY }}
# team-id: ${{ secrets.TEAM_ID }}
# workspace-path: Unity-iPhone.xcworkspace # optional
- name: Delete temp branch
if: success() || failure()
run: |
git checkout main
echo $tempbranch
git branch -D $tempbranch
git push origin —delete $tempbranch
- name: Build Device Farm test file
run: |
cd IntegrationTest
pip install virtualenv
virtualenv --help
virtualenv workspace
cd workspace
source bin/activate
pip install pytest
pip install Appium-Python-Client
mkdir tests
cp ../appium/shopping_test.py tests/
find tests/
py.test --collect-only tests/
cd tests/
find . -name '__pycache__' -type d -exec rm -r {} +
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
cd ..
pip freeze > requirements.txt
zip -r test_bundle.zip tests/ requirements.txt
ls
cd ..
- name: Configure AWS Credentials
if: ${{ env.iam_role_to_assume != '' }}
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.iam_role_to_assume }}
aws-region: us-west-2
# - name: Execute device farm test
# run: |
# cd integrationtest
# pip install -r requirements.txt
# cd devicefarm
# cp ../../clickstream-sdk-samples/android/app/build/outputs/apk/debug/app-debug.apk ./
# cp ../workspace/test_bundle.zip ./
# ls
# python -u -c "from automate_device_farm import upload_and_test_android; upload_and_test_android('app-debug.apk', 'test_bundle.zip', '${{ env.device_farm_project_arn }}', '${{ env.device_farm_test_spec_arn }}', '${{ env.device_farm_pool_arn }}')"
# - name: Execute logcat test
# run: |
# cd integrationtest/devicefarm
# pytest logcat_test.py -s --junitxml=report/logcat_test_report.xml --html=report/logcat_test_report.html
# - name: Publish Test Report
# uses: mikepenz/action-junit-report@v4
# if: success() || failure()
# with:
# report_paths: 'integrationtest/devicefarm/report/*.xml'
# require_tests: true
# detailed_summary: true
# include_passed: true
# fail_on_failure: true
# job_name: integration test
# - name: Upload test result
# uses: actions/upload-artifact@v4
# if: success() || failure()
# with:
# name: test-result
# path: |
# integrationtest/devicefarm/report/
# integrationtest/devicefarm/MyAndroidAppTest-*/**