Skip to content

Commit

Permalink
ci: record complete session (#3179)
Browse files Browse the repository at this point in the history
* ci: record complete session

* test

* ok
  • Loading branch information
sandipndev authored Apr 16, 2024
1 parent 641e837 commit 4daf79c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 24 deletions.
70 changes: 46 additions & 24 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ jobs:
run: |
nix develop -c sh -c 'emulator -avd Pixel_API_34 -gpu swiftshader -wipe-data -no-boot-anim' &
nix develop -c adb wait-for-device
nix develop -c sh -c 'adb shell screenrecord --bit-rate 4000000 --time-limit 99999999 /sdcard/screenRecord.mp4' &
echo "EMU_RECORD=$!" >> $GITHUB_ENV
- name: Run Detox Tests on Android Emulator
uses: nick-fields/retry@v3
Expand All @@ -80,7 +82,11 @@ jobs:
- name: Kill Android Emulator
if: always()
continue-on-error: true
run: nix develop -c adb emu kill
run: |
kill -SIGINT $EMU_RECORD
nix develop -c adb pull /sdcard/screenRecord.mp4 ./screenRecordUnopt.mp4
ffmpeg -i screenRecordUnopt.mp4 screenRecord.mp4
nix develop -c adb emu kill
- uses: actions/upload-artifact@v4
if: always()
Expand All @@ -96,30 +102,29 @@ jobs:
- uses: "google-github-actions/upload-cloud-storage@v2"
if: always()
with:
path: android-recordings
path: screenRecord.mp4
gzip: false
predefinedAcl: publicRead
glob: "**/*.mp4"
headers: |-
content-type: video/mp4
destination: galoy-mobile-recordings/android-recordings/${{ github.run_id }}
- name: Append Direct Links to GitHub Actions Summary
if: always()
run: |
# Define the base URL for the uploaded files in the GCS bucket
BASE_URL="https://storage.googleapis.com/galoy-mobile-recordings/android-recordings/${{ github.run_id }}/android-recordings"
echo "## Android Recordings" >> $GITHUB_STEP_SUMMARY
echo "## Android Recording" > $GITHUB_STEP_SUMMARY
COMPLETE_RECORDING_URL="https://storage.googleapis.com/galoy-mobile-recordings/android-recordings/${{ github.run_id }}/screenRecord.mp4"
echo "Full Recording: [Click here](<$COMPLETE_RECORDING_URL>)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Test Suite:" >> $GITHUB_STEP_SUMMARY
find android-recordings -type f -name "*.mp4" | while read file; do
# Extract the relative path of the file within the android-recordings folder
RELATIVE_PATH="${file#android-recordings/}"
# Construct the direct URL for the file
FILE_URL="${BASE_URL}/${RELATIVE_PATH}"
TEST_NAME=$(echo "$RELATIVE_PATH" | sed -E 's|.*/(.*)/test\.mp4|\1|')
# Append the URL to the GitHub Actions summary
echo "- $TEST_NAME [Recording](<$FILE_URL>)" >> $GITHUB_STEP_SUMMARY
echo "- $TEST_NAME" >> $GITHUB_STEP_SUMMARY
done
# Cleanup
Expand Down Expand Up @@ -188,6 +193,17 @@ jobs:
nix develop -c sh -c 'cd dev && tilt up' &
echo "TILT_SERVER_PID=$!" >> $GITHUB_ENV
- name: Record Simulator in Background
run: |
DEVICE_ID=$(xcrun simctl list devices | grep "iPhone SE (3rd generation)" | cut -d' ' -f9 | tr -d '()')
open -a Simulator --args -CurrentDeviceUDID $DEVICE_ID
while ! xcrun simctl list devices | grep "(Booted)"; do
sleep 1
echo "Waiting for Simulator device to come online..."
done
xcrun simctl io booted recordVideo screenRecord.mov &
echo "SIM_RECORD=$!" >> $GITHUB_ENV
# Tests on iOS Simulator
- name: Run Detox Tests on iOS Simulator
uses: nick-fields/retry@v3
Expand All @@ -201,6 +217,13 @@ jobs:
nix develop -c tilt wait --timeout 5m --for=condition=Ready uiresources dev-setup
nix develop -c yarn e2e:test ios.sim.debug -d -R 5 --take-screenshots all --record-videos all --record-logs all --artifacts-location ios-recordings
- name: Stop Recording
if: always()
continue-on-error: true
run: |
kill -SIGINT $SIM_RECORD
ffmpeg -i screenRecord.mov screenRecord.mp4
- run: killall Simulator
if: always()
continue-on-error: true
Expand All @@ -211,38 +234,37 @@ jobs:
name: ios-recordings
path: ios-recordings

# Upload recordings to GCS bucket
# Upload recording to GCS bucket
- uses: "google-github-actions/auth@v2"
if: always()
with:
credentials_json: "${{ secrets.BUILD_ARTIFACTS_BUCKET_KEY }}"
- uses: "google-github-actions/upload-cloud-storage@v2"
if: always()
with:
path: ios-recordings
path: screenRecord.mp4
gzip: false
predefinedAcl: publicRead
glob: "**/*.mp4"
headers: |-
content-type: video/mp4
destination: galoy-mobile-recordings/ios-recordings/${{ github.run_id }}
- name: Append Direct Links to GitHub Actions Summary
if: always()
run: |
# Define the base URL for the uploaded files in the GCS bucket
BASE_URL="https://storage.googleapis.com/galoy-mobile-recordings/ios-recordings/${{ github.run_id }}/ios-recordings"
echo "## iOS Recordings" >> $GITHUB_STEP_SUMMARY
echo "## iOS Recording" > $GITHUB_STEP_SUMMARY
COMPLETE_RECORDING_URL="https://storage.googleapis.com/galoy-mobile-recordings/ios-recordings/${{ github.run_id }}/screenRecord.mp4"
echo "Full Recording: [Click here](<$COMPLETE_RECORDING_URL>)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Test Suite:" >> $GITHUB_STEP_SUMMARY
find ios-recordings -type f -name "*.mp4" | while read file; do
# Extract the relative path of the file within the ios-recordings folder
RELATIVE_PATH="${file#ios-recordings/}"
# Construct the direct URL for the file
FILE_URL="${BASE_URL}/${RELATIVE_PATH}"
TEST_NAME=$(echo "$RELATIVE_PATH" | sed -E 's|.*/(.*)/test\.mp4|\1|')
# Append the URL to the GitHub Actions summary
echo "- $TEST_NAME [Recording](<$FILE_URL>)" >> $GITHUB_STEP_SUMMARY
echo "- $TEST_NAME" >> $GITHUB_STEP_SUMMARY
done
# Cleanup
Expand Down
Binary file added filename.mp4
Binary file not shown.

0 comments on commit 4daf79c

Please sign in to comment.