From 8ef859c70e82595ca25bd243c6f832a31e2a8aa5 Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 18 Sep 2024 12:59:14 -0700 Subject: [PATCH 01/41] Remove unused VERSION environment variables --- .github/workflows/deploy.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6ef9fe299510..2964a94bc26f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -140,9 +140,6 @@ jobs: name: android-build-artifact path: ./android/app/build/outputs/bundle/productionRelease/app-production-release.aab - - name: Set current App version in Env - run: echo "VERSION=$(npm run print-version --silent)" >> "$GITHUB_ENV" - - name: Warn deployers if Android production deploy failed if: ${{ failure() && fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} uses: 8398a7/action-slack@v3 @@ -266,9 +263,6 @@ jobs: env: LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} - - name: Set current App version in Env - run: echo "VERSION=$(npm run print-version --silent)" >> "$GITHUB_ENV" - - name: Get iOS native version id: getIOSVersion run: echo "IOS_VERSION=$(echo '${{ needs.prep.outputs.APP_VERSION }}' | tr '-' '.')" >> "$GITHUB_OUTPUT" @@ -381,9 +375,6 @@ jobs: env: CF_API_KEY: ${{ secrets.CLOUDFLARE_TOKEN }} - - name: Set current App version in Env - run: echo "VERSION=$(npm run print-version --silent)" >> "$GITHUB_ENV" - - name: Verify staging deploy if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: | From a449e563a0a85a9363846809e1f513e32fcc7fcc Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 18 Sep 2024 15:39:24 -0700 Subject: [PATCH 02/41] Save draft state --- .github/workflows/deploy.yml | 70 +++++++++++++----------------------- package-lock.json | 16 --------- 2 files changed, 25 insertions(+), 61 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2964a94bc26f..122f7817db76 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -67,58 +67,52 @@ jobs: needs: prep secrets: inherit - android: - name: Build and deploy Android + buildAndroid: + name: Build Android app + uses: ./.github/workflows/buildAndroid.yml + if: ${{ github.ref == 'refs/heads/staging' }} needs: prep - runs-on: ubuntu-latest-xl + secrets: inherit + with: + type: release + ref: staging + + deployAndroid: + name: Deploy Android app + # TODO: is this needs safe? Or will it not run for production? + needs: buildAndroid + runs-on: ubuntu-latest env: RUBYOPT: '-rostruct' steps: - name: Checkout uses: actions/checkout@v4 - - name: Configure MapBox SDK - run: ./scripts/setup-mapbox-sdk.sh ${{ secrets.MAPBOX_SDK_DOWNLOAD_TOKEN }} - - - name: Setup Node - uses: ./.github/actions/composite/setupNode - - - name: Setup Java - uses: actions/setup-java@v4 - with: - distribution: 'oracle' - java-version: '17' - - name: Setup Ruby uses: ruby/setup-ruby@v1.190.0 with: bundler-cache: true - - name: Decrypt keystore - run: cd android/app && gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output my-upload-key.keystore my-upload-key.keystore.gpg - env: - LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} - - - name: Decrypt json key - run: cd android/app && gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output android-fastlane-json-key.json android-fastlane-json-key.json.gpg - env: - LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} - - name: Get Android native version id: getAndroidVersion run: echo "VERSION_CODE=$(grep -o 'versionCode\s\+[0-9]\+' android/app/build.gradle | awk '{ print $2 }')" >> "$GITHUB_OUTPUT" - - name: Build Android app - if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} - run: bundle exec fastlane android build - env: - MYAPP_UPLOAD_STORE_PASSWORD: ${{ secrets.MYAPP_UPLOAD_STORE_PASSWORD }} - MYAPP_UPLOAD_KEY_PASSWORD: ${{ secrets.MYAPP_UPLOAD_KEY_PASSWORD }} + - name: Download Android build artifacts + uses: actions/download-artifact@v4 + with: + path: android-artifact + pattern: android-artifact-* + merge-multiple: true + - name: Log downloaded artifact paths + run: ls -R android-artifact + + # TODO: Set path in env. How to pass from Fastlane in one job through upload-artifact to this job? - name: Upload Android app to Google Play run: bundle exec fastlane android ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) && 'upload_google_play_production' || 'upload_google_play_internal' }} env: VERSION: ${{ steps.getAndroidVersion.outputs.VERSION_CODE }} + gradleAABOutputPath: android-artifact/ - name: Upload Android build to Browser Stack if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} @@ -126,20 +120,6 @@ jobs: env: BROWSERSTACK: ${{ secrets.BROWSERSTACK }} - - name: Upload Android sourcemaps artifact - if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} - uses: actions/upload-artifact@v4 - with: - name: android-sourcemaps-artifact - path: ./android/app/build/generated/sourcemaps/react/productionRelease/index.android.bundle.map - - - name: Upload Android build artifact - if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} - uses: actions/upload-artifact@v4 - with: - name: android-build-artifact - path: ./android/app/build/outputs/bundle/productionRelease/app-production-release.aab - - name: Warn deployers if Android production deploy failed if: ${{ failure() && fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} uses: 8398a7/action-slack@v3 diff --git a/package-lock.json b/package-lock.json index 2a7e349d25a3..dfceedd823d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27979,22 +27979,6 @@ "jest": "bin/jest.js" } }, - "node_modules/jest-expo/node_modules/@babel/code-frame": { - "version": "7.10.4", - "license": "MIT", - "dependencies": { - "@babel/highlight": "^7.10.4" - } - }, - "node_modules/jest-expo/node_modules/@expo/json-file": { - "version": "8.3.1", - "license": "MIT", - "dependencies": { - "@babel/code-frame": "~7.10.4", - "json5": "^2.2.2", - "write-file-atomic": "^2.3.0" - } - }, "node_modules/jest-expo/node_modules/json5": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.2.tgz", From e2d2dfbe064937672a4b9f79ed9d606ba5d209ce Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 18 Sep 2024 18:51:13 -0700 Subject: [PATCH 03/41] Create and use callable buildAndroid workflow --- .github/workflows/buildAndroid.yml | 138 +++++++++++++++++++++++++++++ .github/workflows/deploy.yml | 9 +- 2 files changed, 142 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/buildAndroid.yml diff --git a/.github/workflows/buildAndroid.yml b/.github/workflows/buildAndroid.yml new file mode 100644 index 000000000000..cee7d0391ec8 --- /dev/null +++ b/.github/workflows/buildAndroid.yml @@ -0,0 +1,138 @@ +name: Build Android app + +on: + workflow_call: + inputs: + type: + description: 'What type of build to run. Must be one of ["release", "adhoc", "e2e", "e2eDelta"]' + required: true + type: string + ref: + description: Git ref to checkout and build + required: true + type: string + outputs: + AAB_FILE_NAME: + value: ${{ jobs.build.outputs.AAB_FILE_NAME }} + APK_FILE_NAME: + value: ${{ jobs.build.outputs.APK_FILE_NAME }} + + workflow_dispatch: + inputs: + type: + description: What type of build do you want to run? + required: true + type: choice + options: + - release + - adhoc + - e2e + - e2eDelta + ref: + description: Git ref to checkout and build + required: true + type: string + +jobs: + build: + name: Build Android app + runs-on: ubuntu-latest-xl + env: + RUBYOPT: '-rostruct' + outputs: + AAB_FILE_NAME: ${{ steps.build.outputs.AAB_FILE_NAME }} + APK_FILE_NAME: ${{ steps.build.outputs.APK_FILE_NAME }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} + + - name: Configure MapBox SDK + run: ./scripts/setup-mapbox-sdk.sh ${{ secrets.MAPBOX_SDK_DOWNLOAD_TOKEN }} + + - name: Setup Node + uses: ./.github/actions/composite/setupNode + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: oracle + java-version: 17 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Setup Ruby + uses: ruby/setup-ruby@v1.190.0 + with: + bundler-cache: true + + - name: Decrypt keystore and json key + run: | + cd android/app + gpg --batch --yes --decrypt --passphrase="${{ secrets.LARGE_SECRET_PASSPHRASE }}" --output my-upload-key.keystore my-upload-key.keystore.gpg + gpg --batch --yes --decrypt --passphrase="${{ secrets.LARGE_SECRET_PASSPHRASE }}" --output android-fastlane-json-key.json android-fastlane-json-key.json.gpg + + - name: Get Android native version + id: getAndroidVersion + run: echo "VERSION_CODE=$(grep -o 'versionCode\s\+[0-9]\+' android/app/build.gradle | awk '{ print $2 }')" >> "$GITHUB_OUTPUT" + + - name: Build Android app + id: build + run: | + lane='' + case ${{ inputs.type }} in + 'release') + lane='build';; + 'adhoc') + lane='build_adhoc';; + 'e2e') + lane='build_e2e';; + 'e2eDelta') + lane='build_e2eDelta';; + esac + bundle exec fastlane android "$lane" + + # gradleAPKOutputPath and gradleAABOutputPath are environment varibles set within the Fastfile + echo "GRADLE_AAB_OUTPUT_PATH=$gradleAABOutputPath" >> "$GITHUB_OUTPUT" + echo "AAB_FILE_NAME=$(basename "$gradleAABOutputPath")" >> "$GITHUB_OUTPUT" + echo "GRADLE_APK_OUTPUT_PATH=$gradleAPKOutputPath" >> "$GITHUB_OUTPUT" + echo "APK_FILE_NAME=$(basename "$gradleAPKOutputPath")" >> "$GITHUB_OUTPUT" + + SHOULD_UPLOAD_SOURCEMAPS='false' + if [ -f ./android/app/build/generated/sourcemaps/react/productionRelease/index.android.bundle.map ]; then + SHOULD_UPLOAD_SOURCEMAPS='true' + fi + echo "SHOULD_UPLOAD_SOURCEMAPS=$SHOULD_UPLOAD_SOURCEMAPS" >> "$GITHUB_OUTPUT" + env: + MYAPP_UPLOAD_STORE_PASSWORD: ${{ secrets.MYAPP_UPLOAD_STORE_PASSWORD }} + MYAPP_UPLOAD_KEY_PASSWORD: ${{ secrets.MYAPP_UPLOAD_KEY_PASSWORD }} + + - name: Upload Android AAB artifact + if: ${{ steps.build.outputs.GRADLE_AAB_OUTPUT_PATH != '' }} + uses: actions/upload-artifact@v4 + with: + name: android-artifact-aab + path: ${{ steps.build.outputs.GRADLE_AAB_OUTPUT_PATH }} + + - name: Upload Android APK artifact + if: ${{ steps.build.outputs.GRADLE_APK_OUTPUT_PATH != '' }} + uses: actions/upload-artifact@v4 + with: + name: android-artifact-apk + path: ${{ steps.build.outputs.GRADLE_APK_OUTPUT_PATH }} + + - name: Upload Android sourcemaps artifact + if: ${{ steps.build.outputs.SHOULD_UPLOAD_SOURCEMAPS == 'true' }} + uses: actions/upload-artifact@v4 + with: + name: android-artifact-sourcemaps + path: ./android/app/build/generated/sourcemaps/react/productionRelease/index.android.bundle.map + + - name: Announce failure in slack + if: failure() + uses: ./.github/actions/composite/announceFailedWorkflowInSlack + with: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 122f7817db76..363f123a309e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -100,23 +100,22 @@ jobs: - name: Download Android build artifacts uses: actions/download-artifact@v4 with: - path: android-artifact + path: /etc/usr/artifacts pattern: android-artifact-* merge-multiple: true - name: Log downloaded artifact paths - run: ls -R android-artifact + run: ls -R /etc/usr/artifacts - # TODO: Set path in env. How to pass from Fastlane in one job through upload-artifact to this job? - name: Upload Android app to Google Play run: bundle exec fastlane android ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) && 'upload_google_play_production' || 'upload_google_play_internal' }} env: VERSION: ${{ steps.getAndroidVersion.outputs.VERSION_CODE }} - gradleAABOutputPath: android-artifact/ + gradleAABOutputPath: /etc/usr/artifacts/android-artifact-aab/${{ needs.buildAndroid.outputs.AAB_FILE_NAME }} - name: Upload Android build to Browser Stack if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} - run: curl -u "$BROWSERSTACK" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@./android/app/build/outputs/bundle/productionRelease/app-production-release.aab" + run: curl -u "$BROWSERSTACK" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@/etc/usr/artifacts/android-artifact-aab/${{ needs.buildAndroid.outputs.AAB_FILE_NAME }}" env: BROWSERSTACK: ${{ secrets.BROWSERSTACK }} From 281d55894d0230a541de5dafca2596b7c2e1dbd4 Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 18 Sep 2024 18:53:03 -0700 Subject: [PATCH 04/41] Add quotes in case statement --- .github/workflows/buildAndroid.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildAndroid.yml b/.github/workflows/buildAndroid.yml index cee7d0391ec8..af8733564025 100644 --- a/.github/workflows/buildAndroid.yml +++ b/.github/workflows/buildAndroid.yml @@ -83,7 +83,7 @@ jobs: id: build run: | lane='' - case ${{ inputs.type }} in + case '${{ inputs.type }}' in 'release') lane='build';; 'adhoc') From bb94f92decd29737a14359ef988fef8d316511ed Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 18 Sep 2024 18:55:47 -0700 Subject: [PATCH 05/41] Simplify environment variable names --- .github/workflows/buildAndroid.yml | 18 +++++++++--------- fastlane/Fastfile | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/buildAndroid.yml b/.github/workflows/buildAndroid.yml index af8733564025..449781d4aec5 100644 --- a/.github/workflows/buildAndroid.yml +++ b/.github/workflows/buildAndroid.yml @@ -95,11 +95,11 @@ jobs: esac bundle exec fastlane android "$lane" - # gradleAPKOutputPath and gradleAABOutputPath are environment varibles set within the Fastfile - echo "GRADLE_AAB_OUTPUT_PATH=$gradleAABOutputPath" >> "$GITHUB_OUTPUT" - echo "AAB_FILE_NAME=$(basename "$gradleAABOutputPath")" >> "$GITHUB_OUTPUT" - echo "GRADLE_APK_OUTPUT_PATH=$gradleAPKOutputPath" >> "$GITHUB_OUTPUT" - echo "APK_FILE_NAME=$(basename "$gradleAPKOutputPath")" >> "$GITHUB_OUTPUT" + # aabPath and apkPath are environment varibles set within the Fastfile + echo "AAB_PATH=$aabPath" >> "$GITHUB_OUTPUT" + echo "AAB_FILE_NAME=$(basename "$aabPath")" >> "$GITHUB_OUTPUT" + echo "APK_PATH=$apkPath" >> "$GITHUB_OUTPUT" + echo "APK_FILE_NAME=$(basename "$apkPath")" >> "$GITHUB_OUTPUT" SHOULD_UPLOAD_SOURCEMAPS='false' if [ -f ./android/app/build/generated/sourcemaps/react/productionRelease/index.android.bundle.map ]; then @@ -111,18 +111,18 @@ jobs: MYAPP_UPLOAD_KEY_PASSWORD: ${{ secrets.MYAPP_UPLOAD_KEY_PASSWORD }} - name: Upload Android AAB artifact - if: ${{ steps.build.outputs.GRADLE_AAB_OUTPUT_PATH != '' }} + if: ${{ steps.build.outputs.AAB_PATH != '' }} uses: actions/upload-artifact@v4 with: name: android-artifact-aab - path: ${{ steps.build.outputs.GRADLE_AAB_OUTPUT_PATH }} + path: ${{ steps.build.outputs.AAB_PATH }} - name: Upload Android APK artifact - if: ${{ steps.build.outputs.GRADLE_APK_OUTPUT_PATH != '' }} + if: ${{ steps.build.outputs.APK_PATH != '' }} uses: actions/upload-artifact@v4 with: name: android-artifact-apk - path: ${{ steps.build.outputs.GRADLE_APK_OUTPUT_PATH }} + path: ${{ steps.build.outputs.APK_PATH }} - name: Upload Android sourcemaps artifact if: ${{ steps.build.outputs.SHOULD_UPLOAD_SOURCEMAPS == 'true' }} diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 15eb36c819b5..6187b87655bf 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -15,8 +15,8 @@ require 'ostruct' skip_docs opt_out_usage -KEY_GRADLE_APK_PATH = "gradleAPKOutputPath" -KEY_GRADLE_AAB_PATH = "gradleAABOutputPath" +KEY_GRADLE_APK_PATH = "apkPath" +KEY_GRADLE_AAB_PATH = "aabPath" KEY_IPA_PATH = "ipaPath" KEY_DSYM_PATH = "dsymPath" From b09fc11ac4ae0aa225cbdf31b598d476f7d4b30d Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 18 Sep 2024 20:09:16 -0700 Subject: [PATCH 06/41] Separate upload and submit step for Android deploys --- .github/workflows/deploy.yml | 51 +++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 363f123a309e..61e4c9d29df3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -77,9 +77,9 @@ jobs: type: release ref: staging - deployAndroid: - name: Deploy Android app - # TODO: is this needs safe? Or will it not run for production? + uploadAndroid: + name: Upload Android build to Google Play Store + if: ${{ github.ref == 'refs/heads/staging' }} needs: buildAndroid runs-on: ubuntu-latest env: @@ -93,10 +93,6 @@ jobs: with: bundler-cache: true - - name: Get Android native version - id: getAndroidVersion - run: echo "VERSION_CODE=$(grep -o 'versionCode\s\+[0-9]\+' android/app/build.gradle | awk '{ print $2 }')" >> "$GITHUB_OUTPUT" - - name: Download Android build artifacts uses: actions/download-artifact@v4 with: @@ -108,19 +104,50 @@ jobs: run: ls -R /etc/usr/artifacts - name: Upload Android app to Google Play - run: bundle exec fastlane android ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) && 'upload_google_play_production' || 'upload_google_play_internal' }} + run: bundle exec fastlane android upload_google_play_internal env: - VERSION: ${{ steps.getAndroidVersion.outputs.VERSION_CODE }} - gradleAABOutputPath: /etc/usr/artifacts/android-artifact-aab/${{ needs.buildAndroid.outputs.AAB_FILE_NAME }} + aabPath: /etc/usr/artifacts/android-artifact-aab/${{ needs.buildAndroid.outputs.AAB_FILE_NAME }} - name: Upload Android build to Browser Stack - if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: curl -u "$BROWSERSTACK" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@/etc/usr/artifacts/android-artifact-aab/${{ needs.buildAndroid.outputs.AAB_FILE_NAME }}" env: BROWSERSTACK: ${{ secrets.BROWSERSTACK }} + submitAndroid: + name: Submit Android app for production review + needs: prep + if: ${{ github.ref == 'refs/heads/production' }} + runs-on: ubuntu-latest + env: + RUBYOPT: '-rostruct' + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Ruby + uses: ruby/setup-ruby@v1.190.0 + with: + bundler-cache: true + + - name: Get Android native version + id: getAndroidVersion + run: echo "VERSION_CODE=$(grep -o 'versionCode\s\+[0-9]\+' android/app/build.gradle | awk '{ print $2 }')" >> "$GITHUB_OUTPUT" + + - name: Download Android build artifacts + uses: actions/download-artifact@v4 + with: + path: /etc/usr/artifacts + pattern: android-artifact-* + merge-multiple: true + + - name: Log downloaded artifact paths + run: ls -R /etc/usr/artifacts + + - name: Submit Android build for review + run: bundle exec fastlane android upload_google_play_production + - name: Warn deployers if Android production deploy failed - if: ${{ failure() && fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} + if: ${{ failure() }} uses: 8398a7/action-slack@v3 with: status: custom From 5aa4d486459ed83427df815a9fcb03f0884f9d28 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 19 Sep 2024 19:06:51 -0700 Subject: [PATCH 07/41] Add continue-on-error for artifact upload steps --- .github/workflows/buildAndroid.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/buildAndroid.yml b/.github/workflows/buildAndroid.yml index 449781d4aec5..bd643cc0f979 100644 --- a/.github/workflows/buildAndroid.yml +++ b/.github/workflows/buildAndroid.yml @@ -112,6 +112,7 @@ jobs: - name: Upload Android AAB artifact if: ${{ steps.build.outputs.AAB_PATH != '' }} + continue-on-error: true uses: actions/upload-artifact@v4 with: name: android-artifact-aab @@ -119,6 +120,7 @@ jobs: - name: Upload Android APK artifact if: ${{ steps.build.outputs.APK_PATH != '' }} + continue-on-error: true uses: actions/upload-artifact@v4 with: name: android-artifact-apk @@ -126,6 +128,7 @@ jobs: - name: Upload Android sourcemaps artifact if: ${{ steps.build.outputs.SHOULD_UPLOAD_SOURCEMAPS == 'true' }} + continue-on-error: true uses: actions/upload-artifact@v4 with: name: android-artifact-sourcemaps From 019fcb2e93dd7ccd9b3d3b0ef2bbb5fce4a42dba Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 25 Sep 2024 13:32:30 -0700 Subject: [PATCH 08/41] Fix checkDeploymentSuccess job --- .github/workflows/deploy.yml | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 67d5006fac0d..0507404b1c18 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -428,7 +428,7 @@ jobs: name: Post a Slack message when any platform fails to build or deploy runs-on: ubuntu-latest if: ${{ failure() }} - needs: [android, desktop, iOS, web] + needs: [buildAndroid, uploadAndroid, submitAndroid, desktop, iOS, web] steps: - name: Checkout uses: actions/checkout@v4 @@ -454,15 +454,24 @@ jobs: outputs: IS_AT_LEAST_ONE_PLATFORM_DEPLOYED: ${{ steps.checkDeploymentSuccessOnAtLeastOnePlatform.outputs.IS_AT_LEAST_ONE_PLATFORM_DEPLOYED }} IS_ALL_PLATFORMS_DEPLOYED: ${{ steps.checkDeploymentSuccessOnAtLeastAllPlatform.outputs.IS_ALL_PLATFORMS_DEPLOYED }} - needs: [android, desktop, iOS, web] + needs: [buildAndroid, uploadAndroid, submitAndroid, desktop, iOS, web] if: ${{ always() }} steps: - name: Check deployment success on at least one platform id: checkDeploymentSuccessOnAtLeastOnePlatform run: | isAtLeastOnePlatformDeployed="false" - if [ "${{ needs.android.result }}" == "success" ] || \ - [ "${{ needs.iOS.result }}" == "success" ] || \ + if [ ${{ github.ref }} == 'refs/heads/production' ]; then + if [ "${{ needs.submitAndroid.result }}" == "success" ]; then + isAtLeastOnePlatformDeployed="true" + fi + else + if [ "${{ needs.uploadAndroid.result }}" == "success" ]; then + isAtLeastOnePlatformDeployed="true" + fi + fi + + if [ "${{ needs.iOS.result }}" == "success" ] || \ [ "${{ needs.desktop.result }}" == "success" ] || \ [ "${{ needs.web.result }}" == "success" ]; then isAtLeastOnePlatformDeployed="true" @@ -474,12 +483,22 @@ jobs: id: checkDeploymentSuccessOnAtLeastAllPlatform run: | isAllPlatformsDeployed="false" - if [ "${{ needs.android.result }}" == "success" ] && \ - [ "${{ needs.iOS.result }}" == "success" ] && \ + if [ "${{ needs.iOS.result }}" == "success" ] && \ [ "${{ needs.desktop.result }}" == "success" ] && \ [ "${{ needs.web.result }}" == "success" ]; then isAllPlatformsDeployed="true" fi + + if [ ${{ github.ref }} == 'refs/heads/production' ]; then + if [ "${{ needs.submitAndroid.result }}" != "success" ]; then + isAtLeastOnePlatformDeployed="false" + fi + else + if [ "${{ needs.uploadAndroid.result }}" != "success" ]; then + isAtLeastOnePlatformDeployed="false" + fi + fi + echo "IS_ALL_PLATFORMS_DEPLOYED=$isAllPlatformsDeployed" >> "$GITHUB_OUTPUT" echo "IS_ALL_PLATFORMS_DEPLOYED is $isAllPlatformsDeployed" From 6235d41a68e9d8a998c30567d52b53bcd0b6c620 Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 25 Sep 2024 13:34:21 -0700 Subject: [PATCH 09/41] Fix needs for other jobs --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0507404b1c18..0b8235eebb4a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -614,7 +614,7 @@ jobs: name: Post a Slack message when all platforms deploy successfully runs-on: ubuntu-latest if: ${{ always() && fromJSON(needs.checkDeploymentSuccess.outputs.IS_ALL_PLATFORMS_DEPLOYED) }} - needs: [prep, android, desktop, iOS, web, checkDeploymentSuccess, createPrerelease, finalizeRelease] + needs: [prep, buildAndroid, uploadAndroid, submitAndroid, desktop, iOS, web, checkDeploymentSuccess, createPrerelease, finalizeRelease] steps: - name: 'Announces the deploy in the #announce Slack room' uses: 8398a7/action-slack@v3 @@ -668,7 +668,7 @@ jobs: postGithubComments: uses: ./.github/workflows/postDeployComments.yml if: ${{ always() && fromJSON(needs.checkDeploymentSuccess.outputs.IS_AT_LEAST_ONE_PLATFORM_DEPLOYED) }} - needs: [prep, android, desktop, iOS, web, checkDeploymentSuccess, createPrerelease, finalizeRelease] + needs: [prep, buildAndroid, uploadAndroid, submitAndroid, desktop, iOS, web, checkDeploymentSuccess, createPrerelease, finalizeRelease] with: version: ${{ needs.prep.outputs.APP_VERSION }} env: ${{ github.ref == 'refs/heads/production' && 'production' || 'staging' }} From 00ffddaaf1607d933cd1aca26f545db64da6a6dc Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 25 Sep 2024 14:30:12 -0700 Subject: [PATCH 10/41] Implement buildAndroid job in testBuild --- .github/workflows/buildAndroid.yml | 7 ++ .github/workflows/testBuild.yml | 101 ++++++++++------------------- fastlane/Fastfile | 8 ++- 3 files changed, 49 insertions(+), 67 deletions(-) diff --git a/.github/workflows/buildAndroid.yml b/.github/workflows/buildAndroid.yml index bd643cc0f979..05183d433044 100644 --- a/.github/workflows/buildAndroid.yml +++ b/.github/workflows/buildAndroid.yml @@ -79,6 +79,13 @@ jobs: id: getAndroidVersion run: echo "VERSION_CODE=$(grep -o 'versionCode\s\+[0-9]\+' android/app/build.gradle | awk '{ print $2 }')" >> "$GITHUB_OUTPUT" + - name: Setup DotEnv + if: ${{ inputs.type == 'adhoc' }} + run: | + cp .env.staging .env.adhoc + sed -i 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc + echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.adhoc + - name: Build Android app id: build run: | diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index f523faf785c0..180b8bcdc3ec 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -45,7 +45,7 @@ jobs: needs: validateActor if: ${{ fromJSON(needs.validateActor.outputs.READY_TO_BUILD) }} outputs: - REF: ${{steps.getHeadRef.outputs.REF}} + REF: ${{ steps.getHeadRef.outputs.REF }} steps: - name: Checkout if: ${{ github.event_name == 'workflow_dispatch' }} @@ -60,48 +60,36 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - android: - name: Build and deploy Android for testing - needs: [validateActor, getBranchRef] + buildAndroid: + name: Build Android app for testing + uses: ./.github/workflows/buildAndroid.yml if: ${{ fromJSON(needs.validateActor.outputs.READY_TO_BUILD) }} - runs-on: ubuntu-latest-xl + needs: [validateActor, getBranchRef] + id: buildAndroid + secrets: inherit + with: + type: adhoc + ref: ${{ github.event.pull_request.head.sha || needs.getBranchRef.outputs.REF }} + + uploadAndroid: + name: Upload Android app to S3 + needs: [buildAndroid] + runs-on: ubuntu-latest env: RUBYOPT: '-rostruct' + outputs: + S3_APK_PATH: ${{ steps.exportS3Paths.outputs.S3_APK_PATH }} + S3_HTML_PATH: ${{ steps.exportS3Paths.outputs.S3_HTML_PATH }} steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha || needs.getBranchRef.outputs.REF }} - - - name: Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it - run: | - cp .env.staging .env.adhoc - sed -i 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc - echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.adhoc - - - name: Setup Node - uses: ./.github/actions/composite/setupNode - - - name: Setup Java - uses: actions/setup-java@v4 - with: - distribution: 'oracle' - java-version: '17' - - - name: Setup Ruby - uses: ruby/setup-ruby@v1.190.0 + - name: Download Android build artifacts + uses: actions/download-artifact@v4 with: - bundler-cache: true - - - name: Decrypt keystore - run: cd android/app && gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output my-upload-key.keystore my-upload-key.keystore.gpg - env: - LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} + path: /etc/usr/artifacts + pattern: android-artifact-* + merge-multiple: true - - name: Decrypt json key - run: cd android/app && gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output android-fastlane-json-key.json android-fastlane-json-key.json.gpg - env: - LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} + - name: Log downloaded artifact paths + run: ls -R /etc/usr/artifacts - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4 @@ -110,15 +98,6 @@ jobs: aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-1 - - name: Configure MapBox SDK - run: ./scripts/setup-mapbox-sdk.sh ${{ secrets.MAPBOX_SDK_DOWNLOAD_TOKEN }} - - - name: Run AdHoc build - run: bundle exec fastlane android build_adhoc - env: - MYAPP_UPLOAD_STORE_PASSWORD: ${{ secrets.MYAPP_UPLOAD_STORE_PASSWORD }} - MYAPP_UPLOAD_KEY_PASSWORD: ${{ secrets.MYAPP_UPLOAD_KEY_PASSWORD }} - - name: Upload AdHoc build to S3 run: bundle exec fastlane android upload_s3 env: @@ -127,11 +106,12 @@ jobs: S3_BUCKET: ad-hoc-expensify-cash S3_REGION: us-east-1 - - name: Upload Artifact - uses: actions/upload-artifact@v4 - with: - name: android - path: ./android_paths.json + - name: Export S3 paths + id: exportS3Paths + run: | + # $s3APKPath and $s3HtmlPath are from within the Fastfile, android upload_s3 lane + echo "S3_APK_PATH=$s3APKPath" >> "$GITHUB_OUTPUT" + echo "S3_HTML_PATH=$s3HtmlPath" >> "$GITHUB_OUTPUT" iOS: name: Build and deploy iOS for testing @@ -304,7 +284,7 @@ jobs: postGithubComment: runs-on: ubuntu-latest name: Post a GitHub comment with app download links for testing - needs: [validateActor, getBranchRef, android, iOS, desktop, web] + needs: [validateActor, getBranchRef, uploadAndroid, iOS, desktop, web] if: ${{ always() }} steps: - name: Checkout @@ -317,17 +297,6 @@ jobs: uses: actions/download-artifact@v4 if: ${{ fromJSON(needs.validateActor.outputs.READY_TO_BUILD) }} - - name: Read JSONs with android paths - id: get_android_path - if: ${{ needs.android.result == 'success' }} - run: | - content_android="$(cat ./android/android_paths.json)" - content_android="${content_android//'%'/'%25'}" - content_android="${content_android//$'\n'/'%0A'}" - content_android="${content_android//$'\r'/'%0D'}" - android_path=$(echo "$content_android" | jq -r '.html_path') - echo "android_path=$android_path" >> "$GITHUB_OUTPUT" - - name: Read JSONs with iOS paths id: get_ios_path if: ${{ needs.iOS.result == 'success' }} @@ -345,11 +314,11 @@ jobs: with: PR_NUMBER: ${{ env.PULL_REQUEST_NUMBER }} GITHUB_TOKEN: ${{ github.token }} - ANDROID: ${{ needs.android.result }} + ANDROID: ${{ needs.uploadAndroid.result }} DESKTOP: ${{ needs.desktop.result }} IOS: ${{ needs.iOS.result }} WEB: ${{ needs.web.result }} - ANDROID_LINK: ${{steps.get_android_path.outputs.android_path}} + ANDROID_LINK: ${{ needs.uploadAndroid.outputs.S3_HTML_PATH }} DESKTOP_LINK: https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/${{ env.PULL_REQUEST_NUMBER }}/NewExpensify.dmg - IOS_LINK: ${{steps.get_ios_path.outputs.ios_path}} + IOS_LINK: ${{ steps.get_ios_path.outputs.ios_path }} WEB_LINK: https://${{ env.PULL_REQUEST_NUMBER }}.pr-testing.expensify.com diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 6187b87655bf..409de4d5258a 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -19,6 +19,8 @@ KEY_GRADLE_APK_PATH = "apkPath" KEY_GRADLE_AAB_PATH = "aabPath" KEY_IPA_PATH = "ipaPath" KEY_DSYM_PATH = "dsymPath" +KEY_S3_APK_PATH = "s3APKPath" +KEY_S3_HTML_PATH = "s3HtmlPath" # Export environment variables in the parent shell. # In a GitHub Actions environment, it will save the environment variables in the GITHUB_ENV file. @@ -139,7 +141,11 @@ platform :android do apk: ENV[KEY_GRADLE_APK_PATH], app_directory: "android/#{ENV['PULL_REQUEST_NUMBER']}", ) - sh("echo '{\"apk_path\": \"#{lane_context[SharedValues::S3_APK_OUTPUT_PATH]}\",\"html_path\": \"#{lane_context[SharedValues::S3_HTML_OUTPUT_PATH]}\"}' > ../android_paths.json") + puts "Saving S3 outputs in env..." + exportEnvVars({ + KEY_S3_APK_PATH => lane_context[SharedValues::S3_APK_OUTPUT_PATH], + KEY_S3_HTML_PATH => lane_context[SharedValues::S3_HTML_OUTPUT_PATH], + }) end desc "Upload app to Google Play for internal testing" From e4c568ecc288b5d7febe932c59f4d61298c75054 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 26 Sep 2024 11:49:04 -0700 Subject: [PATCH 11/41] Setup dotenv for e2e and e2eDelta builds --- .github/workflows/buildAndroid.yml | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/buildAndroid.yml b/.github/workflows/buildAndroid.yml index 05183d433044..8760b7c0c1ad 100644 --- a/.github/workflows/buildAndroid.yml +++ b/.github/workflows/buildAndroid.yml @@ -80,11 +80,25 @@ jobs: run: echo "VERSION_CODE=$(grep -o 'versionCode\s\+[0-9]\+' android/app/build.gradle | awk '{ print $2 }')" >> "$GITHUB_OUTPUT" - name: Setup DotEnv - if: ${{ inputs.type == 'adhoc' }} + if: ${{ inputs.type != 'release' }} run: | - cp .env.staging .env.adhoc - sed -i 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc - echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.adhoc + if [ '${{ inputs.type == 'adhoc' }}' ]; then + cp .env.staging .env.adhoc + sed -i 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc + echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.adhoc + else + envFile='' + if [ '${{ inputs.type == 'e2e' }}' ]; then + envFile='tests/e2e/.env.e2e' + else + envFile=tests/e2e/.env.e2edelta + fi + echo "EXPENSIFY_PARTNER_NAME=${{ secrets.EXPENSIFY_PARTNER_NAME }}" >> "$envFile" + echo "EXPENSIFY_PARTNER_PASSWORD=${{ secrets.EXPENSIFY_PARTNER_PASSWORD }}" >> "$envFile" + echo "EXPENSIFY_PARTNER_USER_ID=${{ secrets.EXPENSIFY_PARTNER_USER_ID }}" >> "$envFile" + echo "EXPENSIFY_PARTNER_USER_SECRET=${{ secrets.EXPENSIFY_PARTNER_USER_SECRET }}" >> "$envFile" + echo "EXPENSIFY_PARTNER_PASSWORD_EMAIL=${{ secrets.EXPENSIFY_PARTNER_PASSWORD_EMAIL }}" >> "$envFile" + fi - name: Build Android app id: build From 87b7ca1c463fa2a5050ecaa3bf7b2f796a58620c Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 26 Sep 2024 12:00:47 -0700 Subject: [PATCH 12/41] Add artifact-prefix input --- .github/workflows/buildAndroid.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/buildAndroid.yml b/.github/workflows/buildAndroid.yml index 8760b7c0c1ad..ae650a695364 100644 --- a/.github/workflows/buildAndroid.yml +++ b/.github/workflows/buildAndroid.yml @@ -5,12 +5,17 @@ on: inputs: type: description: 'What type of build to run. Must be one of ["release", "adhoc", "e2e", "e2eDelta"]' - required: true type: string + required: true ref: description: Git ref to checkout and build + type: string required: true + artifact-prefix: + description: 'The prefix for build artifact names. This is useful if you need to call multiple builds from the same workflow' type: string + required: false + default: '' outputs: AAB_FILE_NAME: value: ${{ jobs.build.outputs.AAB_FILE_NAME }} @@ -136,7 +141,7 @@ jobs: continue-on-error: true uses: actions/upload-artifact@v4 with: - name: android-artifact-aab + name: ${{ inputs.artifact-prefix }}android-artifact-aab path: ${{ steps.build.outputs.AAB_PATH }} - name: Upload Android APK artifact @@ -144,7 +149,7 @@ jobs: continue-on-error: true uses: actions/upload-artifact@v4 with: - name: android-artifact-apk + name: ${{ inputs.artifact-prefix }}android-artifact-apk path: ${{ steps.build.outputs.APK_PATH }} - name: Upload Android sourcemaps artifact @@ -152,7 +157,7 @@ jobs: continue-on-error: true uses: actions/upload-artifact@v4 with: - name: android-artifact-sourcemaps + name: ${{ inputs.artifact-prefix }}android-artifact-sourcemaps path: ./android/app/build/generated/sourcemaps/react/productionRelease/index.android.bundle.map - name: Announce failure in slack From 5146322425dbb8ff37bf5a1c3d8679d902842145 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 26 Sep 2024 13:06:51 -0700 Subject: [PATCH 13/41] Refactor e2ePerformanceTests to use callable builds --- .github/workflows/buildAndroid.yml | 4 + .github/workflows/e2ePerformanceTests.yml | 151 +++++++++------------- package.json | 6 +- 3 files changed, 67 insertions(+), 94 deletions(-) diff --git a/.github/workflows/buildAndroid.yml b/.github/workflows/buildAndroid.yml index ae650a695364..c20dda9b3fe9 100644 --- a/.github/workflows/buildAndroid.yml +++ b/.github/workflows/buildAndroid.yml @@ -80,6 +80,10 @@ jobs: gpg --batch --yes --decrypt --passphrase="${{ secrets.LARGE_SECRET_PASSPHRASE }}" --output my-upload-key.keystore my-upload-key.keystore.gpg gpg --batch --yes --decrypt --passphrase="${{ secrets.LARGE_SECRET_PASSPHRASE }}" --output android-fastlane-json-key.json android-fastlane-json-key.json.gpg + - name: Get package version + id: getPackageVersion + run: echo "VERSION=$(jq -r .version < package.json)" >> "$GITHUB_OUTPUT" + - name: Get Android native version id: getAndroidVersion run: echo "VERSION_CODE=$(grep -o 'versionCode\s\+[0-9]\+' android/app/build.gradle | awk '{ print $2 }')" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/e2ePerformanceTests.yml b/.github/workflows/e2ePerformanceTests.yml index b9352d406feb..fde2bb401bfb 100644 --- a/.github/workflows/e2ePerformanceTests.yml +++ b/.github/workflows/e2ePerformanceTests.yml @@ -20,13 +20,15 @@ concurrency: cancel-in-progress: true jobs: - buildBaseline: - runs-on: ubuntu-latest-xl - name: Build apk from latest release as a baseline + prep: + runs-on: ubuntu-latest + name: Find the baseline and delta refs, and check for an existing build artifact for that commit outputs: - VERSION: ${{ steps.getMostRecentRelease.outputs.VERSION }} - ARTIFACT_FOUND: ${{ steps.checkForExistingArtifact.outputs.ARTIFACT_FOUND }} - ARTIFACT_WORKFLOW_ID: ${{ steps.checkForExistingArtifact.outputs.ARTIFACT_WORKFLOW_ID }} + BASELINE_ARTIFACT_FOUND: ${{ steps.checkForExistingArtifact.outputs.BASELINE_ARTIFACT_FOUND }} + BASELINE_ARTIFACT_WORKFLOW_ID: ${{ steps.checkForExistingArtifact.outputs.BASELINE_ARTIFACT_WORKFLOW_ID }} + BASELINE_VERSION: ${{ steps.getMostRecentRelease.outputs.VERSION }} + DELTA_REF: ${{ steps.getDeltaRef.outputs.DELTA_REF }} + IS_PR_MERGED: ${{ steps.getPullRequestDetails.outputs.IS_MERGED }} steps: - uses: actions/checkout@v4 with: @@ -44,41 +46,12 @@ jobs: uses: ./.github/actions/javascript/getArtifactInfo with: GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_COMMIT_TOKEN }} - ARTIFACT_NAME: baseline-apk-${{ steps.getMostRecentRelease.outputs.VERSION }} + ARTIFACT_NAME: baseline-${{ steps.getMostRecentRelease.outputs.VERSION }}-android-artifact-apk - name: Skip build if there's already an existing artifact for the baseline - if: ${{ fromJSON(steps.checkForExistingArtifact.outputs.ARTIFACT_FOUND) }} + if: ${{ fromJSON(steps.checkForExistingArtifact.outputs.BASELINE_ARTIFACT_FOUND) }} run: echo 'APK for baseline ${{ steps.getMostRecentRelease.outputs.VERSION }} already exists, reusing existing build' - - name: Checkout "Baseline" commit (last release) - if: ${{ !fromJSON(steps.checkForExistingArtifact.outputs.ARTIFACT_FOUND) }} - run: | - git fetch origin tag ${{ steps.getMostRecentRelease.outputs.VERSION }} --no-tags --depth=1 - git switch --detach ${{ steps.getMostRecentRelease.outputs.VERSION }} - - - uses: Expensify/App/.github/actions/composite/buildAndroidE2EAPK@main - if: ${{ !fromJSON(steps.checkForExistingArtifact.outputs.ARTIFACT_FOUND) }} - with: - ARTIFACT_NAME: baseline-apk-${{ steps.getMostRecentRelease.outputs.VERSION }} - PACKAGE_SCRIPT_NAME: android-build-e2e - APP_OUTPUT_PATH: android/app/build/outputs/apk/e2e/release/app-e2e-release.apk - MAPBOX_SDK_DOWNLOAD_TOKEN: ${{ secrets.MAPBOX_SDK_DOWNLOAD_TOKEN }} - EXPENSIFY_PARTNER_NAME: ${{ secrets.EXPENSIFY_PARTNER_NAME }} - EXPENSIFY_PARTNER_PASSWORD: ${{ secrets.EXPENSIFY_PARTNER_PASSWORD }} - EXPENSIFY_PARTNER_USER_ID: ${{ secrets.EXPENSIFY_PARTNER_USER_ID }} - EXPENSIFY_PARTNER_USER_SECRET: ${{ secrets.EXPENSIFY_PARTNER_USER_SECRET }} - EXPENSIFY_PARTNER_PASSWORD_EMAIL: ${{ secrets.EXPENSIFY_PARTNER_PASSWORD_EMAIL }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} - PATH_ENV_FILE: tests/e2e/.env.e2e - - buildDelta: - runs-on: ubuntu-latest-xl - name: Build apk from delta ref - outputs: - DELTA_REF: ${{ steps.getDeltaRef.outputs.DELTA_REF }} - steps: - - uses: actions/checkout@v4 - - name: Get pull request details id: getPullRequestDetails uses: ./.github/actions/javascript/getPullRequestDetails @@ -87,59 +60,47 @@ jobs: PULL_REQUEST_NUMBER: ${{ inputs.PR_NUMBER }} USER: ${{ github.actor }} - - name: Merged PR - Get merge commit sha for the pull request - if: ${{ fromJSON(steps.getPullRequestDetails.outputs.IS_MERGED) }} - id: getMergeCommitShaIfMergedPR - run: | - MERGE_COMMIT_SHA=${{ steps.getPullRequestDetails.outputs.MERGE_COMMIT_SHA }} - git fetch origin "$MERGE_COMMIT_SHA" --no-tags --depth=1 - echo "MERGE_COMMIT_SHA=$MERGE_COMMIT_SHA" >> "$GITHUB_OUTPUT" - env: - GITHUB_TOKEN: ${{ github.token }} - - - name: Unmerged PR - Fetch head ref of unmerged PR - if: ${{ !fromJSON(steps.getPullRequestDetails.outputs.IS_MERGED) }} - run: | - git fetch origin ${{ steps.getPullRequestDetails.outputs.HEAD_COMMIT_SHA }} --no-tags --depth=1 - - - name: Unmerged PR - Set dummy git credentials before merging - if: ${{ !fromJSON(steps.getPullRequestDetails.outputs.IS_MERGED) }} - run: | - git config --global user.email "test@test.com" - git config --global user.name "Test" - - - name: Unmerged PR - Merge pull request locally and get merge commit sha - if: ${{ !fromJSON(steps.getPullRequestDetails.outputs.IS_MERGED) }} - id: getMergeCommitShaIfUnmergedPR - run: | - git merge --allow-unrelated-histories -X ours --no-commit ${{ steps.getPullRequestDetails.outputs.HEAD_COMMIT_SHA }} - git checkout ${{ steps.getPullRequestDetails.outputs.HEAD_COMMIT_SHA }} - env: - GITHUB_TOKEN: ${{ github.token }} - - name: Determine "delta ref" id: getDeltaRef - run: echo "DELTA_REF=${{ steps.getMergeCommitShaIfMergedPR.outputs.MERGE_COMMIT_SHA || steps.getMergeCommitShaIfUnmergedPR.outputs.MERGE_COMMIT_SHA }}" >> "$GITHUB_OUTPUT" - env: - GITHUB_TOKEN: ${{ github.token }} + run: | + if [ '${{ steps.getPullRequestDetails.outputs.IS_MERGED }}' == 'true' ]; then + echo "DELTA_REF=${{ steps.getPullRequestDetails.outputs.HEAD_COMMIT_SHA }}" >> "$GITHUB_OUTPUT" + else + # Set dummy git credentials + git config --global user.email "test@test.com" + git config --global user.name "Test" + + # Fetch head_ref of unmerged PR + git fetch origin ${{ steps.getPullRequestDetails.outputs.HEAD_COMMIT_SHA }} --no-tags --depth=1 + + # Merge pull request locally and get merge commit sha + git merge --allow-unrelated-histories -X ours --no-commit ${{ steps.getPullRequestDetails.outputs.HEAD_COMMIT_SHA }} + git checkout ${{ steps.getPullRequestDetails.outputs.HEAD_COMMIT_SHA }} + git checkout -b e2eDelta-${{ steps.getPullRequestDetails.outputs.HEAD_COMMIT_SHA }} + git push origin e2eDelta-${{ steps.getPullRequestDetails.outputs.HEAD_COMMIT_SHA }} + echo "DELTA_REF=e2eDelta-${{ steps.getPullRequestDetails.outputs.HEAD_COMMIT_SHA }}" >> "$GITHUB_OUTPUT" + fi - - name: Checkout "delta ref" - run: git checkout ${{ steps.getDeltaRef.outputs.DELTA_REF }} + buildBaseline: + name: Build apk from latest release as a baseline + uses: ./.github/workflows/buildAndroid.yml + needs: prep + if: ${{ fromJSON(needs.prep.outputs.BASELINE_ARTIFACT_FOUND) }} + secrets: inherit + with: + type: e2e + ref: ${{ needs.prep.outputs.BASELINE_VERSION }} + artifact-prefix: baseline-${{ needs.prep.outputs.BASELINE_VERSION }} - - uses: Expensify/App/.github/actions/composite/buildAndroidE2EAPK@main - with: - ARTIFACT_NAME: delta-apk-${{ steps.getDeltaRef.outputs.DELTA_REF }} - ARTIFACT_RETENTION_DAYS: 3 # We don't need to store the delta apk for long, its only really needed for the next job in this workflow - PACKAGE_SCRIPT_NAME: android-build-e2edelta - APP_OUTPUT_PATH: android/app/build/outputs/apk/e2edelta/release/app-e2edelta-release.apk - MAPBOX_SDK_DOWNLOAD_TOKEN: ${{ secrets.MAPBOX_SDK_DOWNLOAD_TOKEN }} - EXPENSIFY_PARTNER_NAME: ${{ secrets.EXPENSIFY_PARTNER_NAME }} - EXPENSIFY_PARTNER_PASSWORD: ${{ secrets.EXPENSIFY_PARTNER_PASSWORD }} - EXPENSIFY_PARTNER_USER_ID: ${{ secrets.EXPENSIFY_PARTNER_USER_ID }} - EXPENSIFY_PARTNER_USER_SECRET: ${{ secrets.EXPENSIFY_PARTNER_USER_SECRET }} - EXPENSIFY_PARTNER_PASSWORD_EMAIL: ${{ secrets.EXPENSIFY_PARTNER_PASSWORD_EMAIL }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} - PATH_ENV_FILE: tests/e2e/.env.e2edelta + buildDelta: + name: Build apk from delta ref + uses: ./.github/workflows/buildAndroid.yml + needs: prep + secrets: inherit + with: + type: e2eDelta + ref: ${{ needs.prep.outputs.DELTA_REF }} + artifact-prefix: delta-${{ needs.prep.outputs.DELTA_REF }} runTestsInAWS: runs-on: ubuntu-latest @@ -161,11 +122,11 @@ jobs: uses: actions/download-artifact@v4 id: downloadBaselineAPK with: - name: baseline-apk-${{ needs.buildBaseline.outputs.VERSION }} + name: baseline-${{ needs.prep.outputs.BASELINE_VERSION }}-android-apk path: zip # Set github-token only if the baseline was built in this workflow run: - github-token: ${{ needs.buildBaseline.outputs.ARTIFACT_WORKFLOW_ID && github.token }} - run-id: ${{ needs.buildBaseline.outputs.ARTIFACT_WORKFLOW_ID }} + github-token: ${{ needs.buildBaseline.outputs.BASELINE_ARTIFACT_WORKFLOW_ID && github.token }} + run-id: ${{ needs.buildBaseline.outputs.BASELINE_ARTIFACT_WORKFLOW_ID }} # The downloaded artifact will be a file named "app-e2e-release.apk" so we have to rename it - name: Rename baseline APK @@ -175,7 +136,7 @@ jobs: uses: actions/download-artifact@v4 id: downloadDeltaAPK with: - name: delta-apk-${{ needs.buildDelta.outputs.DELTA_REF }} + name: delta-${{ needs.prep.outputs.DELTA_REF }}-android-apk path: zip - name: Rename delta APK @@ -289,3 +250,13 @@ jobs: env: GITHUB_TOKEN: ${{ github.token }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + + cleanupDeltaRef: + needs: [prep, runTestsInAWS] + if: ${{ always() && needs.prep.outputs.IS_PR_MERGED != 'true' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Delete temporary merge branch created for delta ref + run: git push -d origin ${{ needs.prep.outputs.DELTA_REF }} diff --git a/package.json b/package.json index a36259ae815c..00fd58aa4f83 100644 --- a/package.json +++ b/package.json @@ -30,10 +30,8 @@ "createDocsRoutes": "ts-node .github/scripts/createDocsRoutes.ts", "detectRedirectCycle": "ts-node .github/scripts/detectRedirectCycle.ts", "desktop-build-adhoc": "./scripts/build-desktop.sh adhoc", - "ios-build": "fastlane ios build_unsigned", - "android-build": "fastlane android build_local", - "android-build-e2e": "bundle exec fastlane android build_e2e", - "android-build-e2edelta": "bundle exec fastlane android build_e2edelta", + "ios-build": "bundle exec fastlane ios build_unsigned", + "android-build": "bundle exec fastlane android build_local", "test": "TZ=utc NODE_OPTIONS=--experimental-vm-modules jest", "typecheck": "NODE_OPTIONS=--max_old_space_size=8192 tsc", "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=0 --cache --cache-location=node_modules/.cache/eslint", From 7e3c9363f1f549380870bd087394653f9da3eaa7 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 26 Sep 2024 13:07:58 -0700 Subject: [PATCH 14/41] Delete now-unused buildAndroidE2EAPK composite action --- .../composite/buildAndroidE2EAPK/action.yml | 102 ------------------ 1 file changed, 102 deletions(-) delete mode 100644 .github/actions/composite/buildAndroidE2EAPK/action.yml diff --git a/.github/actions/composite/buildAndroidE2EAPK/action.yml b/.github/actions/composite/buildAndroidE2EAPK/action.yml deleted file mode 100644 index b86b68cc7d7d..000000000000 --- a/.github/actions/composite/buildAndroidE2EAPK/action.yml +++ /dev/null @@ -1,102 +0,0 @@ -name: Build an Android apk for e2e tests -description: Build an Android apk for an E2E test build and upload it as an artifact - -inputs: - ARTIFACT_NAME: - description: The name of the workflow artifact where the APK should be uploaded - required: true - ARTIFACT_RETENTION_DAYS: - description: The number of days to retain the artifact - required: false - # Thats github default: - default: "90" - PACKAGE_SCRIPT_NAME: - description: The name of the npm script to run to build the APK - required: true - APP_OUTPUT_PATH: - description: The path to the built APK - required: true - MAPBOX_SDK_DOWNLOAD_TOKEN: - description: The token to use to download the MapBox SDK - required: true - PATH_ENV_FILE: - description: The path to the .env file to use for the build - required: true - EXPENSIFY_PARTNER_NAME: - description: The name of the Expensify partner to use for the build - required: true - EXPENSIFY_PARTNER_PASSWORD: - description: The password of the Expensify partner to use for the build - required: true - EXPENSIFY_PARTNER_USER_ID: - description: The user ID of the Expensify partner to use for the build - required: true - EXPENSIFY_PARTNER_USER_SECRET: - description: The user secret of the Expensify partner to use for the build - required: true - EXPENSIFY_PARTNER_PASSWORD_EMAIL: - description: The email address of the Expensify partner to use for the build - required: true - SLACK_WEBHOOK_URL: - description: 'URL of the slack webhook' - required: true - -runs: - using: composite - steps: - - name: Configure MapBox SDK - run: ./scripts/setup-mapbox-sdk.sh ${{ inputs.MAPBOX_SDK_DOWNLOAD_TOKEN }} - shell: bash - - - uses: Expensify/App/.github/actions/composite/setupNode@main - - - name: Setup Java - uses: actions/setup-java@v4 - with: - distribution: "oracle" - java-version: "17" - - - uses: ruby/setup-ruby@v1.190.0 - with: - bundler-cache: true - - - uses: gradle/gradle-build-action@3fbe033aaae657f011f88f29be9e65ed26bd29ef - - - name: Append environment variables to env file - shell: bash - run: | - echo "EXPENSIFY_PARTNER_NAME=${{ inputs.EXPENSIFY_PARTNER_NAME }}" >> ${{ inputs.PATH_ENV_FILE }} - echo "EXPENSIFY_PARTNER_PASSWORD=${{ inputs.EXPENSIFY_PARTNER_PASSWORD }}" >> ${{ inputs.PATH_ENV_FILE }} - echo "EXPENSIFY_PARTNER_USER_ID=${{ inputs.EXPENSIFY_PARTNER_USER_ID }}" >> ${{ inputs.PATH_ENV_FILE }} - echo "EXPENSIFY_PARTNER_USER_SECRET=${{ inputs.EXPENSIFY_PARTNER_USER_SECRET }}" >> ${{ inputs.PATH_ENV_FILE }} - echo "EXPENSIFY_PARTNER_PASSWORD_EMAIL=${{ inputs.EXPENSIFY_PARTNER_PASSWORD_EMAIL }}" >> ${{ inputs.PATH_ENV_FILE }} - - - name: Build APK - run: npm run ${{ inputs.PACKAGE_SCRIPT_NAME }} - shell: bash - env: - RUBYOPT: '-rostruct' - - - name: Announce failed workflow in Slack - if: failure() - uses: 8398a7/action-slack@v3 - with: - status: custom - custom_payload: | - { - channel: '#e2e-announce', - attachments: [{ - color: 'danger', - text: `🚧 ${process.env.AS_REPO} E2E APK build run failed on workflow 🚧`, - }] - } - env: - GITHUB_TOKEN: ${{ github.token }} - SLACK_WEBHOOK_URL: ${{ inputs.SLACK_WEBHOOK_URL }} - - - name: Upload APK - uses: actions/upload-artifact@v4 - with: - name: ${{ inputs.ARTIFACT_NAME }} - path: ${{ inputs.APP_OUTPUT_PATH }} - retention-days: ${{ inputs.ARTIFACT_RETENTION_DAYS }} From 48336e323b664c1186ac75ec35a493e8640e3fcf Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 26 Sep 2024 13:16:15 -0700 Subject: [PATCH 15/41] Use correct variable when checking if all platforms were a success --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0b8235eebb4a..f3d1b52841b1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -491,11 +491,11 @@ jobs: if [ ${{ github.ref }} == 'refs/heads/production' ]; then if [ "${{ needs.submitAndroid.result }}" != "success" ]; then - isAtLeastOnePlatformDeployed="false" + isAllPlatformsDeployed="false" fi else if [ "${{ needs.uploadAndroid.result }}" != "success" ]; then - isAtLeastOnePlatformDeployed="false" + isAllPlatformsDeployed="false" fi fi From 011e8d8babc9248230f7274d70518565473e800d Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 26 Sep 2024 13:18:02 -0700 Subject: [PATCH 16/41] Add better comment for creating branch --- .github/workflows/e2ePerformanceTests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/e2ePerformanceTests.yml b/.github/workflows/e2ePerformanceTests.yml index fde2bb401bfb..8b7160812de1 100644 --- a/.github/workflows/e2ePerformanceTests.yml +++ b/.github/workflows/e2ePerformanceTests.yml @@ -76,6 +76,8 @@ jobs: # Merge pull request locally and get merge commit sha git merge --allow-unrelated-histories -X ours --no-commit ${{ steps.getPullRequestDetails.outputs.HEAD_COMMIT_SHA }} git checkout ${{ steps.getPullRequestDetails.outputs.HEAD_COMMIT_SHA }} + + # Create and push a branch so it can be checked out in another runner git checkout -b e2eDelta-${{ steps.getPullRequestDetails.outputs.HEAD_COMMIT_SHA }} git push origin e2eDelta-${{ steps.getPullRequestDetails.outputs.HEAD_COMMIT_SHA }} echo "DELTA_REF=e2eDelta-${{ steps.getPullRequestDetails.outputs.HEAD_COMMIT_SHA }}" >> "$GITHUB_OUTPUT" From 581c2c63d9c214a5c8b15dca6193b2217c8944a7 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 26 Sep 2024 13:35:43 -0700 Subject: [PATCH 17/41] Fix actionslint --- .github/workflows/buildAndroid.yml | 33 +++++++++++++---------- .github/workflows/deploy.yml | 2 +- .github/workflows/e2ePerformanceTests.yml | 16 +++++------ .github/workflows/testBuild.yml | 1 - 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/.github/workflows/buildAndroid.yml b/.github/workflows/buildAndroid.yml index c20dda9b3fe9..37f5594c9839 100644 --- a/.github/workflows/buildAndroid.yml +++ b/.github/workflows/buildAndroid.yml @@ -91,22 +91,24 @@ jobs: - name: Setup DotEnv if: ${{ inputs.type != 'release' }} run: | - if [ '${{ inputs.type == 'adhoc' }}' ]; then + if [ '${{ inputs.type }}' == 'adhoc' ]; then cp .env.staging .env.adhoc sed -i 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.adhoc else envFile='' - if [ '${{ inputs.type == 'e2e' }}' ]; then + if [ '${{ inputs.type }}' == 'e2e' ]; then envFile='tests/e2e/.env.e2e' else envFile=tests/e2e/.env.e2edelta fi - echo "EXPENSIFY_PARTNER_NAME=${{ secrets.EXPENSIFY_PARTNER_NAME }}" >> "$envFile" - echo "EXPENSIFY_PARTNER_PASSWORD=${{ secrets.EXPENSIFY_PARTNER_PASSWORD }}" >> "$envFile" - echo "EXPENSIFY_PARTNER_USER_ID=${{ secrets.EXPENSIFY_PARTNER_USER_ID }}" >> "$envFile" - echo "EXPENSIFY_PARTNER_USER_SECRET=${{ secrets.EXPENSIFY_PARTNER_USER_SECRET }}" >> "$envFile" - echo "EXPENSIFY_PARTNER_PASSWORD_EMAIL=${{ secrets.EXPENSIFY_PARTNER_PASSWORD_EMAIL }}" >> "$envFile" + { + echo "EXPENSIFY_PARTNER_NAME=${{ secrets.EXPENSIFY_PARTNER_NAME }}" + echo "EXPENSIFY_PARTNER_PASSWORD=${{ secrets.EXPENSIFY_PARTNER_PASSWORD }}" + echo "EXPENSIFY_PARTNER_USER_ID=${{ secrets.EXPENSIFY_PARTNER_USER_ID }}" + echo "EXPENSIFY_PARTNER_USER_SECRET=${{ secrets.EXPENSIFY_PARTNER_USER_SECRET }}" + echo "EXPENSIFY_PARTNER_PASSWORD_EMAIL=${{ secrets.EXPENSIFY_PARTNER_PASSWORD_EMAIL }}" + } >> "$envFile" fi - name: Build Android app @@ -125,17 +127,20 @@ jobs: esac bundle exec fastlane android "$lane" - # aabPath and apkPath are environment varibles set within the Fastfile - echo "AAB_PATH=$aabPath" >> "$GITHUB_OUTPUT" - echo "AAB_FILE_NAME=$(basename "$aabPath")" >> "$GITHUB_OUTPUT" - echo "APK_PATH=$apkPath" >> "$GITHUB_OUTPUT" - echo "APK_FILE_NAME=$(basename "$apkPath")" >> "$GITHUB_OUTPUT" - SHOULD_UPLOAD_SOURCEMAPS='false' if [ -f ./android/app/build/generated/sourcemaps/react/productionRelease/index.android.bundle.map ]; then SHOULD_UPLOAD_SOURCEMAPS='true' fi - echo "SHOULD_UPLOAD_SOURCEMAPS=$SHOULD_UPLOAD_SOURCEMAPS" >> "$GITHUB_OUTPUT" + + { + # aabPath and apkPath are environment varibles set within the Fastfile + echo "AAB_PATH=$aabPath" + echo "AAB_FILE_NAME=$(basename "$aabPath")" + echo "APK_PATH=$apkPath" + echo "APK_FILE_NAME=$(basename "$apkPath")" + echo "SHOULD_UPLOAD_SOURCEMAPS=$SHOULD_UPLOAD_SOURCEMAPS" + } >> "$GITHUB_OUTPUT" + env: MYAPP_UPLOAD_STORE_PASSWORD: ${{ secrets.MYAPP_UPLOAD_STORE_PASSWORD }} MYAPP_UPLOAD_KEY_PASSWORD: ${{ secrets.MYAPP_UPLOAD_KEY_PASSWORD }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f3d1b52841b1..d0e45f1462b4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -672,7 +672,7 @@ jobs: with: version: ${{ needs.prep.outputs.APP_VERSION }} env: ${{ github.ref == 'refs/heads/production' && 'production' || 'staging' }} - android: ${{ needs.android.result }} + android: ${{ github.ref == 'refs/heads/production' && needs.submitAndroid.result || needs.uploadAndroid.result }} ios: ${{ needs.iOS.result }} web: ${{ needs.web.result }} desktop: ${{ needs.desktop.result }} diff --git a/.github/workflows/e2ePerformanceTests.yml b/.github/workflows/e2ePerformanceTests.yml index 8b7160812de1..82c6425361ce 100644 --- a/.github/workflows/e2ePerformanceTests.yml +++ b/.github/workflows/e2ePerformanceTests.yml @@ -24,8 +24,8 @@ jobs: runs-on: ubuntu-latest name: Find the baseline and delta refs, and check for an existing build artifact for that commit outputs: - BASELINE_ARTIFACT_FOUND: ${{ steps.checkForExistingArtifact.outputs.BASELINE_ARTIFACT_FOUND }} - BASELINE_ARTIFACT_WORKFLOW_ID: ${{ steps.checkForExistingArtifact.outputs.BASELINE_ARTIFACT_WORKFLOW_ID }} + BASELINE_ARTIFACT_FOUND: ${{ steps.checkForExistingArtifact.outputs.ARTIFACT_FOUND }} + BASELINE_ARTIFACT_WORKFLOW_ID: ${{ steps.checkForExistingArtifact.outputs.ARTIFACT_WORKFLOW_ID }} BASELINE_VERSION: ${{ steps.getMostRecentRelease.outputs.VERSION }} DELTA_REF: ${{ steps.getDeltaRef.outputs.DELTA_REF }} IS_PR_MERGED: ${{ steps.getPullRequestDetails.outputs.IS_MERGED }} @@ -49,7 +49,7 @@ jobs: ARTIFACT_NAME: baseline-${{ steps.getMostRecentRelease.outputs.VERSION }}-android-artifact-apk - name: Skip build if there's already an existing artifact for the baseline - if: ${{ fromJSON(steps.checkForExistingArtifact.outputs.BASELINE_ARTIFACT_FOUND) }} + if: ${{ fromJSON(steps.checkForExistingArtifact.outputs.ARTIFACT_FOUND) }} run: echo 'APK for baseline ${{ steps.getMostRecentRelease.outputs.VERSION }} already exists, reusing existing build' - name: Get pull request details @@ -106,7 +106,7 @@ jobs: runTestsInAWS: runs-on: ubuntu-latest - needs: [buildBaseline, buildDelta] + needs: [prep, buildBaseline, buildDelta] name: Run E2E tests in AWS device farm steps: - uses: actions/checkout@v4 @@ -127,12 +127,12 @@ jobs: name: baseline-${{ needs.prep.outputs.BASELINE_VERSION }}-android-apk path: zip # Set github-token only if the baseline was built in this workflow run: - github-token: ${{ needs.buildBaseline.outputs.BASELINE_ARTIFACT_WORKFLOW_ID && github.token }} - run-id: ${{ needs.buildBaseline.outputs.BASELINE_ARTIFACT_WORKFLOW_ID }} + github-token: ${{ needs.prep.outputs.BASELINE_ARTIFACT_WORKFLOW_ID && github.token }} + run-id: ${{ needs.prep.outputs.BASELINE_ARTIFACT_WORKFLOW_ID }} # The downloaded artifact will be a file named "app-e2e-release.apk" so we have to rename it - name: Rename baseline APK - run: mv "${{steps.downloadBaselineAPK.outputs.download-path}}/app-e2e-release.apk" "${{steps.downloadBaselineAPK.outputs.download-path}}/app-e2eRelease.apk" + run: mv "${{ steps.downloadBaselineAPK.outputs.download-path }}/app-e2e-release.apk" "${{ steps.downloadBaselineAPK.outputs.download-path }}/app-e2eRelease.apk" - name: Download delta APK uses: actions/download-artifact@v4 @@ -142,7 +142,7 @@ jobs: path: zip - name: Rename delta APK - run: mv "${{steps.downloadDeltaAPK.outputs.download-path}}/app-e2edelta-release.apk" "${{steps.downloadDeltaAPK.outputs.download-path}}/app-e2edeltaRelease.apk" + run: mv "${{ steps.downloadDeltaAPK.outputs.download-path }}/app-e2edelta-release.apk" "${{ steps.downloadDeltaAPK.outputs.download-path }}/app-e2edeltaRelease.apk" - name: Compile test runner to be executable in a nodeJS environment run: npm run e2e-test-runner-build diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index 180b8bcdc3ec..ea0bdbb2c531 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -65,7 +65,6 @@ jobs: uses: ./.github/workflows/buildAndroid.yml if: ${{ fromJSON(needs.validateActor.outputs.READY_TO_BUILD) }} needs: [validateActor, getBranchRef] - id: buildAndroid secrets: inherit with: type: adhoc From 01ed4b183bceaa52f9122e5dacb005e316b26e3f Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 26 Sep 2024 14:48:44 -0700 Subject: [PATCH 18/41] echo debug paths --- .github/workflows/buildAndroid.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/buildAndroid.yml b/.github/workflows/buildAndroid.yml index 37f5594c9839..2727a9beba13 100644 --- a/.github/workflows/buildAndroid.yml +++ b/.github/workflows/buildAndroid.yml @@ -132,6 +132,12 @@ jobs: SHOULD_UPLOAD_SOURCEMAPS='true' fi + echo "AAB_PATH=$aabPath" + echo "AAB_FILE_NAME=$(basename "$aabPath")" + echo "APK_PATH=$apkPath" + echo "APK_FILE_NAME=$(basename "$apkPath")" + echo "SHOULD_UPLOAD_SOURCEMAPS=$SHOULD_UPLOAD_SOURCEMAPS" + { # aabPath and apkPath are environment varibles set within the Fastfile echo "AAB_PATH=$aabPath" From ed66629f9457a437b52041833aee9450a81092cc Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 26 Sep 2024 14:53:47 -0700 Subject: [PATCH 19/41] Fix android e2eDelta lane name --- fastlane/Fastfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 409de4d5258a..7dd6522b5861 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -104,7 +104,7 @@ platform :android do setGradleOutputsInEnv() end - lane :build_e2edelta do + lane :build_e2eDelta dog ENV["ENVFILE"]="tests/e2e/.env.e2edelta" ENV["ENTRY_FILE"]="src/libs/E2E/reactNativeLaunchingTest.ts" ENV["E2E_TESTING"]="true" From 1ec65557a7821a1d739c1ed154ffbae4dec59c71 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 26 Sep 2024 14:56:22 -0700 Subject: [PATCH 20/41] Fix typo --- fastlane/Fastfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 7dd6522b5861..554b529389d5 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -104,7 +104,7 @@ platform :android do setGradleOutputsInEnv() end - lane :build_e2eDelta dog + lane :build_e2eDelta ENV["ENVFILE"]="tests/e2e/.env.e2edelta" ENV["ENTRY_FILE"]="src/libs/E2E/reactNativeLaunchingTest.ts" ENV["E2E_TESTING"]="true" From 25c54ac8f674bf0a538a5f0daa4f517226a8d253 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 26 Sep 2024 15:00:04 -0700 Subject: [PATCH 21/41] Add back missing do --- fastlane/Fastfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 554b529389d5..956ba5de5dc7 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -104,7 +104,7 @@ platform :android do setGradleOutputsInEnv() end - lane :build_e2eDelta + lane :build_e2eDelta do ENV["ENVFILE"]="tests/e2e/.env.e2edelta" ENV["ENTRY_FILE"]="src/libs/E2E/reactNativeLaunchingTest.ts" ENV["E2E_TESTING"]="true" From 45a589d2e86cbe7c857933408d1a7dfff811156d Mon Sep 17 00:00:00 2001 From: rory Date: Mon, 30 Sep 2024 19:10:53 -0700 Subject: [PATCH 22/41] Source GITHUB_ENV before trying to access env vars set in fastlane in the same step --- .github/workflows/buildAndroid.yml | 3 +++ fastlane/Fastfile | 12 ++---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/buildAndroid.yml b/.github/workflows/buildAndroid.yml index 2727a9beba13..1c54435a4f21 100644 --- a/.github/workflows/buildAndroid.yml +++ b/.github/workflows/buildAndroid.yml @@ -127,6 +127,9 @@ jobs: esac bundle exec fastlane android "$lane" + # Reload environment variables from GITHUB_ENV + source "$GITHUB_ENV" + SHOULD_UPLOAD_SOURCEMAPS='false' if [ -f ./android/app/build/generated/sourcemaps/react/productionRelease/index.android.bundle.map ]; then SHOULD_UPLOAD_SOURCEMAPS='true' diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 956ba5de5dc7..25d365198943 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -22,9 +22,8 @@ KEY_DSYM_PATH = "dsymPath" KEY_S3_APK_PATH = "s3APKPath" KEY_S3_HTML_PATH = "s3HtmlPath" -# Export environment variables in the parent shell. -# In a GitHub Actions environment, it will save the environment variables in the GITHUB_ENV file. -# In any other environment, it will save them to the current shell environment using the `export` command. +# Export environment variables to GITHUB_ENV +# If there's no GITHUB_ENV file set in the env, then this is a no-op def exportEnvVars(env_vars) github_env_path = ENV['GITHUB_ENV'] if github_env_path && File.exist?(github_env_path) @@ -35,13 +34,6 @@ def exportEnvVars(env_vars) file.puts "#{key}=#{value}" end end - else - puts "Saving environment variables in parent shell..." - env_vars.each do |key, value| - puts "#{key}=#{value}" - command = "export #{key}=#{value}" - system(command) - end end end From 3cae22f1ce516d6505967413f128cba897526360 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 1 Oct 2024 09:37:36 -0700 Subject: [PATCH 23/41] fix artifact paths --- .github/workflows/deploy.yml | 12 ++++++------ .github/workflows/testBuild.yml | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f79e6f2e00c8..7905e7d2acb7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -96,20 +96,20 @@ jobs: - name: Download Android build artifacts uses: actions/download-artifact@v4 with: - path: /etc/usr/artifacts + path: /tmp/artifacts pattern: android-artifact-* merge-multiple: true - name: Log downloaded artifact paths - run: ls -R /etc/usr/artifacts + run: ls -R /tmp/artifacts - name: Upload Android app to Google Play run: bundle exec fastlane android upload_google_play_internal env: - aabPath: /etc/usr/artifacts/android-artifact-aab/${{ needs.buildAndroid.outputs.AAB_FILE_NAME }} + aabPath: /tmp/artifacts/android-artifact-aab/${{ needs.buildAndroid.outputs.AAB_FILE_NAME }} - name: Upload Android build to Browser Stack - run: curl -u "$BROWSERSTACK" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@/etc/usr/artifacts/android-artifact-aab/${{ needs.buildAndroid.outputs.AAB_FILE_NAME }}" + run: curl -u "$BROWSERSTACK" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@/tmp/artifacts/android-artifact-aab/${{ needs.buildAndroid.outputs.AAB_FILE_NAME }}" env: BROWSERSTACK: ${{ secrets.BROWSERSTACK }} @@ -136,12 +136,12 @@ jobs: - name: Download Android build artifacts uses: actions/download-artifact@v4 with: - path: /etc/usr/artifacts + path: /tmp/artifacts pattern: android-artifact-* merge-multiple: true - name: Log downloaded artifact paths - run: ls -R /etc/usr/artifacts + run: ls -R /tmp/artifacts - name: Submit Android build for review run: bundle exec fastlane android upload_google_play_production diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index ea0bdbb2c531..b2539f8e47da 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -83,12 +83,12 @@ jobs: - name: Download Android build artifacts uses: actions/download-artifact@v4 with: - path: /etc/usr/artifacts + path: /tmp/artifacts pattern: android-artifact-* merge-multiple: true - name: Log downloaded artifact paths - run: ls -R /etc/usr/artifacts + run: ls -R /tmp/artifacts - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4 @@ -100,6 +100,7 @@ jobs: - name: Upload AdHoc build to S3 run: bundle exec fastlane android upload_s3 env: + apkPath: /tmp/artifacts/android-artifact-apk/${{ needs.buildAndroid.outputs.APK_FILE_NAME }} S3_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} S3_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} S3_BUCKET: ad-hoc-expensify-cash From 7b73ba5400abc97f65eb1a703b1e29c9bb4bbcc8 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 1 Oct 2024 11:57:12 -0700 Subject: [PATCH 24/41] Add missing setup-ruby step --- .github/workflows/testBuild.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index b2539f8e47da..f55a1b837411 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -80,6 +80,11 @@ jobs: S3_APK_PATH: ${{ steps.exportS3Paths.outputs.S3_APK_PATH }} S3_HTML_PATH: ${{ steps.exportS3Paths.outputs.S3_HTML_PATH }} steps: + - name: Setup Ruby + uses: ruby/setup-ruby@v1.190.0 + with: + bundler-cache: true + - name: Download Android build artifacts uses: actions/download-artifact@v4 with: From 5a4a7343e4e31e10dc3438742cd74e75f5a15131 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 1 Oct 2024 13:54:48 -0700 Subject: [PATCH 25/41] Add missing checkout --- .github/workflows/testBuild.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index f55a1b837411..1b5c52136ae8 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -80,6 +80,9 @@ jobs: S3_APK_PATH: ${{ steps.exportS3Paths.outputs.S3_APK_PATH }} S3_HTML_PATH: ${{ steps.exportS3Paths.outputs.S3_HTML_PATH }} steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Ruby uses: ruby/setup-ruby@v1.190.0 with: From bedb860bb61aaf43203e27a7cd2c68ca86e5d230 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 1 Oct 2024 21:51:15 -0700 Subject: [PATCH 26/41] Add missing env var for upload prod --- .github/workflows/deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7905e7d2acb7..0fd9c5a718bd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -145,6 +145,8 @@ jobs: - name: Submit Android build for review run: bundle exec fastlane android upload_google_play_production + env: + VERSION: ${{ steps.getAndroidVersion.outputs.VERSION_CODE }} - name: Warn deployers if Android production deploy failed if: ${{ failure() }} From ab797cd0a60879f3e572ceb6c9511b1fd98a6634 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 1 Oct 2024 21:52:36 -0700 Subject: [PATCH 27/41] Fix downloaded artifact paths --- .github/workflows/deploy.yml | 4 ++-- .github/workflows/testBuild.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0fd9c5a718bd..2a4b4871f776 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -106,10 +106,10 @@ jobs: - name: Upload Android app to Google Play run: bundle exec fastlane android upload_google_play_internal env: - aabPath: /tmp/artifacts/android-artifact-aab/${{ needs.buildAndroid.outputs.AAB_FILE_NAME }} + aabPath: /tmp/artifacts/${{ needs.buildAndroid.outputs.AAB_FILE_NAME }} - name: Upload Android build to Browser Stack - run: curl -u "$BROWSERSTACK" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@/tmp/artifacts/android-artifact-aab/${{ needs.buildAndroid.outputs.AAB_FILE_NAME }}" + run: curl -u "$BROWSERSTACK" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@/tmp/artifacts/${{ needs.buildAndroid.outputs.AAB_FILE_NAME }}" env: BROWSERSTACK: ${{ secrets.BROWSERSTACK }} diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index 1b5c52136ae8..8d23082edbbd 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -108,7 +108,7 @@ jobs: - name: Upload AdHoc build to S3 run: bundle exec fastlane android upload_s3 env: - apkPath: /tmp/artifacts/android-artifact-apk/${{ needs.buildAndroid.outputs.APK_FILE_NAME }} + apkPath: /tmp/artifacts/${{ needs.buildAndroid.outputs.APK_FILE_NAME }} S3_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} S3_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} S3_BUCKET: ad-hoc-expensify-cash From eb969cc24cdbcb7fd8960e2288695ea9ac756fc3 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 1 Oct 2024 22:35:22 -0700 Subject: [PATCH 28/41] Remove some redundant debug logs --- .github/workflows/buildAndroid.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/buildAndroid.yml b/.github/workflows/buildAndroid.yml index 1c54435a4f21..bd00ed5a15e5 100644 --- a/.github/workflows/buildAndroid.yml +++ b/.github/workflows/buildAndroid.yml @@ -135,12 +135,6 @@ jobs: SHOULD_UPLOAD_SOURCEMAPS='true' fi - echo "AAB_PATH=$aabPath" - echo "AAB_FILE_NAME=$(basename "$aabPath")" - echo "APK_PATH=$apkPath" - echo "APK_FILE_NAME=$(basename "$apkPath")" - echo "SHOULD_UPLOAD_SOURCEMAPS=$SHOULD_UPLOAD_SOURCEMAPS" - { # aabPath and apkPath are environment varibles set within the Fastfile echo "AAB_PATH=$aabPath" From feced846ee49cd78e57c7ad8cba95a47dfd9cd35 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 1 Oct 2024 22:37:09 -0700 Subject: [PATCH 29/41] Remove unnecessary artifact download step --- .github/workflows/deploy.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2a4b4871f776..26ee7ffb56e3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -133,16 +133,6 @@ jobs: id: getAndroidVersion run: echo "VERSION_CODE=$(grep -o 'versionCode\s\+[0-9]\+' android/app/build.gradle | awk '{ print $2 }')" >> "$GITHUB_OUTPUT" - - name: Download Android build artifacts - uses: actions/download-artifact@v4 - with: - path: /tmp/artifacts - pattern: android-artifact-* - merge-multiple: true - - - name: Log downloaded artifact paths - run: ls -R /tmp/artifacts - - name: Submit Android build for review run: bundle exec fastlane android upload_google_play_production env: From 50e101983b24e05d2060653ef0984b891155f6de Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 1 Oct 2024 22:39:33 -0700 Subject: [PATCH 30/41] Improve grammar in step id name --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 26ee7ffb56e3..d15e543e890c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -433,7 +433,7 @@ jobs: runs-on: ubuntu-latest outputs: IS_AT_LEAST_ONE_PLATFORM_DEPLOYED: ${{ steps.checkDeploymentSuccessOnAtLeastOnePlatform.outputs.IS_AT_LEAST_ONE_PLATFORM_DEPLOYED }} - IS_ALL_PLATFORMS_DEPLOYED: ${{ steps.checkDeploymentSuccessOnAtLeastAllPlatform.outputs.IS_ALL_PLATFORMS_DEPLOYED }} + IS_ALL_PLATFORMS_DEPLOYED: ${{ steps.checkDeploymentSuccessOnAllPlatforms.outputs.IS_ALL_PLATFORMS_DEPLOYED }} needs: [buildAndroid, uploadAndroid, submitAndroid, desktop, iOS, web] if: ${{ always() }} steps: @@ -460,7 +460,7 @@ jobs: echo "IS_AT_LEAST_ONE_PLATFORM_DEPLOYED is $isAtLeastOnePlatformDeployed" - name: Check deployment success on all platforms - id: checkDeploymentSuccessOnAtLeastAllPlatform + id: checkDeploymentSuccessOnAllPlatforms run: | isAllPlatformsDeployed="false" if [ "${{ needs.iOS.result }}" == "success" ] && \ From 2d78d20542e8958de70bb6bc3753d0c5995ad5b0 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 1 Oct 2024 22:42:47 -0700 Subject: [PATCH 31/41] Always run tests in AWS --- .github/workflows/e2ePerformanceTests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/e2ePerformanceTests.yml b/.github/workflows/e2ePerformanceTests.yml index 82c6425361ce..40f6ad2f6f6a 100644 --- a/.github/workflows/e2ePerformanceTests.yml +++ b/.github/workflows/e2ePerformanceTests.yml @@ -107,6 +107,7 @@ jobs: runTestsInAWS: runs-on: ubuntu-latest needs: [prep, buildBaseline, buildDelta] + if: ${{ always() }} name: Run E2E tests in AWS device farm steps: - uses: actions/checkout@v4 From ff0e6ba1f3f2a73b0648bdfbeac60986291706fe Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 1 Oct 2024 22:46:55 -0700 Subject: [PATCH 32/41] Disable shellcheck warning on source --- .github/workflows/buildAndroid.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/buildAndroid.yml b/.github/workflows/buildAndroid.yml index bd00ed5a15e5..1322c86de25b 100644 --- a/.github/workflows/buildAndroid.yml +++ b/.github/workflows/buildAndroid.yml @@ -128,6 +128,7 @@ jobs: bundle exec fastlane android "$lane" # Reload environment variables from GITHUB_ENV + # shellcheck disable=SC1090 source "$GITHUB_ENV" SHOULD_UPLOAD_SOURCEMAPS='false' From c283f7cec769bf1485134846b83bbbd111596b71 Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 2 Oct 2024 12:07:49 -0700 Subject: [PATCH 33/41] Fix artifact name in e2e download-artifact --- .github/workflows/buildAndroid.yml | 1 - .github/workflows/e2ePerformanceTests.yml | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/buildAndroid.yml b/.github/workflows/buildAndroid.yml index 1322c86de25b..091b88a59d94 100644 --- a/.github/workflows/buildAndroid.yml +++ b/.github/workflows/buildAndroid.yml @@ -144,7 +144,6 @@ jobs: echo "APK_FILE_NAME=$(basename "$apkPath")" echo "SHOULD_UPLOAD_SOURCEMAPS=$SHOULD_UPLOAD_SOURCEMAPS" } >> "$GITHUB_OUTPUT" - env: MYAPP_UPLOAD_STORE_PASSWORD: ${{ secrets.MYAPP_UPLOAD_STORE_PASSWORD }} MYAPP_UPLOAD_KEY_PASSWORD: ${{ secrets.MYAPP_UPLOAD_KEY_PASSWORD }} diff --git a/.github/workflows/e2ePerformanceTests.yml b/.github/workflows/e2ePerformanceTests.yml index 40f6ad2f6f6a..2415eeebe6be 100644 --- a/.github/workflows/e2ePerformanceTests.yml +++ b/.github/workflows/e2ePerformanceTests.yml @@ -125,7 +125,7 @@ jobs: uses: actions/download-artifact@v4 id: downloadBaselineAPK with: - name: baseline-${{ needs.prep.outputs.BASELINE_VERSION }}-android-apk + name: baseline-${{ needs.prep.outputs.BASELINE_VERSION }}-android-artifact-apk path: zip # Set github-token only if the baseline was built in this workflow run: github-token: ${{ needs.prep.outputs.BASELINE_ARTIFACT_WORKFLOW_ID && github.token }} @@ -139,7 +139,7 @@ jobs: uses: actions/download-artifact@v4 id: downloadDeltaAPK with: - name: delta-${{ needs.prep.outputs.DELTA_REF }}-android-apk + name: delta-${{ needs.prep.outputs.DELTA_REF }}-android-artifact-apk path: zip - name: Rename delta APK From 4097a1241d55617cd2c4ff747a7063ff4116fad0 Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 2 Oct 2024 12:57:23 -0700 Subject: [PATCH 34/41] Invert skip condition for building the baseline artifact --- .github/workflows/e2ePerformanceTests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2ePerformanceTests.yml b/.github/workflows/e2ePerformanceTests.yml index 2415eeebe6be..f88e841617bb 100644 --- a/.github/workflows/e2ePerformanceTests.yml +++ b/.github/workflows/e2ePerformanceTests.yml @@ -87,7 +87,7 @@ jobs: name: Build apk from latest release as a baseline uses: ./.github/workflows/buildAndroid.yml needs: prep - if: ${{ fromJSON(needs.prep.outputs.BASELINE_ARTIFACT_FOUND) }} + if: ${{ !fromJSON(needs.prep.outputs.BASELINE_ARTIFACT_FOUND) }} secrets: inherit with: type: e2e From 660020dddab79e695bd37961d544607721abc8aa Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 2 Oct 2024 16:19:21 -0700 Subject: [PATCH 35/41] Remove unnecessary if statement --- .github/workflows/deploy.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d15e543e890c..60bb97b0c2e7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -79,7 +79,6 @@ jobs: uploadAndroid: name: Upload Android build to Google Play Store - if: ${{ github.ref == 'refs/heads/staging' }} needs: buildAndroid runs-on: ubuntu-latest env: From 342f861b0f659a49749d78ee727f34bf7362752a Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 2 Oct 2024 16:51:26 -0700 Subject: [PATCH 36/41] Consolidate S3 paths --- .github/workflows/testBuild.yml | 6 ++---- fastlane/Fastfile | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index 8d23082edbbd..e844c137400a 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -78,7 +78,6 @@ jobs: RUBYOPT: '-rostruct' outputs: S3_APK_PATH: ${{ steps.exportS3Paths.outputs.S3_APK_PATH }} - S3_HTML_PATH: ${{ steps.exportS3Paths.outputs.S3_HTML_PATH }} steps: - name: Checkout uses: actions/checkout@v4 @@ -117,9 +116,8 @@ jobs: - name: Export S3 paths id: exportS3Paths run: | - # $s3APKPath and $s3HtmlPath are from within the Fastfile, android upload_s3 lane + # $s3APKPath is set from within the Fastfile, android upload_s3 lane echo "S3_APK_PATH=$s3APKPath" >> "$GITHUB_OUTPUT" - echo "S3_HTML_PATH=$s3HtmlPath" >> "$GITHUB_OUTPUT" iOS: name: Build and deploy iOS for testing @@ -326,7 +324,7 @@ jobs: DESKTOP: ${{ needs.desktop.result }} IOS: ${{ needs.iOS.result }} WEB: ${{ needs.web.result }} - ANDROID_LINK: ${{ needs.uploadAndroid.outputs.S3_HTML_PATH }} + ANDROID_LINK: ${{ needs.uploadAndroid.outputs.S3_APK_PATH }} DESKTOP_LINK: https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/${{ env.PULL_REQUEST_NUMBER }}/NewExpensify.dmg IOS_LINK: ${{ steps.get_ios_path.outputs.ios_path }} WEB_LINK: https://${{ env.PULL_REQUEST_NUMBER }}.pr-testing.expensify.com diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 25d365198943..eed84acdc916 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -16,11 +16,10 @@ skip_docs opt_out_usage KEY_GRADLE_APK_PATH = "apkPath" +KEY_S3_APK_PATH = "s3APKPath" KEY_GRADLE_AAB_PATH = "aabPath" KEY_IPA_PATH = "ipaPath" KEY_DSYM_PATH = "dsymPath" -KEY_S3_APK_PATH = "s3APKPath" -KEY_S3_HTML_PATH = "s3HtmlPath" # Export environment variables to GITHUB_ENV # If there's no GITHUB_ENV file set in the env, then this is a no-op @@ -135,8 +134,7 @@ platform :android do ) puts "Saving S3 outputs in env..." exportEnvVars({ - KEY_S3_APK_PATH => lane_context[SharedValues::S3_APK_OUTPUT_PATH], - KEY_S3_HTML_PATH => lane_context[SharedValues::S3_HTML_OUTPUT_PATH], + KEY_S3_APK_PATH => lane_context[SharedValues::S3_HTML_OUTPUT_PATH], }) end From f2c9d7fa32d0045241704e4b9d5017946b244bd5 Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 2 Oct 2024 17:00:06 -0700 Subject: [PATCH 37/41] exportS3Path singular --- .github/workflows/testBuild.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index e844c137400a..3847eaed6fd1 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -77,7 +77,7 @@ jobs: env: RUBYOPT: '-rostruct' outputs: - S3_APK_PATH: ${{ steps.exportS3Paths.outputs.S3_APK_PATH }} + S3_APK_PATH: ${{ steps.exportS3Path.outputs.S3_APK_PATH }} steps: - name: Checkout uses: actions/checkout@v4 @@ -114,7 +114,7 @@ jobs: S3_REGION: us-east-1 - name: Export S3 paths - id: exportS3Paths + id: exportS3Path run: | # $s3APKPath is set from within the Fastfile, android upload_s3 lane echo "S3_APK_PATH=$s3APKPath" >> "$GITHUB_OUTPUT" From 9f6280a606ce30ed919ac8eef6528f5c2133df6e Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 2 Oct 2024 17:36:27 -0700 Subject: [PATCH 38/41] Provide pull_request_number to AdHoc builds --- .github/workflows/buildAndroid.yml | 11 ++++++++++- .github/workflows/testBuild.yml | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/buildAndroid.yml b/.github/workflows/buildAndroid.yml index 091b88a59d94..582cb05256fa 100644 --- a/.github/workflows/buildAndroid.yml +++ b/.github/workflows/buildAndroid.yml @@ -16,6 +16,10 @@ on: type: string required: false default: '' + pull_request_number: + description: The pull request number associated with this build, if relevant. + type: number + required: false outputs: AAB_FILE_NAME: value: ${{ jobs.build.outputs.AAB_FILE_NAME }} @@ -38,6 +42,11 @@ on: required: true type: string + pull_request_number: + description: The pull request number associated with this build, if relevant. + type: number + required: false + jobs: build: name: Build Android app @@ -94,7 +103,7 @@ jobs: if [ '${{ inputs.type }}' == 'adhoc' ]; then cp .env.staging .env.adhoc sed -i 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc - echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.adhoc + echo "PULL_REQUEST_NUMBER=${{ inputs.pull_request_number }}" >> .env.adhoc else envFile='' if [ '${{ inputs.type }}' == 'e2e' ]; then diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index 3847eaed6fd1..0a28d155f760 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -69,6 +69,7 @@ jobs: with: type: adhoc ref: ${{ github.event.pull_request.head.sha || needs.getBranchRef.outputs.REF }} + pull_request_number: ${{ env.PULL_REQUEST_NUMBER }} uploadAndroid: name: Upload Android app to S3 From 74420b64246c723c418ba1616b6cac5d40be695e Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 2 Oct 2024 17:56:28 -0700 Subject: [PATCH 39/41] Make it type: string to make lint happy --- .github/workflows/buildAndroid.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildAndroid.yml b/.github/workflows/buildAndroid.yml index 582cb05256fa..114c42d407e2 100644 --- a/.github/workflows/buildAndroid.yml +++ b/.github/workflows/buildAndroid.yml @@ -18,7 +18,7 @@ on: default: '' pull_request_number: description: The pull request number associated with this build, if relevant. - type: number + type: string required: false outputs: AAB_FILE_NAME: From 5a4d56d29c07a5c182be50a23b0d028a1a2f674d Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 2 Oct 2024 18:16:57 -0700 Subject: [PATCH 40/41] Don't access env where it's not available --- .github/workflows/testBuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index 0a28d155f760..672d468ed3b1 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -69,7 +69,7 @@ jobs: with: type: adhoc ref: ${{ github.event.pull_request.head.sha || needs.getBranchRef.outputs.REF }} - pull_request_number: ${{ env.PULL_REQUEST_NUMBER }} + pull_request_number: ${{ github.event.number || github.event.inputs.PULL_REQUEST_NUMBER }} uploadAndroid: name: Upload Android app to S3 From 4e452c82bc870b70c1305507c810b856a457f807 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 3 Oct 2024 12:02:16 -0700 Subject: [PATCH 41/41] Improve comment --- .github/workflows/buildAndroid.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildAndroid.yml b/.github/workflows/buildAndroid.yml index 114c42d407e2..a8023aebd359 100644 --- a/.github/workflows/buildAndroid.yml +++ b/.github/workflows/buildAndroid.yml @@ -136,7 +136,7 @@ jobs: esac bundle exec fastlane android "$lane" - # Reload environment variables from GITHUB_ENV + # Refresh environment variables from GITHUB_ENV that are updated when running fastlane # shellcheck disable=SC1090 source "$GITHUB_ENV"