Skip to content

UI Test Workflow

UI Test Workflow #20

Workflow file for this run

name: UI Test Workflow
on:
workflow_dispatch:
inputs:
psha:
required: true
jobs:
test:
name: UI Test
runs-on: macos-13
permissions:
checks: write
statuses: write
env:
FIN_STATUS: "error"
GH_TOKEN: ${{ github.token }}
steps:
- name: Update Check Status
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/statuses/$GITHUB_SHA \
-f state='pending' \
-f target_url='https://github.com/Darock-Studio/Darock-Bili/actions/runs/${{ github.run_id }}' \
-f description='Testing...' \
-f context='UI Test'
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.psha }}
- name: Set Xcode Version
run: sudo xcode-select -s /Applications/Xcode_15.0.app
- name: Prepare Environment
run: |
brew install chargepoint/xcparse/xcparse
mkdir Caches
- name: Restore Caches
uses: actions/cache/restore@v3
with:
key: ${{ runner.os }}-ui-test-cache-
path: ~/Library/Developer/Xcode/DerivedData
- name: Update Status Env
run: echo "FIN_STATUS=failure" >> $GITHUB_ENV
- name: Resolve Package Dependencies
run: xcodebuild -resolvePackageDependencies -project ./DarockBili.xcodeproj -scheme 'DarockBili Watch App'
- name: Build for Testing
run: xcodebuild build-for-testing -scheme 'DarockBili Watch App' -project ./DarockBili.xcodeproj -destination 'platform=watchOS Simulator,name=Apple Watch Series 7 (41mm),OS=10.0' -testProductsPath ./Caches/TestProducts.xctestproducts -testPlan WatchAppUITestPlan -IDEPostProgressNotifications=YES COMPILER_INDEX_STORE_ENABLE=NO -quiet
- name: Get Current Time
id: current-time
run: echo "time=$(date +"%Y%m%d%H%M%S")" >> $GITHUB_OUTPUT
- name: Save Caches
uses: actions/cache/save@v3
with:
key: ${{ runner.os }}-ui-test-cache-${{ steps.current-time.outputs.time }}
path: ~/Library/Developer/Xcode/DerivedData
- name: Run DarockBili Watch App UI Test
run: |
xcodebuild test-without-building -destination 'platform=watchOS Simulator,name=Apple Watch Series 7 (41mm),OS=10.0' -testPlan WatchAppUITestPlan -testProductsPath ./Caches/TestProducts.xctestproducts IDEPostProgressNotifications=YES -DTDKDisableSymbolCopying=YES
echo "FIN_STATUS=success" >> $GITHUB_ENV
- name: Process Test Result
run: |
mv ~/Library/Developer/Xcode/DerivedData/DarockBili-*/Logs/Test/Test-*.xcresult ./Caches/Test-1.xcresult
mkdir Caches/ExportFiles
xcparse -s ./Caches/Test-1.xcresult ./Caches/ExportFiles
- name: Upload Test Attachments
uses: actions/upload-artifact@v3
with:
name: Test Attachments
path: ./Caches/ExportFiles
- name: Update Check Status
if: always()
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/statuses/$GITHUB_SHA \
-f state='${{ env.FIN_STATUS }}' \
-f target_url='https://github.com/Darock-Studio/Darock-Bili/actions/runs/${{ github.run_id }}' \
-f context='UI Test'