From 0bda993a83715277c24eed8632b9a73e8dec980d Mon Sep 17 00:00:00 2001 From: Sandipan Date: Sat, 6 Apr 2024 16:00:58 +0530 Subject: [PATCH] ci: upload recordings to gcs (#3153) * ci: upload recordings to gcs * test --- .github/workflows/e2e.yml | 74 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 5d74847052..03105f60e9 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -50,8 +50,8 @@ jobs: uses: nick-fields/retry@v3 with: timeout_minutes: 10 - retry_wait_seconds: 30 - max_attempts: 3 + max_attempts: 10 + retry_wait_seconds: 45 command: nix develop -c sh -c 'cd dev && tilt ci' - name: Tilt Server run: | @@ -88,6 +88,39 @@ jobs: name: android-recordings path: android-recordings + # Upload recordings 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: android-recordings + 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 + 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 + + 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 + done + # Cleanup - name: Terminate Metro if: always() @@ -145,8 +178,8 @@ jobs: uses: nick-fields/retry@v3 with: timeout_minutes: 10 - retry_wait_seconds: 30 - max_attempts: 3 + max_attempts: 10 + retry_wait_seconds: 45 command: nix develop -c sh -c 'cd dev && tilt ci' - name: Tilt Server run: | @@ -177,6 +210,39 @@ jobs: name: ios-recordings path: ios-recordings + # Upload recordings 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 + 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 + 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 + + 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 + done + # Cleanup - name: Cleanup if: always()