From 3274ee951f24c8efcfd56eee3041aa584e704e0a Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Thu, 15 May 2025 04:34:12 +0700 Subject: [PATCH 01/22] combine testBuild and testHybridApp --- .github/workflows/testBuild.yml | 321 +++++++++++++++++++++++++++++--- 1 file changed, 297 insertions(+), 24 deletions(-) diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index 26b0c8f8d69d..6ee356c0b5c8 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -4,8 +4,13 @@ on: workflow_dispatch: inputs: PULL_REQUEST_NUMBER: - description: Pull Request number for correct placement of apps + description: App PR number for correct placement of apps required: true + # Pull Request number from Mobile-Expensify repo for correct placement of OD app. It will take precedence over MOBILE-EXPENSIFY from App's PR description if both are specified. If nothing is specified defaults to Mobile-Expensify's main + HYBRIDAPP_PULL_REQUEST_NUMBER: + description: Mobile-Expensify PR number. Defaults to main. Overrides MOBILE-EXPENSIFY set in App's PR description. + required: false + default: '' REVIEWED_CODE: description: I reviewed this pull request and verified that it does not contain any malicious code. type: boolean @@ -30,7 +35,7 @@ on: env: # This variable is needed for fastlane to construct correct path - PULL_REQUEST_NUMBER: ${{ github.event.inputs.PULL_REQUEST_NUMBER }} + PULL_REQUEST_NUMBER: ${{ inputs.PULL_REQUEST_NUMBER }} jobs: prep: @@ -54,22 +59,76 @@ jobs: echo "::error::🕵️‍♀️ Please carefully review the pull request before running a test build to ensure it does not contain any malicious code" exit 1 - - name: Check if pull request number is correct + - name: Check if App pull request number is correct if: ${{ github.event_name == 'workflow_dispatch' }} id: getHeadRef run: | set -e - echo "REF=$(gh pr view ${{ github.event.inputs.PULL_REQUEST_NUMBER }} --json headRefOid --jq '.headRefOid')" >> "$GITHUB_OUTPUT" + echo "REF=$(gh pr view ${{ inputs.PULL_REQUEST_NUMBER }} --json headRefOid --jq '.headRefOid')" >> "$GITHUB_OUTPUT" env: GITHUB_TOKEN: ${{ github.token }} + + getOldDotPR: + runs-on: ubuntu-latest + needs: [prep] + outputs: + OLD_DOT_PR: ${{ steps.old-dot-pr.outputs.result }} + steps: + - name: Check if author specifed Old Dot PR + id: old-dot-pr + # v7 + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea + with: + github-token: ${{ github.token }} + result-encoding: string + script: | + if ('${{ inputs.HYBRIDAPP_PULL_REQUEST_NUMBER}}') return '${{ inputs.HYBRIDAPP_PULL_REQUEST_NUMBER}}'; + + if (!'${{ inputs.PULL_REQUEST_NUMBER }}') return ''; + + const pullRequest = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: '${{ inputs.PULL_REQUEST_NUMBER }}', + }); + + const body = pullRequest.data.body; + const regex = /MOBILE-EXPENSIFY:\s*https:\/\/github.com\/Expensify\/Mobile-Expensify\/pull\/(?\d+)/; + const found = body.match(regex)?.groups?.prNumber || ""; + + return found.trim(); + + getOldDotRef: + runs-on: ubuntu-latest + needs: [getOldDotPR] + outputs: + OLD_DOT_REF: ${{ steps.getHeadRef.outputs.REF }} + steps: + - name: Checkout + # v4 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + + - name: Check if Old Dot pull request number is correct + id: getHeadRef + run: | + set -e + if [[ -z "${{ inputs.HYBRIDAPP_PULL_REQUEST_NUMBER }}" && -z "${{ needs.getOldDotPR.outputs.OLD_DOT_PR }}" ]]; then + echo "REF=" >> "$GITHUB_OUTPUT" + else + echo "PR=${{ inputs.HYBRIDAPP_PULL_REQUEST_NUMBER || needs.getOldDotPR.outputs.OLD_DOT_PR }}" >> "$GITHUB_OUTPUT" + echo "REF=$(gh pr view ${{ inputs.HYBRIDAPP_PULL_REQUEST_NUMBER || needs.getOldDotPR.outputs.OLD_DOT_PR }} -R Expensify/Mobile-Expensify --json headRefOid --jq '.headRefOid')" >> "$GITHUB_OUTPUT" + fi + env: + GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} postGitHubCommentBuildStarted: name: Post build started comment uses: ./.github/workflows/postBuildStartedComment.yml - needs: [prep] + needs: [prep, getOldDotPR, getOldDotRef] secrets: inherit with: - APP_PULL_REQUEST_NUMBER: ${{ github.event.number || github.event.inputs.PULL_REQUEST_NUMBER }} + APP_PULL_REQUEST_NUMBER: ${{ github.event.number || inputs.PULL_REQUEST_NUMBER }} + HYBRIDAPP_PULL_REQUEST_NUMBER: ${{ inputs.HYBRIDAPP_PULL_REQUEST_NUMBER }} desktop: name: Build and deploy Desktop for testing @@ -160,22 +219,236 @@ jobs: - name: Deploy to S3 for internal testing run: aws s3 cp --recursive --acl public-read "$GITHUB_WORKSPACE"/dist s3://ad-hoc-expensify-cash/web/"$PULL_REQUEST_NUMBER" - buildHybridApps: - name: Build hybrid adhoc apps - uses: ./.github/workflows/testBuildHybrid.yml - needs: [prep] - secrets: inherit - with: - APP_PR_NUMBER: ${{ github.event.inputs.PULL_REQUEST_NUMBER }} - APP_REF: ${{ needs.prep.outputs.REF }} - IOS: ${{ inputs.IOS }} - ANDROID: ${{ inputs.ANDROID }} + androidHybrid: + name: Build Android HybridApp + if: ${{ inputs.ANDROID }} + needs: [prep, getOldDotPR, getOldDotRef] + runs-on: ubuntu-latest-xl + outputs: + S3_APK_PATH: ${{ steps.exportAndroidS3Path.outputs.S3_APK_PATH }} + steps: + - name: Checkout + # v4 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + with: + submodules: true + ref: ${{ needs.prep.outputs.REF || 'main' }} + token: ${{ secrets.OS_BOTIFY_TOKEN }} + + - name: Checkout Old Dot to author specified branch or commit + if: ${{ needs.getOldDotRef.outputs.OLD_DOT_REF != '' }} + run: | + cd Mobile-Expensify + git fetch origin ${{ needs.getOldDotRef.outputs.OLD_DOT_REF }} + git checkout ${{ needs.getOldDotRef.outputs.OLD_DOT_REF }} + echo "Building from https://github.com/Expensify/Mobile-Expensify/pull/${{ needs.getOldDotPR.outputs.OLD_DOT_PR }}" + + - name: Configure MapBox SDK + run: ./scripts/setup-mapbox-sdk.sh ${{ secrets.MAPBOX_SDK_DOWNLOAD_TOKEN }} + + - name: Setup Node + id: setup-node + uses: ./.github/actions/composite/setupNode + with: + IS_HYBRID_BUILD: 'true' + + - name: Run grunt build + run: | + cd Mobile-Expensify + npm run grunt:build:shared + + - name: Setup dotenv + run: | + cp .env.staging .env.adhoc + sed -i 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc + echo "PULL_REQUEST_NUMBER=${{ inputs.PULL_REQUEST_NUMBER }}" >> .env.adhoc + + - name: Setup Java + # v4 + uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 + with: + distribution: 'oracle' + java-version: '17' + + - name: Setup Ruby + # v1.229.0 + uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 + with: + bundler-cache: true + + - name: Install 1Password CLI + # v1 + uses: 1password/install-cli-action@143a85f84a90555d121cde2ff5872e393a47ab9f + + - name: Load files from 1Password + env: + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} + run: | + op read "op://${{ vars.OP_VAULT }}/upload-key.keystore/upload-key.keystore" --force --out-file ./upload-key.keystore + op read "op://${{ vars.OP_VAULT }}/android-fastlane-json-key.json/android-fastlane-json-key.json" --force --out-file ./android-fastlane-json-key.json + + # Copy the keystore to the Android directory for Fullstory + cp ./upload-key.keystore Mobile-Expensify/Android + + - name: Load Android upload keystore credentials from 1Password + id: load-credentials + # v2 + uses: 1password/load-secrets-action@581a835fb51b8e7ec56b71cf2ffddd7e68bb25e0 + with: + export-env: false + env: + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} + ANDROID_UPLOAD_KEYSTORE_PASSWORD: op://${{ vars.OP_VAULT }}/Repository-Secrets/ANDROID_UPLOAD_KEYSTORE_PASSWORD + ANDROID_UPLOAD_KEYSTORE_ALIAS: op://${{ vars.OP_VAULT }}/Repository-Secrets/ANDROID_UPLOAD_KEYSTORE_ALIAS + ANDROID_UPLOAD_KEY_PASSWORD: op://${{ vars.OP_VAULT }}/Repository-Secrets/ANDROID_UPLOAD_KEY_PASSWORD + + - name: Build Android app + id: build + env: + ANDROID_UPLOAD_KEYSTORE_PASSWORD: ${{ steps.load-credentials.outputs.ANDROID_UPLOAD_KEYSTORE_PASSWORD }} + ANDROID_UPLOAD_KEYSTORE_ALIAS: ${{ steps.load-credentials.outputs.ANDROID_UPLOAD_KEYSTORE_ALIAS }} + ANDROID_UPLOAD_KEY_PASSWORD: ${{ steps.load-credentials.outputs.ANDROID_UPLOAD_KEY_PASSWORD }} + run: bundle exec fastlane android build_adhoc_hybrid + + - name: Configure AWS Credentials + # v4 + uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Upload Android AdHoc build to S3 + run: bundle exec fastlane android upload_s3 + env: + S3_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} + S3_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + S3_BUCKET: ad-hoc-expensify-cash + S3_REGION: us-east-1 + + - name: Export S3 path + id: exportAndroidS3Path + run: | + # $s3APKPath is set from within the Fastfile, android upload_s3 lane + echo "S3_APK_PATH=$s3APKPath" >> "$GITHUB_OUTPUT" + + iosHybrid: + name: Build and deploy iOS for testing + if: ${{ inputs.IOS }} + needs: [prep, getOldDotPR, getOldDotRef] + env: + DEVELOPER_DIR: /Applications/Xcode_16.2.0.app/Contents/Developer + runs-on: macos-15-xlarge + outputs: + IOS_PATH: ${{ steps.export-ios-path.outputs.IOS_PATH }} + steps: + - name: Checkout + # v4 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + with: + submodules: true + ref: ${{ needs.prep.outputs.REF || 'main'}} + token: ${{ secrets.OS_BOTIFY_TOKEN }} + + - name: Checkout Old Dot to author specified branch or commit + if: ${{ needs.getOldDotRef.outputs.OLD_DOT_REF != '' }} + run: | + cd Mobile-Expensify + git fetch origin ${{ needs.getOldDotRef.outputs.OLD_DOT_REF }} + git checkout ${{ needs.getOldDotRef.outputs.OLD_DOT_REF }} + echo "Building from https://github.com/Expensify/Mobile-Expensify/pull/${{ needs.getOldDotPR.outputs.OLD_DOT_PR }}" + + - name: Configure MapBox SDK + run: ./scripts/setup-mapbox-sdk.sh ${{ secrets.MAPBOX_SDK_DOWNLOAD_TOKEN }} + + - name: Setup Node + id: setup-node + uses: ./.github/actions/composite/setupNode + with: + IS_HYBRID_BUILD: 'true' + + - 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=${{ inputs.PULL_REQUEST_NUMBER }}" >> .env.adhoc + + - name: Setup Ruby + # v1.229.0 + uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 + with: + bundler-cache: true + + - name: Install New Expensify Gems + run: bundle install + + - name: Cache Pod dependencies + # v4 + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 + id: pods-cache + with: + path: Mobile-Expensify/iOS/Pods + key: ${{ runner.os }}-pods-cache-${{ hashFiles('Mobile-Expensify/iOS/Podfile.lock', 'firebase.json') }} + + - name: Compare Podfile.lock and Manifest.lock + id: compare-podfile-and-manifest + run: echo "IS_PODFILE_SAME_AS_MANIFEST=${{ hashFiles('Mobile-Expensify/iOS/Podfile.lock') == hashFiles('Mobile-Expensify/iOS/Manifest.lock') }}" >> "$GITHUB_OUTPUT" + + - name: Install cocoapods + uses: nick-fields/retry@3f757583fb1b1f940bc8ef4bf4734c8dc02a5847 + if: steps.pods-cache.outputs.cache-hit != 'true' || steps.compare-podfile-and-manifest.outputs.IS_PODFILE_SAME_AS_MANIFEST != 'true' || steps.setup-node.outputs.cache-hit != 'true' + with: + timeout_minutes: 10 + max_attempts: 5 + command: npm run pod-install + + - name: Install 1Password CLI + # v1 + uses: 1password/install-cli-action@143a85f84a90555d121cde2ff5872e393a47ab9f + + - name: Load files from 1Password + env: + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} + run: | + op read "op://${{ vars.OP_VAULT }}/OldApp_AdHoc/OldApp_AdHoc.mobileprovision" --force --out-file ./OldApp_AdHoc.mobileprovision + op read "op://${{ vars.OP_VAULT }}/OldApp_AdHoc_Share_Extension/OldApp_AdHoc_Share_Extension.mobileprovision" --force --out-file ./OldApp_AdHoc_Share_Extension.mobileprovision + op read "op://${{ vars.OP_VAULT }}/OldApp_AdHoc_Notification_Service/OldApp_AdHoc_Notification_Service.mobileprovision" --force --out-file ./OldApp_AdHoc_Notification_Service.mobileprovision + op read "op://${{ vars.OP_VAULT }}/New Expensify Distribution Certificate/Certificates.p12" --force --out-file ./Certificates.p12 + + - name: Build AdHoc app + run: bundle exec fastlane ios build_adhoc_hybrid + + - name: Configure AWS Credentials + # v4 + uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Upload AdHoc build to S3 + run: bundle exec fastlane ios upload_s3 + env: + S3_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} + S3_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + S3_BUCKET: ad-hoc-expensify-cash + S3_REGION: us-east-1 + + - name: Export iOS path + id: export-ios-path + run: | + content_ios="$(cat ./ios_paths.json)" + content_ios="${content_ios//'%'/'%25'}" + content_ios="${content_ios//$'\n'/'%0A'}" + content_ios="${content_ios//$'\r'/'%0D'}" + ios_path=$(echo "$content_ios" | jq -r '.html_path') + echo "IOS_PATH=$ios_path" >> "$GITHUB_OUTPUT" postGithubComment: runs-on: ubuntu-latest if: always() name: Post a GitHub comment with app download links for testing - needs: [prep, desktop, web, buildHybridApps] + needs: [prep, desktop, web, androidHybrid, iosHybrid] steps: - name: Checkout # v4 @@ -190,13 +463,13 @@ jobs: - name: Publish links to apps for download uses: ./.github/actions/javascript/postTestBuildComment with: - PR_NUMBER: ${{ github.event.inputs.PULL_REQUEST_NUMBER }} + PR_NUMBER: ${{ inputs.PULL_REQUEST_NUMBER }} GITHUB_TOKEN: ${{ github.token }} - ANDROID: ${{ needs.buildHybridApps.result }} + ANDROID: ${{ needs.androidHybrid.result }} DESKTOP: ${{ needs.desktop.result }} - IOS: ${{ needs.buildHybridApps.result }} + IOS: ${{ needs.iosHybrid.result }} WEB: ${{ needs.web.result }} - ANDROID_LINK: ${{ needs.buildHybridApps.outputs.ANDROID_LINK }} - DESKTOP_LINK: https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/${{ github.event.inputs.PULL_REQUEST_NUMBER }}/NewExpensify.dmg - IOS_LINK: ${{ needs.buildHybridApps.outputs.IOS_LINK }} - WEB_LINK: https://${{ github.event.inputs.PULL_REQUEST_NUMBER }}.pr-testing.expensify.com + ANDROID_LINK: ${{ needs.androidHybrid.outputs.S3_APK_PATH }} + DESKTOP_LINK: https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/${{ inputs.PULL_REQUEST_NUMBER }}/NewExpensify.dmg + IOS_LINK: ${{ needs.iosHybrid.outputs.IOS_PATH }} + WEB_LINK: https://${{ inputs.PULL_REQUEST_NUMBER }}.pr-testing.expensify.com From 94c61e85201ebf51d0b6890c2720f5fd1900d799 Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Thu, 15 May 2025 04:49:38 +0700 Subject: [PATCH 02/22] update postTestBuildComment script to include hybridapp pr --- .github/actions/javascript/postTestBuildComment/action.yml | 3 +++ .github/actions/javascript/postTestBuildComment/index.js | 6 ++++-- .../javascript/postTestBuildComment/postTestBuildComment.ts | 6 ++++-- .github/workflows/testBuild.yml | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/actions/javascript/postTestBuildComment/action.yml b/.github/actions/javascript/postTestBuildComment/action.yml index 538a8f9bfe3a..6bcd8112afad 100644 --- a/.github/actions/javascript/postTestBuildComment/action.yml +++ b/.github/actions/javascript/postTestBuildComment/action.yml @@ -7,6 +7,9 @@ inputs: PR_NUMBER: description: "Pull request number" required: true + HYBRID_APP_PR_NUMBER: + description: "Pull request number for the hybrid app" + required: false GITHUB_TOKEN: description: "Github token for authentication" default: "${{ github.token }}" diff --git a/.github/actions/javascript/postTestBuildComment/index.js b/.github/actions/javascript/postTestBuildComment/index.js index f0cd66d45f20..ad5c2c4e31ac 100644 --- a/.github/actions/javascript/postTestBuildComment/index.js +++ b/.github/actions/javascript/postTestBuildComment/index.js @@ -11574,7 +11574,7 @@ const core = __importStar(__nccwpck_require__(2186)); const github_1 = __nccwpck_require__(5438); const CONST_1 = __importDefault(__nccwpck_require__(9873)); const GithubUtils_1 = __importDefault(__nccwpck_require__(9296)); -function getTestBuildMessage() { +function getTestBuildMessage(pr, hybridAppPr) { const inputs = ['ANDROID', 'DESKTOP', 'IOS', 'WEB']; const names = { [inputs[0]]: 'Android', @@ -11600,6 +11600,7 @@ function getTestBuildMessage() { return acc; }, {}); const message = `:test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! :test_tube::test_tube: +Built from App PR Expensify/App#${pr}${hybridAppPr ? ` and Mobile-Expensify PR Expensify/Mobile-Expensify#${hybridAppPr}` : ''}. | Android :robot: | iOS :apple: | | ------------- | ------------- | | Android :robot::arrows_counterclockwise: | iOS :apple::arrows_counterclockwise: | @@ -11631,6 +11632,7 @@ async function commentPR(REPO, PR, message) { } async function run() { const PR_NUMBER = Number(core.getInput('PR_NUMBER', { required: true })); + const HYBRID_APP_PR_NUMBER = Number(core.getInput('HYBRID_APP_PR_NUMBER', { required: false })); const REPO = String(core.getInput('REPO', { required: true })); if (REPO !== CONST_1.default.APP_REPO && REPO !== CONST_1.default.MOBILE_EXPENSIFY_REPO) { core.setFailed(`Invalid repository used to place output comment: ${REPO}`); @@ -11657,7 +11659,7 @@ async function run() { } `); } - await commentPR(REPO, PR_NUMBER, getTestBuildMessage()); + await commentPR(REPO, PR_NUMBER, getTestBuildMessage(PR_NUMBER, HYBRID_APP_PR_NUMBER)); } if (require.main === require.cache[eval('__filename')]) { run(); diff --git a/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts b/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts index e9600076c078..94eb2a9fc467 100644 --- a/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts +++ b/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts @@ -4,7 +4,7 @@ import type {TupleToUnion} from 'type-fest'; import CONST from '@github/libs/CONST'; import GithubUtils from '@github/libs/GithubUtils'; -function getTestBuildMessage(): string { +function getTestBuildMessage(pr: number, hybridAppPr?: number): string { const inputs = ['ANDROID', 'DESKTOP', 'IOS', 'WEB'] as const; const names = { [inputs[0]]: 'Android', @@ -36,6 +36,7 @@ function getTestBuildMessage(): string { }, {} as Record, {link: string; qrCode: string}>); const message = `:test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! :test_tube::test_tube: +Built from App PR Expensify/App#${pr}${hybridAppPr ? ` and Mobile-Expensify PR Expensify/Mobile-Expensify#${hybridAppPr}` : ''}. | Android :robot: | iOS :apple: | | ------------- | ------------- | | Android :robot::arrows_counterclockwise: | iOS :apple::arrows_counterclockwise: | @@ -70,6 +71,7 @@ async function commentPR(REPO: string, PR: number, message: string) { async function run() { const PR_NUMBER = Number(core.getInput('PR_NUMBER', {required: true})); + const HYBRID_APP_PR_NUMBER = Number(core.getInput('HYBRID_APP_PR_NUMBER', {required: false})); const REPO = String(core.getInput('REPO', {required: true})); if (REPO !== CONST.APP_REPO && REPO !== CONST.MOBILE_EXPENSIFY_REPO) { @@ -102,7 +104,7 @@ async function run() { } `); } - await commentPR(REPO, PR_NUMBER, getTestBuildMessage()); + await commentPR(REPO, PR_NUMBER, getTestBuildMessage(PR_NUMBER, HYBRID_APP_PR_NUMBER)); } if (require.main === module) { diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index 6ee356c0b5c8..11ec4628c3e5 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -464,6 +464,7 @@ jobs: uses: ./.github/actions/javascript/postTestBuildComment with: PR_NUMBER: ${{ inputs.PULL_REQUEST_NUMBER }} + HYBRID_APP_PR_NUMBER: ${{ needs.getOldDotPR.outputs.OLD_DOT_PR }} GITHUB_TOKEN: ${{ github.token }} ANDROID: ${{ needs.androidHybrid.result }} DESKTOP: ${{ needs.desktop.result }} From afa3b2b64c5de76bcd3a9a13d2da670a9a28476f Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Thu, 15 May 2025 04:52:51 +0700 Subject: [PATCH 03/22] update deploy docs --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index e7a289e66b49..bde9c05abb19 100644 --- a/README.md +++ b/README.md @@ -813,10 +813,7 @@ The [`lockDeploys` workflow](https://github.com/Expensify/App/blob/main/.github/ The [`finishReleaseCycle` workflow](https://github.com/Expensify/App/blob/main/.github/workflows/finishReleaseCycle.yml) executes when the `StagingDeployCash` is closed. It updates the `production` branch from `staging` (triggering a production deploy), deploys `main` to staging (with a new `PATCH` version), and creates a new `StagingDeployCash` deploy checklist. ### testBuild -The [`testBuild` workflow](https://github.com/Expensify/App/blob/main/.github/workflows/testBuild.yml) builds ad-hoc staging apps (standalone iOS, standalone Android, web, and desktop) directly from pull requests in the App repository. This process enables testers to review modifications before they are merged into the main branch and deployed to the staging environment. To initiate this workflow, the PR number from the App repository is required as input. - -### testBuildHybrid -The [`testBuildHybrid` workflow](https://github.com/Expensify/App/blob/main/.github/workflows/testBuildHybrid.yml) builds ad-hoc staging versions of hybrid apps (iOS and Android) from pull requests submitted to the App and Mobile-Expensify repositories. This workflow facilitates testing changes by accepting up to two inputs: +The [`testBuild` workflow](https://github.com/Expensify/App/blob/main/.github/workflows/testBuild.yml) builds ad-hoc staging apps (hybrid iOS, hybrid Android, web, and desktop) from pull requests submitted to the App and Mobile-Expensify repositories. This process enables testers to review modifications before they are merged into the main branch and deployed to the staging environment. This workflow accepts up to two inputs: - A PR number from the App repository for testing New Dot (ND) changes. - A PR number from the Mobile-Expensify repository for testing Old Dot (OD) changes. From 62124682de1b446fc780e76354ac7bc2ddd12d1f Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Thu, 15 May 2025 04:53:38 +0700 Subject: [PATCH 04/22] fix action lint --- .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 11ec4628c3e5..2aa2bab5dde5 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -448,7 +448,7 @@ jobs: runs-on: ubuntu-latest if: always() name: Post a GitHub comment with app download links for testing - needs: [prep, desktop, web, androidHybrid, iosHybrid] + needs: [prep, getOldDotPR, desktop, web, androidHybrid, iosHybrid] steps: - name: Checkout # v4 From 5d831b0e95b447dbce3f4ce3c5f673e45bc54480 Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Thu, 15 May 2025 04:54:33 +0700 Subject: [PATCH 05/22] remove testBuildHybrid.yml --- .github/workflows/testBuildHybrid.yml | 434 -------------------------- 1 file changed, 434 deletions(-) delete mode 100644 .github/workflows/testBuildHybrid.yml diff --git a/.github/workflows/testBuildHybrid.yml b/.github/workflows/testBuildHybrid.yml deleted file mode 100644 index 1b68781f3ba8..000000000000 --- a/.github/workflows/testBuildHybrid.yml +++ /dev/null @@ -1,434 +0,0 @@ -name: Build and deploy hybrid apps for testing - -on: - workflow_dispatch: - inputs: - REVIEWED_CODE: - description: I reviewed this pull request and verified that it does not contain any malicious code. - type: boolean - required: true - default: false - # Pull Request number from App repo for correct placement of ND app. If not specified defaults to main branch. - APP_PULL_REQUEST_NUMBER: - description: App PR number. Defaults to main. - required: false - default: '' - # Pull Request number from Mobile-Expensify repo for correct placement of OD app. It will take precedence over MOBILE-EXPENSIFY from App's PR description if both are specified. If nothing is specified defaults to Mobile-Expensify's main - HYBRIDAPP_PULL_REQUEST_NUMBER: - description: Mobile-Expensify PR number. Defaults to main. Overrides MOBILE-EXPENSIFY set in App's PR description. - required: false - default: '' - # Do not modify! GH preserves `workflow_dispatch` as the event that triggered this workflow even if it was called from `testBuild.yml`. This is a workaround for that issue. - DISPATCHED_MANUALLY: - description: Leave checked! This is a workaround for a GH workflow bug. - type: boolean - default: true - workflow_call: - inputs: - APP_PR_NUMBER: - description: Pull Request number from App repo needed for download link construction - type: string - required: true - APP_REF: - description: Git ref to checkout in App - type: string - required: true - IOS: - description: Should build iOS app? - type: boolean - default: true - ANDROID: - description: Should build Android app? - type: boolean - default: true - - outputs: - ANDROID_LINK: - value: ${{ jobs.androidHybrid.outputs.S3_APK_PATH }} - IOS_LINK: - value: ${{ jobs.iosHybrid.outputs.IOS_PATH }} - -env: - # This variable is needed for fastlane to construct correct path, -hybrid suffix is needed to distinguish hybrid apps from standalone New Dot - PULL_REQUEST_NUMBER: ${{ github.event.inputs.APP_PULL_REQUEST_NUMBER || github.event.inputs.HYBRIDAPP_PULL_REQUEST_NUMBER || inputs.APP_PR_NUMBER}}-hybrid - -jobs: - prep: - runs-on: ubuntu-latest - steps: - - name: Checkout - # v4 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - - name: Validate that user is an Expensify employee - if: github.event.inputs.DISPATCHED_MANUALLY - uses: ./.github/actions/composite/validateActor - with: - REQUIRE_APP_DEPLOYER: false - OS_BOTIFY_TOKEN: ${{ secrets.OS_BOTIFY_COMMIT_TOKEN }} - - - name: Validate that the user reviewed the pull request before running a test build - if: ${{ github.event_name == 'workflow_dispatch' && !inputs.REVIEWED_CODE }} - run: | - echo "::error::🕵️‍♀️ Please carefully review the pull request before running a test build to ensure it does not contain any malicious code" - exit 1 - - - name: Validate input - if: github.event.inputs.DISPATCHED_MANUALLY - run: | - if [[ -z "${{ github.event.inputs.APP_PULL_REQUEST_NUMBER }}" && -z "${{ github.event.inputs.HYBRIDAPP_PULL_REQUEST_NUMBER }}" ]]; then - echo "Invalid input. You have to pass at least one PR number" - exit 1 - fi - - getNewDotRef: - runs-on: ubuntu-latest - needs: [prep] - outputs: - REF: ${{ steps.getHeadRef.outputs.REF }} - steps: - - name: Checkout - # v4 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - - name: Check if pull request number is correct - id: getHeadRef - run: | - set -e - - if [[ -n "${{ inputs.APP_REF }}" ]]; then - echo "REF=${{ inputs.APP_REF }}" >> "$GITHUB_OUTPUT" - exit 0 - fi - - if [[ -z "${{ github.event.inputs.APP_PULL_REQUEST_NUMBER }}" ]]; then - echo "REF=" >> "$GITHUB_OUTPUT" - else - echo "REF=$(gh pr view ${{ github.event.inputs.APP_PULL_REQUEST_NUMBER }} -R Expensify/App --json headRefOid --jq '.headRefOid')" >> "$GITHUB_OUTPUT" - fi - env: - GITHUB_TOKEN: ${{ github.token }} - - getOldDotPR: - runs-on: ubuntu-latest - needs: [prep] - outputs: - OLD_DOT_PR: ${{ steps.old-dot-pr.outputs.result }} - steps: - - name: Check if author specifed Old Dot PR - id: old-dot-pr - # v7 - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea - with: - github-token: ${{ github.token }} - result-encoding: string - script: | - if ('${{ github.event.inputs.HYBRIDAPP_PULL_REQUEST_NUMBER}}') return '${{ github.event.inputs.HYBRIDAPP_PULL_REQUEST_NUMBER}}'; - - if (!'${{ github.event.inputs.APP_PULL_REQUEST_NUMBER }}' && !'${{ inputs.APP_PR_NUMBER }}') return ''; - - const pullRequest = await github.rest.pulls.get({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: '${{ github.event.inputs.APP_PULL_REQUEST_NUMBER || inputs.APP_PR_NUMBER }}', - }); - - const body = pullRequest.data.body; - const regex = /MOBILE-EXPENSIFY:\s*https:\/\/github.com\/Expensify\/Mobile-Expensify\/pull\/(?\d+)/; - const found = body.match(regex)?.groups?.prNumber || ""; - - return found.trim(); - - getOldDotRef: - runs-on: ubuntu-latest - needs: [getOldDotPR] - outputs: - OLD_DOT_REF: ${{ steps.getHeadRef.outputs.REF }} - steps: - - name: Checkout - # v4 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - - name: Check if pull request number is correct - id: getHeadRef - run: | - set -e - if [[ -z "${{ github.event.inputs.HYBRIDAPP_PULL_REQUEST_NUMBER }}" && -z "${{ needs.getOldDotPR.outputs.OLD_DOT_PR }}" ]]; then - echo "REF=" >> "$GITHUB_OUTPUT" - else - echo "PR=${{ github.event.inputs.HYBRIDAPP_PULL_REQUEST_NUMBER || needs.getOldDotPR.outputs.OLD_DOT_PR }}" >> "$GITHUB_OUTPUT" - echo "REF=$(gh pr view ${{ github.event.inputs.HYBRIDAPP_PULL_REQUEST_NUMBER || needs.getOldDotPR.outputs.OLD_DOT_PR }} -R Expensify/Mobile-Expensify --json headRefOid --jq '.headRefOid')" >> "$GITHUB_OUTPUT" - fi - env: - GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} - - - postGitHubCommentBuildStarted: - name: Post build started comment - uses: ./.github/workflows/postBuildStartedComment.yml - needs: [getNewDotRef, getOldDotPR, getOldDotRef] - secrets: inherit - with: - APP_PULL_REQUEST_NUMBER: ${{ inputs.APP_PULL_REQUEST_NUMBER }} - HYBRIDAPP_PULL_REQUEST_NUMBER: ${{ github.event.inputs.HYBRIDAPP_PULL_REQUEST_NUMBER || needs.getOldDotPR.outputs.OLD_DOT_PR }} - - androidHybrid: - name: Build Android HybridApp - if: ${{ github.event.inputs.DISPATCHED_MANUALLY || inputs.ANDROID }} - needs: [getNewDotRef, getOldDotPR, getOldDotRef] - runs-on: ubuntu-latest-xl - outputs: - S3_APK_PATH: ${{ steps.exportAndroidS3Path.outputs.S3_APK_PATH }} - steps: - - name: Checkout - # v4 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - submodules: true - ref: ${{ needs.getNewDotRef.outputs.REF || 'main' }} - token: ${{ secrets.OS_BOTIFY_TOKEN }} - - - name: Checkout Old Dot to author specified branch or commit - if: ${{ needs.getOldDotRef.outputs.OLD_DOT_REF != '' }} - run: | - cd Mobile-Expensify - git fetch origin ${{ needs.getOldDotRef.outputs.OLD_DOT_REF }} - git checkout ${{ needs.getOldDotRef.outputs.OLD_DOT_REF }} - echo "Building from https://github.com/Expensify/Mobile-Expensify/pull/${{ needs.getOldDotPR.outputs.OLD_DOT_PR }}" - - - name: Configure MapBox SDK - run: ./scripts/setup-mapbox-sdk.sh ${{ secrets.MAPBOX_SDK_DOWNLOAD_TOKEN }} - - - name: Setup Node - id: setup-node - uses: ./.github/actions/composite/setupNode - with: - IS_HYBRID_BUILD: 'true' - - - name: Run grunt build - run: | - cd Mobile-Expensify - npm run grunt:build:shared - - - name: Setup dotenv - run: | - cp .env.staging .env.adhoc - sed -i 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc - echo "PULL_REQUEST_NUMBER=${{ github.event.inputs.APP_PULL_REQUEST_NUMBER }}" >> .env.adhoc - - - name: Setup Java - # v4 - uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 - with: - distribution: 'oracle' - java-version: '17' - - - name: Setup Ruby - # v1.229.0 - uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 - with: - bundler-cache: true - - - name: Install 1Password CLI - # v1 - uses: 1password/install-cli-action@143a85f84a90555d121cde2ff5872e393a47ab9f - - - name: Load files from 1Password - env: - OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} - run: | - op read "op://${{ vars.OP_VAULT }}/upload-key.keystore/upload-key.keystore" --force --out-file ./upload-key.keystore - op read "op://${{ vars.OP_VAULT }}/android-fastlane-json-key.json/android-fastlane-json-key.json" --force --out-file ./android-fastlane-json-key.json - - # Copy the keystore to the Android directory for Fullstory - cp ./upload-key.keystore Mobile-Expensify/Android - - - name: Load Android upload keystore credentials from 1Password - id: load-credentials - # v2 - uses: 1password/load-secrets-action@581a835fb51b8e7ec56b71cf2ffddd7e68bb25e0 - with: - export-env: false - env: - OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} - ANDROID_UPLOAD_KEYSTORE_PASSWORD: op://${{ vars.OP_VAULT }}/Repository-Secrets/ANDROID_UPLOAD_KEYSTORE_PASSWORD - ANDROID_UPLOAD_KEYSTORE_ALIAS: op://${{ vars.OP_VAULT }}/Repository-Secrets/ANDROID_UPLOAD_KEYSTORE_ALIAS - ANDROID_UPLOAD_KEY_PASSWORD: op://${{ vars.OP_VAULT }}/Repository-Secrets/ANDROID_UPLOAD_KEY_PASSWORD - - - name: Build Android app - id: build - env: - ANDROID_UPLOAD_KEYSTORE_PASSWORD: ${{ steps.load-credentials.outputs.ANDROID_UPLOAD_KEYSTORE_PASSWORD }} - ANDROID_UPLOAD_KEYSTORE_ALIAS: ${{ steps.load-credentials.outputs.ANDROID_UPLOAD_KEYSTORE_ALIAS }} - ANDROID_UPLOAD_KEY_PASSWORD: ${{ steps.load-credentials.outputs.ANDROID_UPLOAD_KEY_PASSWORD }} - run: bundle exec fastlane android build_adhoc_hybrid - - - name: Configure AWS Credentials - # v4 - uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-east-1 - - - name: Upload Android AdHoc build to S3 - run: bundle exec fastlane android upload_s3 - env: - S3_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} - S3_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - S3_BUCKET: ad-hoc-expensify-cash - S3_REGION: us-east-1 - - - name: Export S3 path - id: exportAndroidS3Path - run: | - # $s3APKPath is set from within the Fastfile, android upload_s3 lane - echo "S3_APK_PATH=$s3APKPath" >> "$GITHUB_OUTPUT" - - iosHybrid: - name: Build and deploy iOS for testing - if: ${{ github.event.inputs.DISPATCHED_MANUALLY || inputs.IOS }} - needs: [getNewDotRef, getOldDotPR, getOldDotRef] - env: - DEVELOPER_DIR: /Applications/Xcode_16.2.0.app/Contents/Developer - runs-on: macos-15-xlarge - outputs: - IOS_PATH: ${{ steps.export-ios-path.outputs.IOS_PATH }} - steps: - - name: Checkout - # v4 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - submodules: true - ref: ${{ needs.getNewDotRef.outputs.REF || 'main'}} - token: ${{ secrets.OS_BOTIFY_TOKEN }} - - - name: Checkout Old Dot to author specified branch or commit - if: ${{ needs.getOldDotRef.outputs.OLD_DOT_REF != '' }} - run: | - cd Mobile-Expensify - git fetch origin ${{ needs.getOldDotRef.outputs.OLD_DOT_REF }} - git checkout ${{ needs.getOldDotRef.outputs.OLD_DOT_REF }} - echo "Building from https://github.com/Expensify/Mobile-Expensify/pull/${{ needs.getOldDotPR.outputs.OLD_DOT_PR }}" - - - name: Configure MapBox SDK - run: ./scripts/setup-mapbox-sdk.sh ${{ secrets.MAPBOX_SDK_DOWNLOAD_TOKEN }} - - - name: Setup Node - id: setup-node - uses: ./.github/actions/composite/setupNode - with: - IS_HYBRID_BUILD: 'true' - - - 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=${{ github.event.inputs.APP_PULL_REQUEST_NUMBER }}" >> .env.adhoc - - - name: Setup Ruby - # v1.229.0 - uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 - with: - bundler-cache: true - - - name: Install New Expensify Gems - run: bundle install - - - name: Cache Pod dependencies - # v4 - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 - id: pods-cache - with: - path: Mobile-Expensify/iOS/Pods - key: ${{ runner.os }}-pods-cache-${{ hashFiles('Mobile-Expensify/iOS/Podfile.lock', 'firebase.json') }} - - - name: Compare Podfile.lock and Manifest.lock - id: compare-podfile-and-manifest - run: echo "IS_PODFILE_SAME_AS_MANIFEST=${{ hashFiles('Mobile-Expensify/iOS/Podfile.lock') == hashFiles('Mobile-Expensify/iOS/Manifest.lock') }}" >> "$GITHUB_OUTPUT" - - - name: Install cocoapods - uses: nick-fields/retry@3f757583fb1b1f940bc8ef4bf4734c8dc02a5847 - if: steps.pods-cache.outputs.cache-hit != 'true' || steps.compare-podfile-and-manifest.outputs.IS_PODFILE_SAME_AS_MANIFEST != 'true' || steps.setup-node.outputs.cache-hit != 'true' - with: - timeout_minutes: 10 - max_attempts: 5 - command: npm run pod-install - - - name: Install 1Password CLI - # v1 - uses: 1password/install-cli-action@143a85f84a90555d121cde2ff5872e393a47ab9f - - - name: Load files from 1Password - env: - OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} - run: | - op read "op://${{ vars.OP_VAULT }}/OldApp_AdHoc/OldApp_AdHoc.mobileprovision" --force --out-file ./OldApp_AdHoc.mobileprovision - op read "op://${{ vars.OP_VAULT }}/OldApp_AdHoc_Share_Extension/OldApp_AdHoc_Share_Extension.mobileprovision" --force --out-file ./OldApp_AdHoc_Share_Extension.mobileprovision - op read "op://${{ vars.OP_VAULT }}/OldApp_AdHoc_Notification_Service/OldApp_AdHoc_Notification_Service.mobileprovision" --force --out-file ./OldApp_AdHoc_Notification_Service.mobileprovision - op read "op://${{ vars.OP_VAULT }}/New Expensify Distribution Certificate/Certificates.p12" --force --out-file ./Certificates.p12 - - - name: Build AdHoc app - run: bundle exec fastlane ios build_adhoc_hybrid - - - name: Configure AWS Credentials - # v4 - uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-east-1 - - - name: Upload AdHoc build to S3 - run: bundle exec fastlane ios upload_s3 - env: - S3_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} - S3_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - S3_BUCKET: ad-hoc-expensify-cash - S3_REGION: us-east-1 - - - name: Export iOS path - id: export-ios-path - run: | - content_ios="$(cat ./ios_paths.json)" - content_ios="${content_ios//'%'/'%25'}" - content_ios="${content_ios//$'\n'/'%0A'}" - content_ios="${content_ios//$'\r'/'%0D'}" - ios_path=$(echo "$content_ios" | jq -r '.html_path') - echo "IOS_PATH=$ios_path" >> "$GITHUB_OUTPUT" - - postGithubComment: - runs-on: ubuntu-latest - name: Post a GitHub comment with app download links for testing - if: github.event.inputs.DISPATCHED_MANUALLY - needs: [getNewDotRef, getOldDotPR, androidHybrid, iosHybrid] - steps: - - name: Checkout - # v4 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: ${{ needs.getNewDotRef.outputs.REF }} - - - name: Publish links to apps for download on NewDot PR - if: github.event.inputs.APP_PULL_REQUEST_NUMBER != '' - uses: ./.github/actions/javascript/postTestBuildComment - with: - PR_NUMBER: ${{ github.event.inputs.APP_PULL_REQUEST_NUMBER }} - REPO: App - GITHUB_TOKEN: ${{ github.token }} - ANDROID: ${{ needs.androidHybrid.result }} - IOS: ${{ needs.iosHybrid.result }} - ANDROID_LINK: ${{ needs.androidHybrid.outputs.S3_APK_PATH }} - IOS_LINK: ${{ needs.iosHybrid.outputs.IOS_PATH }} - - - name: Publish links to apps for download on OldDot PR - if: needs.getOldDotPR.outputs.OLD_DOT_PR != '' - uses: ./.github/actions/javascript/postTestBuildComment - with: - PR_NUMBER: ${{ needs.getOldDotPR.outputs.OLD_DOT_PR }} - REPO: Mobile-Expensify - GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} - ANDROID: ${{ needs.androidHybrid.result }} - IOS: ${{ needs.iosHybrid.result }} - ANDROID_LINK: ${{ needs.androidHybrid.outputs.S3_APK_PATH }} - IOS_LINK: ${{ needs.iosHybrid.outputs.IOS_PATH }} From 4979e440ca72e9d6e8b879676b42fe34f6cd80ed Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Thu, 15 May 2025 05:04:52 +0700 Subject: [PATCH 06/22] update unit test --- tests/unit/postTestBuildComment.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/unit/postTestBuildComment.ts b/tests/unit/postTestBuildComment.ts index 5d8bdd8f88d3..48ac6b4104e8 100644 --- a/tests/unit/postTestBuildComment.ts +++ b/tests/unit/postTestBuildComment.ts @@ -51,6 +51,7 @@ const iOSQRCode = `![iOS](https://api.qrserver.com/v1/create-qr-code/?size=120x1 const webQRCode = `![Web](https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=${webLink})`; const message = `:test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! :test_tube::test_tube: +Built from App PR Expensify/App#12 and Mobile-Expensify PR Expensify/Mobile-Expensify#13. | Android :robot: | iOS :apple: | | ------------- | ------------- | | Android :robot::arrows_counterclockwise: | iOS :apple::arrows_counterclockwise: | @@ -66,6 +67,7 @@ const message = `:test_tube::test_tube: Use the links below to test this adhoc b `; const onlyAndroidMessage = `:test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! :test_tube::test_tube: +Built from App PR Expensify/App#12. | Android :robot: | iOS :apple: | | ------------- | ------------- | | Android :robot::arrows_counterclockwise: | iOS :apple::arrows_counterclockwise: | @@ -91,7 +93,7 @@ describe('Post test build comments action tests', () => { test('Test GH action', async () => { when(core.getInput).calledWith('REPO', {required: true}).mockReturnValue(CONST.APP_REPO); when(core.getInput).calledWith('PR_NUMBER', {required: true}).mockReturnValue('12'); - when(core.getInput).calledWith('ANDROID', {required: false}).mockReturnValue('success'); + when(core.getInput).calledWith('HYBRIDAPP_PULL_REQUEST_NUMBER', {required: false}).mockReturnValue('13'); when(core.getInput).calledWith('ANDROID', {required: false}).mockReturnValue('success'); when(core.getInput).calledWith('IOS', {required: false}).mockReturnValue('success'); when(core.getInput).calledWith('WEB', {required: false}).mockReturnValue('success'); From 7593926c685d07ec9589a051fce0aa196fed4e07 Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Thu, 15 May 2025 05:08:41 +0700 Subject: [PATCH 07/22] update unit test --- tests/unit/postTestBuildComment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/postTestBuildComment.ts b/tests/unit/postTestBuildComment.ts index 48ac6b4104e8..6f32dfdc4b26 100644 --- a/tests/unit/postTestBuildComment.ts +++ b/tests/unit/postTestBuildComment.ts @@ -93,7 +93,7 @@ describe('Post test build comments action tests', () => { test('Test GH action', async () => { when(core.getInput).calledWith('REPO', {required: true}).mockReturnValue(CONST.APP_REPO); when(core.getInput).calledWith('PR_NUMBER', {required: true}).mockReturnValue('12'); - when(core.getInput).calledWith('HYBRIDAPP_PULL_REQUEST_NUMBER', {required: false}).mockReturnValue('13'); + when(core.getInput).calledWith('HYBRID_APP_PR_NUMBER', {required: false}).mockReturnValue('13'); when(core.getInput).calledWith('ANDROID', {required: false}).mockReturnValue('success'); when(core.getInput).calledWith('IOS', {required: false}).mockReturnValue('success'); when(core.getInput).calledWith('WEB', {required: false}).mockReturnValue('success'); From 04b1f8fee00d3df15f880cc97eabae7ab77e2412 Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Thu, 15 May 2025 05:13:11 +0700 Subject: [PATCH 08/22] update unit test --- tests/unit/postTestBuildComment.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/postTestBuildComment.ts b/tests/unit/postTestBuildComment.ts index 6f32dfdc4b26..e52fd94aa206 100644 --- a/tests/unit/postTestBuildComment.ts +++ b/tests/unit/postTestBuildComment.ts @@ -130,6 +130,7 @@ describe('Post test build comments action tests', () => { test('Test GH action when input is not complete', async () => { when(core.getInput).calledWith('REPO', {required: true}).mockReturnValue(CONST.APP_REPO); when(core.getInput).calledWith('PR_NUMBER', {required: true}).mockReturnValue('12'); + when(core.getInput).calledWith('HYBRID_APP_PR_NUMBER', {required: false}).mockReturnValue('13'); when(core.getInput).calledWith('ANDROID', {required: false}).mockReturnValue(''); when(core.getInput).calledWith('IOS', {required: false}).mockReturnValue(''); when(core.getInput).calledWith('WEB', {required: false}).mockReturnValue(''); From 68e04343bd6b891a10083a782c98df97eb14883e Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Thu, 15 May 2025 05:24:16 +0700 Subject: [PATCH 09/22] update unit test --- tests/unit/postTestBuildComment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/postTestBuildComment.ts b/tests/unit/postTestBuildComment.ts index e52fd94aa206..f204a269446c 100644 --- a/tests/unit/postTestBuildComment.ts +++ b/tests/unit/postTestBuildComment.ts @@ -130,7 +130,7 @@ describe('Post test build comments action tests', () => { test('Test GH action when input is not complete', async () => { when(core.getInput).calledWith('REPO', {required: true}).mockReturnValue(CONST.APP_REPO); when(core.getInput).calledWith('PR_NUMBER', {required: true}).mockReturnValue('12'); - when(core.getInput).calledWith('HYBRID_APP_PR_NUMBER', {required: false}).mockReturnValue('13'); + when(core.getInput).calledWith('HYBRID_APP_PR_NUMBER', {required: false}).mockReturnValue(''); when(core.getInput).calledWith('ANDROID', {required: false}).mockReturnValue(''); when(core.getInput).calledWith('IOS', {required: false}).mockReturnValue(''); when(core.getInput).calledWith('WEB', {required: false}).mockReturnValue(''); From c9234071afc38f95f76eb96ae20978359357f97d Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Thu, 15 May 2025 12:05:02 +0700 Subject: [PATCH 10/22] consistently use Mobile-Expensify instead of OldDot or HybridApp --- .../postTestBuildComment/action.yml | 8 +- .../javascript/postTestBuildComment/index.js | 12 +- .../postTestBuildComment.ts | 12 +- .github/workflows/compareNDandODbuilds.yml | 2 +- .github/workflows/postBuildStartedComment.yml | 18 +-- .github/workflows/testBuild.yml | 108 +++++++++--------- tests/unit/postTestBuildComment.ts | 8 +- 7 files changed, 84 insertions(+), 84 deletions(-) diff --git a/.github/actions/javascript/postTestBuildComment/action.yml b/.github/actions/javascript/postTestBuildComment/action.yml index 6bcd8112afad..b476e892da69 100644 --- a/.github/actions/javascript/postTestBuildComment/action.yml +++ b/.github/actions/javascript/postTestBuildComment/action.yml @@ -4,11 +4,11 @@ inputs: REPO: description: "Repository to place a comment. Can be App or Mobile-Expensify" default: App - PR_NUMBER: - description: "Pull request number" + APP_PR_NUMBER: + description: "Pull request number for Expensify/App repository" required: true - HYBRID_APP_PR_NUMBER: - description: "Pull request number for the hybrid app" + MOBILE_EXPENSIFY_PR_NUMBER: + description: "Pull request number for Expensify/Mobile-Expensify repository" required: false GITHUB_TOKEN: description: "Github token for authentication" diff --git a/.github/actions/javascript/postTestBuildComment/index.js b/.github/actions/javascript/postTestBuildComment/index.js index ad5c2c4e31ac..8c7ebdc07ed6 100644 --- a/.github/actions/javascript/postTestBuildComment/index.js +++ b/.github/actions/javascript/postTestBuildComment/index.js @@ -11574,7 +11574,7 @@ const core = __importStar(__nccwpck_require__(2186)); const github_1 = __nccwpck_require__(5438); const CONST_1 = __importDefault(__nccwpck_require__(9873)); const GithubUtils_1 = __importDefault(__nccwpck_require__(9296)); -function getTestBuildMessage(pr, hybridAppPr) { +function getTestBuildMessage(appPr, mobileExpensifyPr) { const inputs = ['ANDROID', 'DESKTOP', 'IOS', 'WEB']; const names = { [inputs[0]]: 'Android', @@ -11600,7 +11600,7 @@ function getTestBuildMessage(pr, hybridAppPr) { return acc; }, {}); const message = `:test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! :test_tube::test_tube: -Built from App PR Expensify/App#${pr}${hybridAppPr ? ` and Mobile-Expensify PR Expensify/Mobile-Expensify#${hybridAppPr}` : ''}. +Built from App PR Expensify/App#${appPr}${mobileExpensifyPr ? ` and Mobile-Expensify PR Expensify/Mobile-Expensify#${mobileExpensifyPr}` : ''}. | Android :robot: | iOS :apple: | | ------------- | ------------- | | Android :robot::arrows_counterclockwise: | iOS :apple::arrows_counterclockwise: | @@ -11631,8 +11631,8 @@ async function commentPR(REPO, PR, message) { } } async function run() { - const PR_NUMBER = Number(core.getInput('PR_NUMBER', { required: true })); - const HYBRID_APP_PR_NUMBER = Number(core.getInput('HYBRID_APP_PR_NUMBER', { required: false })); + const APP_PR_NUMBER = Number(core.getInput('APP_PR_NUMBER', { required: true })); + const MOBILE_EXPENSIFY_PR_NUMBER = Number(core.getInput('MOBILE_EXPENSIFY_PR_NUMBER', { required: false })); const REPO = String(core.getInput('REPO', { required: true })); if (REPO !== CONST_1.default.APP_REPO && REPO !== CONST_1.default.MOBILE_EXPENSIFY_REPO) { core.setFailed(`Invalid repository used to place output comment: ${REPO}`); @@ -11642,7 +11642,7 @@ async function run() { owner: CONST_1.default.GITHUB_OWNER, repo: REPO, // eslint-disable-next-line @typescript-eslint/naming-convention - issue_number: PR_NUMBER, + issue_number: APP_PR_NUMBER, // eslint-disable-next-line @typescript-eslint/naming-convention per_page: 100, }, (response) => response.data); @@ -11659,7 +11659,7 @@ async function run() { } `); } - await commentPR(REPO, PR_NUMBER, getTestBuildMessage(PR_NUMBER, HYBRID_APP_PR_NUMBER)); + await commentPR(REPO, APP_PR_NUMBER, getTestBuildMessage(APP_PR_NUMBER, MOBILE_EXPENSIFY_PR_NUMBER)); } if (require.main === require.cache[eval('__filename')]) { run(); diff --git a/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts b/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts index 94eb2a9fc467..180bfc7dd995 100644 --- a/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts +++ b/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts @@ -4,7 +4,7 @@ import type {TupleToUnion} from 'type-fest'; import CONST from '@github/libs/CONST'; import GithubUtils from '@github/libs/GithubUtils'; -function getTestBuildMessage(pr: number, hybridAppPr?: number): string { +function getTestBuildMessage(appPr: number, mobileExpensifyPr?: number): string { const inputs = ['ANDROID', 'DESKTOP', 'IOS', 'WEB'] as const; const names = { [inputs[0]]: 'Android', @@ -36,7 +36,7 @@ function getTestBuildMessage(pr: number, hybridAppPr?: number): string { }, {} as Record, {link: string; qrCode: string}>); const message = `:test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! :test_tube::test_tube: -Built from App PR Expensify/App#${pr}${hybridAppPr ? ` and Mobile-Expensify PR Expensify/Mobile-Expensify#${hybridAppPr}` : ''}. +Built from App PR Expensify/App#${appPr}${mobileExpensifyPr ? ` and Mobile-Expensify PR Expensify/Mobile-Expensify#${mobileExpensifyPr}` : ''}. | Android :robot: | iOS :apple: | | ------------- | ------------- | | Android :robot::arrows_counterclockwise: | iOS :apple::arrows_counterclockwise: | @@ -70,8 +70,8 @@ async function commentPR(REPO: string, PR: number, message: string) { } async function run() { - const PR_NUMBER = Number(core.getInput('PR_NUMBER', {required: true})); - const HYBRID_APP_PR_NUMBER = Number(core.getInput('HYBRID_APP_PR_NUMBER', {required: false})); + const APP_PR_NUMBER = Number(core.getInput('APP_PR_NUMBER', {required: true})); + const MOBILE_EXPENSIFY_PR_NUMBER = Number(core.getInput('MOBILE_EXPENSIFY_PR_NUMBER', {required: false})); const REPO = String(core.getInput('REPO', {required: true})); if (REPO !== CONST.APP_REPO && REPO !== CONST.MOBILE_EXPENSIFY_REPO) { @@ -85,7 +85,7 @@ async function run() { owner: CONST.GITHUB_OWNER, repo: REPO, // eslint-disable-next-line @typescript-eslint/naming-convention - issue_number: PR_NUMBER, + issue_number: APP_PR_NUMBER, // eslint-disable-next-line @typescript-eslint/naming-convention per_page: 100, }, @@ -104,7 +104,7 @@ async function run() { } `); } - await commentPR(REPO, PR_NUMBER, getTestBuildMessage(PR_NUMBER, HYBRID_APP_PR_NUMBER)); + await commentPR(REPO, APP_PR_NUMBER, getTestBuildMessage(APP_PR_NUMBER, MOBILE_EXPENSIFY_PR_NUMBER)); } if (require.main === module) { diff --git a/.github/workflows/compareNDandODbuilds.yml b/.github/workflows/compareNDandODbuilds.yml index e559b85e9e22..ea75a7bf89c9 100644 --- a/.github/workflows/compareNDandODbuilds.yml +++ b/.github/workflows/compareNDandODbuilds.yml @@ -58,7 +58,7 @@ jobs: secrets: inherit with: APP_PULL_REQUEST_NUMBER: ${{ inputs.PULL_REQUEST_NUMBER }} - HYBRIDAPP_PULL_REQUEST_NUMBER: ${{ inputs.OLD_DOT_PULL_REQUEST_NUMBER }} + MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER: ${{ inputs.OLD_DOT_PULL_REQUEST_NUMBER }} buildHybridAppAndroid: diff --git a/.github/workflows/postBuildStartedComment.yml b/.github/workflows/postBuildStartedComment.yml index e181d856cfb4..0e9f9e019ed8 100644 --- a/.github/workflows/postBuildStartedComment.yml +++ b/.github/workflows/postBuildStartedComment.yml @@ -4,11 +4,11 @@ on: workflow_call: inputs: APP_PULL_REQUEST_NUMBER: - description: Number of the Pull Request in the App repository where the comment will be posted + description: Number of the Pull Request in Expensify/App repository where the comment will be posted type: string required: false - HYBRIDAPP_PULL_REQUEST_NUMBER: - description: Number of the Pull Request in the Mobile-Expensify repository where the comment will be posted + MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER: + description: Number of the Pull Request in Expensify/Mobile-Expensify repository where the comment will be posted type: string required: false @@ -16,7 +16,7 @@ jobs: postGitHubCommentBuildStarted: runs-on: ubuntu-latest steps: - - name: Add build start comment to ND PR + - name: Add build start comment to Expensify/App PR if: ${{ inputs.APP_PULL_REQUEST_NUMBER != ''}} # v7 uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea @@ -28,11 +28,11 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, issue_number: ${{ inputs.APP_PULL_REQUEST_NUMBER }}, - body: `🚧 @${{ github.actor }} has triggered a test app build. You can view the [workflow run here](${workflowURL}).` + body: `🚧 @${{ github.actor }} has triggered a test Expensify/App build. You can view the [workflow run here](${workflowURL}).` }); - - name: Add build start comment to OD PR - if: ${{ inputs.HYBRIDAPP_PULL_REQUEST_NUMBER != '' }} + - name: Add build start comment to Expensify/Mobile-Expensify PR + if: ${{ inputs.MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER != '' }} # v7 uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea with: @@ -42,6 +42,6 @@ jobs: github.rest.issues.createComment({ owner: context.repo.owner, repo: 'Mobile-Expensify', - issue_number: ${{ inputs.HYBRIDAPP_PULL_REQUEST_NUMBER }}, - body: `🚧 @${{ github.actor }} has triggered a test hybrid app build. You can view the [workflow run here](${workflowURL}).` + issue_number: ${{ inputs.MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER }}, + body: `🚧 @${{ github.actor }} has triggered a test Expensify/Mobile-Expensify build. You can view the [workflow run here](${workflowURL}).` }); \ No newline at end of file diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index 2aa2bab5dde5..f9725efc87be 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -3,12 +3,12 @@ name: Build and deploy apps for testing on: workflow_dispatch: inputs: - PULL_REQUEST_NUMBER: - description: App PR number for correct placement of apps + APP_PULL_REQUEST_NUMBER: + description: Expensify/App PR number for correct placement of apps required: true # Pull Request number from Mobile-Expensify repo for correct placement of OD app. It will take precedence over MOBILE-EXPENSIFY from App's PR description if both are specified. If nothing is specified defaults to Mobile-Expensify's main - HYBRIDAPP_PULL_REQUEST_NUMBER: - description: Mobile-Expensify PR number. Defaults to main. Overrides MOBILE-EXPENSIFY set in App's PR description. + MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER: + description: Expensify/Mobile-Expensify PR number. Defaults to main. Overrides MOBILE-EXPENSIFY set in App's PR description. required: false default: '' REVIEWED_CODE: @@ -35,13 +35,13 @@ on: env: # This variable is needed for fastlane to construct correct path - PULL_REQUEST_NUMBER: ${{ inputs.PULL_REQUEST_NUMBER }} + APP_PULL_REQUEST_NUMBER: ${{ inputs.APP_PULL_REQUEST_NUMBER }} jobs: prep: runs-on: ubuntu-latest outputs: - REF: ${{ steps.getHeadRef.outputs.REF }} + APP_REF: ${{ steps.getHeadRef.outputs.REF }} steps: - name: Checkout # v4 @@ -64,32 +64,32 @@ jobs: id: getHeadRef run: | set -e - echo "REF=$(gh pr view ${{ inputs.PULL_REQUEST_NUMBER }} --json headRefOid --jq '.headRefOid')" >> "$GITHUB_OUTPUT" + echo "REF=$(gh pr view ${{ inputs.APP_PULL_REQUEST_NUMBER }} --json headRefOid --jq '.headRefOid')" >> "$GITHUB_OUTPUT" env: GITHUB_TOKEN: ${{ github.token }} - getOldDotPR: + getMobileExpensifyPR: runs-on: ubuntu-latest needs: [prep] outputs: - OLD_DOT_PR: ${{ steps.old-dot-pr.outputs.result }} + MOBILE_EXPENSIFY_PR: ${{ steps.mobileExpensifyPR.outputs.result }} steps: - - name: Check if author specifed Old Dot PR - id: old-dot-pr + - name: Check if author specifed Expensify/Mobile-Expensify PR + id: mobileExpensifyPR # v7 uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea with: github-token: ${{ github.token }} result-encoding: string script: | - if ('${{ inputs.HYBRIDAPP_PULL_REQUEST_NUMBER}}') return '${{ inputs.HYBRIDAPP_PULL_REQUEST_NUMBER}}'; + if ('${{ inputs.MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER}}') return '${{ inputs.MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER}}'; - if (!'${{ inputs.PULL_REQUEST_NUMBER }}') return ''; + if (!'${{ inputs.APP_PULL_REQUEST_NUMBER }}') return ''; const pullRequest = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, - pull_number: '${{ inputs.PULL_REQUEST_NUMBER }}', + pull_number: '${{ inputs.APP_PULL_REQUEST_NUMBER }}', }); const body = pullRequest.data.body; @@ -98,25 +98,25 @@ jobs: return found.trim(); - getOldDotRef: + getMobileExpensifyRef: runs-on: ubuntu-latest - needs: [getOldDotPR] + needs: [getMobileExpensifyPR] outputs: - OLD_DOT_REF: ${{ steps.getHeadRef.outputs.REF }} + MOBILE_EXPENSIFY_REF: ${{ steps.getHeadRef.outputs.REF }} steps: - name: Checkout # v4 uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - name: Check if Old Dot pull request number is correct + - name: Check if Expensify/Mobile-Expensify pull request number is correct id: getHeadRef run: | set -e - if [[ -z "${{ inputs.HYBRIDAPP_PULL_REQUEST_NUMBER }}" && -z "${{ needs.getOldDotPR.outputs.OLD_DOT_PR }}" ]]; then + if [[ -z "${{ inputs.MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER }}" && -z "${{ needs.getMobileExpensifyPR.outputs.MOBILE_EXPENSIFY_PR }}" ]]; then echo "REF=" >> "$GITHUB_OUTPUT" else - echo "PR=${{ inputs.HYBRIDAPP_PULL_REQUEST_NUMBER || needs.getOldDotPR.outputs.OLD_DOT_PR }}" >> "$GITHUB_OUTPUT" - echo "REF=$(gh pr view ${{ inputs.HYBRIDAPP_PULL_REQUEST_NUMBER || needs.getOldDotPR.outputs.OLD_DOT_PR }} -R Expensify/Mobile-Expensify --json headRefOid --jq '.headRefOid')" >> "$GITHUB_OUTPUT" + echo "PR=${{ inputs.MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER || needs.getMobileExpensifyPR.outputs.MOBILE_EXPENSIFY_PR }}" >> "$GITHUB_OUTPUT" + echo "REF=$(gh pr view ${{ inputs.MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER || needs.getMobileExpensifyPR.outputs.MOBILE_EXPENSIFY_PR }} -R Expensify/Mobile-Expensify --json headRefOid --jq '.headRefOid')" >> "$GITHUB_OUTPUT" fi env: GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} @@ -124,11 +124,11 @@ jobs: postGitHubCommentBuildStarted: name: Post build started comment uses: ./.github/workflows/postBuildStartedComment.yml - needs: [prep, getOldDotPR, getOldDotRef] + needs: [prep, getMobileExpensifyPR, getMobileExpensifyRef] secrets: inherit with: - APP_PULL_REQUEST_NUMBER: ${{ github.event.number || inputs.PULL_REQUEST_NUMBER }} - HYBRIDAPP_PULL_REQUEST_NUMBER: ${{ inputs.HYBRIDAPP_PULL_REQUEST_NUMBER }} + APP_PULL_REQUEST_NUMBER: ${{ github.event.number || inputs.APP_PULL_REQUEST_NUMBER }} + MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER: ${{ inputs.MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER }} desktop: name: Build and deploy Desktop for testing @@ -140,13 +140,13 @@ jobs: # v4 uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: - ref: ${{ needs.prep.outputs.REF }} + ref: ${{ needs.prep.outputs.APP_REF }} - - name: Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it + - name: Create .env.adhoc file based on staging and add APP_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 + echo "APP_PULL_REQUEST_NUMBER=$APP_PULL_REQUEST_NUMBER" >> .env.adhoc - name: Setup Node uses: ./.github/actions/composite/setupNode @@ -194,13 +194,13 @@ jobs: # v4 uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: - ref: ${{ needs.prep.outputs.REF }} + ref: ${{ needs.prep.outputs.APP_REF }} - - name: Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it + - name: Create .env.adhoc file based on staging and add APP_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 + echo "APP_PULL_REQUEST_NUMBER=$APP_PULL_REQUEST_NUMBER" >> .env.adhoc - name: Setup Node uses: ./.github/actions/composite/setupNode @@ -217,12 +217,12 @@ jobs: run: npm run build-adhoc - name: Deploy to S3 for internal testing - run: aws s3 cp --recursive --acl public-read "$GITHUB_WORKSPACE"/dist s3://ad-hoc-expensify-cash/web/"$PULL_REQUEST_NUMBER" + run: aws s3 cp --recursive --acl public-read "$GITHUB_WORKSPACE"/dist s3://ad-hoc-expensify-cash/web/"$APP_PULL_REQUEST_NUMBER" androidHybrid: name: Build Android HybridApp if: ${{ inputs.ANDROID }} - needs: [prep, getOldDotPR, getOldDotRef] + needs: [prep, getMobileExpensifyPR, getMobileExpensifyRef] runs-on: ubuntu-latest-xl outputs: S3_APK_PATH: ${{ steps.exportAndroidS3Path.outputs.S3_APK_PATH }} @@ -232,16 +232,16 @@ jobs: uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: submodules: true - ref: ${{ needs.prep.outputs.REF || 'main' }} + ref: ${{ needs.prep.outputs.APP_REF || 'main' }} token: ${{ secrets.OS_BOTIFY_TOKEN }} - - name: Checkout Old Dot to author specified branch or commit - if: ${{ needs.getOldDotRef.outputs.OLD_DOT_REF != '' }} + - name: Checkout Mobile-Expensify to specified branch or commit + if: ${{ needs.getMobileExpensifyRef.outputs.MOBILE_EXPENSIFY_REF != '' }} run: | cd Mobile-Expensify - git fetch origin ${{ needs.getOldDotRef.outputs.OLD_DOT_REF }} - git checkout ${{ needs.getOldDotRef.outputs.OLD_DOT_REF }} - echo "Building from https://github.com/Expensify/Mobile-Expensify/pull/${{ needs.getOldDotPR.outputs.OLD_DOT_PR }}" + git fetch origin ${{ needs.getMobileExpensifyRef.outputs.MOBILE_EXPENSIFY_REF }} + git checkout ${{ needs.getMobileExpensifyRef.outputs.MOBILE_EXPENSIFY_REF }} + echo "Building from https://github.com/Expensify/Mobile-Expensify/pull/${{ needs.getMobileExpensifyPR.outputs.MOBILE_EXPENSIFY_PR }}" - name: Configure MapBox SDK run: ./scripts/setup-mapbox-sdk.sh ${{ secrets.MAPBOX_SDK_DOWNLOAD_TOKEN }} @@ -261,7 +261,7 @@ jobs: run: | cp .env.staging .env.adhoc sed -i 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc - echo "PULL_REQUEST_NUMBER=${{ inputs.PULL_REQUEST_NUMBER }}" >> .env.adhoc + echo "APP_PULL_REQUEST_NUMBER=${{ inputs.APP_PULL_REQUEST_NUMBER }}" >> .env.adhoc - name: Setup Java # v4 @@ -335,7 +335,7 @@ jobs: iosHybrid: name: Build and deploy iOS for testing if: ${{ inputs.IOS }} - needs: [prep, getOldDotPR, getOldDotRef] + needs: [prep, getMobileExpensifyPR, getMobileExpensifyRef] env: DEVELOPER_DIR: /Applications/Xcode_16.2.0.app/Contents/Developer runs-on: macos-15-xlarge @@ -347,16 +347,16 @@ jobs: uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: submodules: true - ref: ${{ needs.prep.outputs.REF || 'main'}} + ref: ${{ needs.prep.outputs.APP_REF || 'main'}} token: ${{ secrets.OS_BOTIFY_TOKEN }} - - name: Checkout Old Dot to author specified branch or commit - if: ${{ needs.getOldDotRef.outputs.OLD_DOT_REF != '' }} + - name: Checkout Mobile-Expensify to specified branch or commit + if: ${{ needs.getMobileExpensifyRef.outputs.MOBILE_EXPENSIFY_REF != '' }} run: | cd Mobile-Expensify - git fetch origin ${{ needs.getOldDotRef.outputs.OLD_DOT_REF }} - git checkout ${{ needs.getOldDotRef.outputs.OLD_DOT_REF }} - echo "Building from https://github.com/Expensify/Mobile-Expensify/pull/${{ needs.getOldDotPR.outputs.OLD_DOT_PR }}" + git fetch origin ${{ needs.getMobileExpensifyRef.outputs.MOBILE_EXPENSIFY_REF }} + git checkout ${{ needs.getMobileExpensifyRef.outputs.MOBILE_EXPENSIFY_REF }} + echo "Building from https://github.com/Expensify/Mobile-Expensify/pull/${{ needs.getMobileExpensifyPR.outputs.MOBILE_EXPENSIFY_PR }}" - name: Configure MapBox SDK run: ./scripts/setup-mapbox-sdk.sh ${{ secrets.MAPBOX_SDK_DOWNLOAD_TOKEN }} @@ -367,11 +367,11 @@ jobs: with: IS_HYBRID_BUILD: 'true' - - name: Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it + - name: Create .env.adhoc file based on staging and add APP_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=${{ inputs.PULL_REQUEST_NUMBER }}" >> .env.adhoc + echo "APP_PULL_REQUEST_NUMBER=${{ inputs.APP_PULL_REQUEST_NUMBER }}" >> .env.adhoc - name: Setup Ruby # v1.229.0 @@ -448,13 +448,13 @@ jobs: runs-on: ubuntu-latest if: always() name: Post a GitHub comment with app download links for testing - needs: [prep, getOldDotPR, desktop, web, androidHybrid, iosHybrid] + needs: [prep, getMobileExpensifyPR, desktop, web, androidHybrid, iosHybrid] steps: - name: Checkout # v4 uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: - ref: ${{ needs.prep.outputs.REF }} + ref: ${{ needs.prep.outputs.APP_REF }} - name: Download Artifact # v4 @@ -463,14 +463,14 @@ jobs: - name: Publish links to apps for download uses: ./.github/actions/javascript/postTestBuildComment with: - PR_NUMBER: ${{ inputs.PULL_REQUEST_NUMBER }} - HYBRID_APP_PR_NUMBER: ${{ needs.getOldDotPR.outputs.OLD_DOT_PR }} + APP_PR_NUMBER: ${{ inputs.APP_PULL_REQUEST_NUMBER }} + MOBILE_EXPENSIFY_PR_NUMBER: ${{ needs.getMobileExpensifyPR.outputs.MOBILE_EXPENSIFY_PR }} GITHUB_TOKEN: ${{ github.token }} ANDROID: ${{ needs.androidHybrid.result }} DESKTOP: ${{ needs.desktop.result }} IOS: ${{ needs.iosHybrid.result }} WEB: ${{ needs.web.result }} ANDROID_LINK: ${{ needs.androidHybrid.outputs.S3_APK_PATH }} - DESKTOP_LINK: https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/${{ inputs.PULL_REQUEST_NUMBER }}/NewExpensify.dmg + DESKTOP_LINK: https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/${{ inputs.APP_PULL_REQUEST_NUMBER }}/NewExpensify.dmg IOS_LINK: ${{ needs.iosHybrid.outputs.IOS_PATH }} - WEB_LINK: https://${{ inputs.PULL_REQUEST_NUMBER }}.pr-testing.expensify.com + WEB_LINK: https://${{ inputs.APP_PULL_REQUEST_NUMBER }}.pr-testing.expensify.com diff --git a/tests/unit/postTestBuildComment.ts b/tests/unit/postTestBuildComment.ts index f204a269446c..753fc4ca7466 100644 --- a/tests/unit/postTestBuildComment.ts +++ b/tests/unit/postTestBuildComment.ts @@ -92,8 +92,8 @@ describe('Post test build comments action tests', () => { test('Test GH action', async () => { when(core.getInput).calledWith('REPO', {required: true}).mockReturnValue(CONST.APP_REPO); - when(core.getInput).calledWith('PR_NUMBER', {required: true}).mockReturnValue('12'); - when(core.getInput).calledWith('HYBRID_APP_PR_NUMBER', {required: false}).mockReturnValue('13'); + when(core.getInput).calledWith('APP_PR_NUMBER', {required: true}).mockReturnValue('12'); + when(core.getInput).calledWith('MOBILE_EXPENSIFY_PR_NUMBER', {required: false}).mockReturnValue('13'); when(core.getInput).calledWith('ANDROID', {required: false}).mockReturnValue('success'); when(core.getInput).calledWith('IOS', {required: false}).mockReturnValue('success'); when(core.getInput).calledWith('WEB', {required: false}).mockReturnValue('success'); @@ -129,8 +129,8 @@ describe('Post test build comments action tests', () => { test('Test GH action when input is not complete', async () => { when(core.getInput).calledWith('REPO', {required: true}).mockReturnValue(CONST.APP_REPO); - when(core.getInput).calledWith('PR_NUMBER', {required: true}).mockReturnValue('12'); - when(core.getInput).calledWith('HYBRID_APP_PR_NUMBER', {required: false}).mockReturnValue(''); + when(core.getInput).calledWith('APP_PR_NUMBER', {required: true}).mockReturnValue('12'); + when(core.getInput).calledWith('MOBILE_EXPENSIFY_PR_NUMBER', {required: false}).mockReturnValue(''); when(core.getInput).calledWith('ANDROID', {required: false}).mockReturnValue(''); when(core.getInput).calledWith('IOS', {required: false}).mockReturnValue(''); when(core.getInput).calledWith('WEB', {required: false}).mockReturnValue(''); From e20181b36e8fb50c03be60f96db8667c0e7d5188 Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Sat, 24 May 2025 08:41:26 +0700 Subject: [PATCH 11/22] make App PR optional --- .../postTestBuildComment/action.yml | 2 +- .../javascript/postTestBuildComment/index.js | 24 ++++++---- .../postTestBuildComment.ts | 29 ++++++++---- .github/workflows/testBuild.yml | 45 +++++++++++++++---- 4 files changed, 73 insertions(+), 27 deletions(-) diff --git a/.github/actions/javascript/postTestBuildComment/action.yml b/.github/actions/javascript/postTestBuildComment/action.yml index b476e892da69..ad97aa9015f4 100644 --- a/.github/actions/javascript/postTestBuildComment/action.yml +++ b/.github/actions/javascript/postTestBuildComment/action.yml @@ -6,7 +6,7 @@ inputs: default: App APP_PR_NUMBER: description: "Pull request number for Expensify/App repository" - required: true + required: false MOBILE_EXPENSIFY_PR_NUMBER: description: "Pull request number for Expensify/Mobile-Expensify repository" required: false diff --git a/.github/actions/javascript/postTestBuildComment/index.js b/.github/actions/javascript/postTestBuildComment/index.js index 1151b26c3acd..7563d95e9cf1 100644 --- a/.github/actions/javascript/postTestBuildComment/index.js +++ b/.github/actions/javascript/postTestBuildComment/index.js @@ -11526,16 +11526,19 @@ function getTestBuildMessage(appPr, mobileExpensifyPr) { }; return acc; }, {}); - const message = `:test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! :test_tube::test_tube: -Built from App PR Expensify/App#${appPr}${mobileExpensifyPr ? ` and Mobile-Expensify PR Expensify/Mobile-Expensify#${mobileExpensifyPr}` : ''}. + const message = `:test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS${appPr ? ', Desktop, and Web' : ''}. Happy testing! :test_tube::test_tube: +Built from${appPr ? ` App PR Expensify/App#${appPr}` : ''}${mobileExpensifyPr ? ` and Mobile-Expensify PR Expensify/Mobile-Expensify#${mobileExpensifyPr}` : ''}. | Android :robot: | iOS :apple: | | ------------- | ------------- | -| Android :robot::arrows_counterclockwise: | iOS :apple::arrows_counterclockwise: | | ${result.ANDROID.link} | ${result.IOS.link} | | ${result.ANDROID.qrCode} | ${result.IOS.qrCode} | -| Desktop :computer: | Web :spider_web: | + +${appPr + ? `| Desktop :computer: | Web :spider_web: | +| ------------- | ------------- | | ${result.DESKTOP.link} | ${result.WEB.link} | -| ${result.DESKTOP.qrCode} | ${result.WEB.qrCode} | +| ${result.DESKTOP.qrCode} | ${result.WEB.qrCode} |` + : ''} --- @@ -11558,18 +11561,23 @@ async function commentPR(REPO, PR, message) { } } async function run() { - const APP_PR_NUMBER = Number(core.getInput('APP_PR_NUMBER', { required: true })); + const APP_PR_NUMBER = Number(core.getInput('APP_PR_NUMBER', { required: false })); const MOBILE_EXPENSIFY_PR_NUMBER = Number(core.getInput('MOBILE_EXPENSIFY_PR_NUMBER', { required: false })); const REPO = String(core.getInput('REPO', { required: true })); + if (!APP_PR_NUMBER && !MOBILE_EXPENSIFY_PR_NUMBER) { + core.setFailed('Please provide either App or Mobile-Expensify pull request number'); + return; + } if (REPO !== CONST_1.default.APP_REPO && REPO !== CONST_1.default.MOBILE_EXPENSIFY_REPO) { core.setFailed(`Invalid repository used to place output comment: ${REPO}`); return; } + const destinationPRNumber = REPO === CONST_1.default.APP_REPO ? APP_PR_NUMBER : MOBILE_EXPENSIFY_PR_NUMBER; const comments = await GithubUtils_1.default.paginate(GithubUtils_1.default.octokit.issues.listComments, { owner: CONST_1.default.GITHUB_OWNER, repo: REPO, // eslint-disable-next-line @typescript-eslint/naming-convention - issue_number: APP_PR_NUMBER, + issue_number: destinationPRNumber, // eslint-disable-next-line @typescript-eslint/naming-convention per_page: 100, }, (response) => response.data); @@ -11586,7 +11594,7 @@ async function run() { } `); } - await commentPR(REPO, APP_PR_NUMBER, getTestBuildMessage(APP_PR_NUMBER, MOBILE_EXPENSIFY_PR_NUMBER)); + await commentPR(REPO, destinationPRNumber, getTestBuildMessage(APP_PR_NUMBER, MOBILE_EXPENSIFY_PR_NUMBER)); } if (require.main === require.cache[eval('__filename')]) { run(); diff --git a/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts b/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts index 180bfc7dd995..bd4142caf686 100644 --- a/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts +++ b/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts @@ -4,7 +4,7 @@ import type {TupleToUnion} from 'type-fest'; import CONST from '@github/libs/CONST'; import GithubUtils from '@github/libs/GithubUtils'; -function getTestBuildMessage(appPr: number, mobileExpensifyPr?: number): string { +function getTestBuildMessage(appPr?: number, mobileExpensifyPr?: number): string { const inputs = ['ANDROID', 'DESKTOP', 'IOS', 'WEB'] as const; const names = { [inputs[0]]: 'Android', @@ -35,16 +35,21 @@ function getTestBuildMessage(appPr: number, mobileExpensifyPr?: number): string return acc; }, {} as Record, {link: string; qrCode: string}>); - const message = `:test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! :test_tube::test_tube: -Built from App PR Expensify/App#${appPr}${mobileExpensifyPr ? ` and Mobile-Expensify PR Expensify/Mobile-Expensify#${mobileExpensifyPr}` : ''}. + const message = `:test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS${appPr ? ', Desktop, and Web' : ''}. Happy testing! :test_tube::test_tube: +Built from${appPr ? ` App PR Expensify/App#${appPr}` : ''}${mobileExpensifyPr ? ` and Mobile-Expensify PR Expensify/Mobile-Expensify#${mobileExpensifyPr}` : ''}. | Android :robot: | iOS :apple: | | ------------- | ------------- | -| Android :robot::arrows_counterclockwise: | iOS :apple::arrows_counterclockwise: | | ${result.ANDROID.link} | ${result.IOS.link} | | ${result.ANDROID.qrCode} | ${result.IOS.qrCode} | -| Desktop :computer: | Web :spider_web: | + +${ + appPr + ? `| Desktop :computer: | Web :spider_web: | +| ------------- | ------------- | | ${result.DESKTOP.link} | ${result.WEB.link} | -| ${result.DESKTOP.qrCode} | ${result.WEB.qrCode} | +| ${result.DESKTOP.qrCode} | ${result.WEB.qrCode} |` + : '' +} --- @@ -70,22 +75,28 @@ async function commentPR(REPO: string, PR: number, message: string) { } async function run() { - const APP_PR_NUMBER = Number(core.getInput('APP_PR_NUMBER', {required: true})); + const APP_PR_NUMBER = Number(core.getInput('APP_PR_NUMBER', {required: false})); const MOBILE_EXPENSIFY_PR_NUMBER = Number(core.getInput('MOBILE_EXPENSIFY_PR_NUMBER', {required: false})); const REPO = String(core.getInput('REPO', {required: true})); + if (!APP_PR_NUMBER && !MOBILE_EXPENSIFY_PR_NUMBER) { + core.setFailed('Please provide either App or Mobile-Expensify pull request number'); + return; + } + if (REPO !== CONST.APP_REPO && REPO !== CONST.MOBILE_EXPENSIFY_REPO) { core.setFailed(`Invalid repository used to place output comment: ${REPO}`); return; } + const destinationPRNumber = REPO === CONST.APP_REPO ? APP_PR_NUMBER : MOBILE_EXPENSIFY_PR_NUMBER; const comments = await GithubUtils.paginate( GithubUtils.octokit.issues.listComments, { owner: CONST.GITHUB_OWNER, repo: REPO, // eslint-disable-next-line @typescript-eslint/naming-convention - issue_number: APP_PR_NUMBER, + issue_number: destinationPRNumber, // eslint-disable-next-line @typescript-eslint/naming-convention per_page: 100, }, @@ -104,7 +115,7 @@ async function run() { } `); } - await commentPR(REPO, APP_PR_NUMBER, getTestBuildMessage(APP_PR_NUMBER, MOBILE_EXPENSIFY_PR_NUMBER)); + await commentPR(REPO, destinationPRNumber, getTestBuildMessage(APP_PR_NUMBER, MOBILE_EXPENSIFY_PR_NUMBER)); } if (require.main === module) { diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index f9725efc87be..1513c2b74385 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -3,9 +3,11 @@ name: Build and deploy apps for testing on: workflow_dispatch: inputs: + # If not specified, only build iOS and Android apps from the main branch of Expensify/App APP_PULL_REQUEST_NUMBER: description: Expensify/App PR number for correct placement of apps - required: true + required: false + default: '' # Pull Request number from Mobile-Expensify repo for correct placement of OD app. It will take precedence over MOBILE-EXPENSIFY from App's PR description if both are specified. If nothing is specified defaults to Mobile-Expensify's main MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER: description: Expensify/Mobile-Expensify PR number. Defaults to main. Overrides MOBILE-EXPENSIFY set in App's PR description. @@ -41,7 +43,7 @@ jobs: prep: runs-on: ubuntu-latest outputs: - APP_REF: ${{ steps.getHeadRef.outputs.REF }} + APP_REF: ${{ steps.getHeadRef.outputs.REF || 'main' }} steps: - name: Checkout # v4 @@ -59,12 +61,23 @@ jobs: echo "::error::🕵️‍♀️ Please carefully review the pull request before running a test build to ensure it does not contain any malicious code" exit 1 + - name: Check if either App or Mobile-Expensify pull request number is provided + if: ${{ inputs.APP_PULL_REQUEST_NUMBER || inputs.MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER }} + id: checkPRs + run: | + echo "::error::🕵️‍♀️ Please provide either App or Mobile-Expensify pull request number" + exit 1 + - name: Check if App pull request number is correct if: ${{ github.event_name == 'workflow_dispatch' }} id: getHeadRef run: | set -e - echo "REF=$(gh pr view ${{ inputs.APP_PULL_REQUEST_NUMBER }} --json headRefOid --jq '.headRefOid')" >> "$GITHUB_OUTPUT" + if [ -z "${{ inputs.APP_PULL_REQUEST_NUMBER }}" ]; then + echo "REF=" >> "$GITHUB_OUTPUT" + else + echo "REF=$(gh pr view ${{ inputs.APP_PULL_REQUEST_NUMBER }} --json headRefOid --jq '.headRefOid')" >> "$GITHUB_OUTPUT" + fi env: GITHUB_TOKEN: ${{ github.token }} @@ -127,12 +140,12 @@ jobs: needs: [prep, getMobileExpensifyPR, getMobileExpensifyRef] secrets: inherit with: - APP_PULL_REQUEST_NUMBER: ${{ github.event.number || inputs.APP_PULL_REQUEST_NUMBER }} + APP_PULL_REQUEST_NUMBER: ${{ inputs.APP_PULL_REQUEST_NUMBER }} MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER: ${{ inputs.MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER }} desktop: name: Build and deploy Desktop for testing - if: ${{ inputs.DESKTOP }} + if: ${{ inputs.DESKTOP && inputs.APP_PULL_REQUEST_NUMBER }} needs: [prep] runs-on: macos-14-large steps: @@ -186,7 +199,7 @@ jobs: web: name: Build and deploy Web - if: ${{ inputs.WEB }} + if: ${{ inputs.WEB && inputs.APP_PULL_REQUEST_NUMBER }} needs: [prep] runs-on: ubuntu-latest-xl steps: @@ -232,7 +245,7 @@ jobs: uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: submodules: true - ref: ${{ needs.prep.outputs.APP_REF || 'main' }} + ref: ${{ needs.prep.outputs.APP_REF }} token: ${{ secrets.OS_BOTIFY_TOKEN }} - name: Checkout Mobile-Expensify to specified branch or commit @@ -347,7 +360,7 @@ jobs: uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: submodules: true - ref: ${{ needs.prep.outputs.APP_REF || 'main'}} + ref: ${{ needs.prep.outputs.APP_REF }} token: ${{ secrets.OS_BOTIFY_TOKEN }} - name: Checkout Mobile-Expensify to specified branch or commit @@ -460,9 +473,11 @@ jobs: # v4 uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e - - name: Publish links to apps for download + - name: Publish links to apps for download on Expensify/App PR + if: ${{ inputs.APP_PULL_REQUEST_NUMBER }} uses: ./.github/actions/javascript/postTestBuildComment with: + REPO: App APP_PR_NUMBER: ${{ inputs.APP_PULL_REQUEST_NUMBER }} MOBILE_EXPENSIFY_PR_NUMBER: ${{ needs.getMobileExpensifyPR.outputs.MOBILE_EXPENSIFY_PR }} GITHUB_TOKEN: ${{ github.token }} @@ -474,3 +489,15 @@ jobs: DESKTOP_LINK: https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/${{ inputs.APP_PULL_REQUEST_NUMBER }}/NewExpensify.dmg IOS_LINK: ${{ needs.iosHybrid.outputs.IOS_PATH }} WEB_LINK: https://${{ inputs.APP_PULL_REQUEST_NUMBER }}.pr-testing.expensify.com + + - name: Publish links to apps for download on Expensify/Mobile-Expensify PR + if: ${{ needs.getMobileExpensifyPR.outputs.MOBILE_EXPENSIFY_PR }} + uses: ./.github/actions/javascript/postTestBuildComment + with: + REPO: Mobile-Expensify + MOBILE_EXPENSIFY_PR_NUMBER: ${{ needs.getMobileExpensifyPR.outputs.MOBILE_EXPENSIFY_PR }} + GITHUB_TOKEN: ${{ github.token }} + ANDROID: ${{ needs.androidHybrid.result }} + IOS: ${{ needs.iosHybrid.result }} + ANDROID_LINK: ${{ needs.androidHybrid.outputs.S3_APK_PATH }} + IOS_LINK: ${{ needs.iosHybrid.outputs.IOS_PATH }} \ No newline at end of file From ef32eb0d4887364c77e3d307cd3050ec3bb671ae Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Sat, 24 May 2025 09:01:16 +0700 Subject: [PATCH 12/22] update unit test --- .../javascript/postTestBuildComment/index.js | 8 +-- .../postTestBuildComment.ts | 8 +-- tests/unit/postTestBuildComment.ts | 55 +++++++++++++++++-- 3 files changed, 59 insertions(+), 12 deletions(-) diff --git a/.github/actions/javascript/postTestBuildComment/index.js b/.github/actions/javascript/postTestBuildComment/index.js index 7563d95e9cf1..8649d9f5707a 100644 --- a/.github/actions/javascript/postTestBuildComment/index.js +++ b/.github/actions/javascript/postTestBuildComment/index.js @@ -11564,14 +11564,14 @@ async function run() { const APP_PR_NUMBER = Number(core.getInput('APP_PR_NUMBER', { required: false })); const MOBILE_EXPENSIFY_PR_NUMBER = Number(core.getInput('MOBILE_EXPENSIFY_PR_NUMBER', { required: false })); const REPO = String(core.getInput('REPO', { required: true })); - if (!APP_PR_NUMBER && !MOBILE_EXPENSIFY_PR_NUMBER) { - core.setFailed('Please provide either App or Mobile-Expensify pull request number'); - return; - } if (REPO !== CONST_1.default.APP_REPO && REPO !== CONST_1.default.MOBILE_EXPENSIFY_REPO) { core.setFailed(`Invalid repository used to place output comment: ${REPO}`); return; } + if ((REPO === CONST_1.default.APP_REPO && !APP_PR_NUMBER) || (REPO === CONST_1.default.MOBILE_EXPENSIFY_REPO && !MOBILE_EXPENSIFY_PR_NUMBER)) { + core.setFailed(`Please provide ${REPO} pull request number`); + return; + } const destinationPRNumber = REPO === CONST_1.default.APP_REPO ? APP_PR_NUMBER : MOBILE_EXPENSIFY_PR_NUMBER; const comments = await GithubUtils_1.default.paginate(GithubUtils_1.default.octokit.issues.listComments, { owner: CONST_1.default.GITHUB_OWNER, diff --git a/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts b/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts index bd4142caf686..330314d474a5 100644 --- a/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts +++ b/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts @@ -79,13 +79,13 @@ async function run() { const MOBILE_EXPENSIFY_PR_NUMBER = Number(core.getInput('MOBILE_EXPENSIFY_PR_NUMBER', {required: false})); const REPO = String(core.getInput('REPO', {required: true})); - if (!APP_PR_NUMBER && !MOBILE_EXPENSIFY_PR_NUMBER) { - core.setFailed('Please provide either App or Mobile-Expensify pull request number'); + if (REPO !== CONST.APP_REPO && REPO !== CONST.MOBILE_EXPENSIFY_REPO) { + core.setFailed(`Invalid repository used to place output comment: ${REPO}`); return; } - if (REPO !== CONST.APP_REPO && REPO !== CONST.MOBILE_EXPENSIFY_REPO) { - core.setFailed(`Invalid repository used to place output comment: ${REPO}`); + if ((REPO === CONST.APP_REPO && !APP_PR_NUMBER) || (REPO === CONST.MOBILE_EXPENSIFY_REPO && !MOBILE_EXPENSIFY_PR_NUMBER)) { + core.setFailed(`Please provide ${REPO} pull request number`); return; } diff --git a/tests/unit/postTestBuildComment.ts b/tests/unit/postTestBuildComment.ts index 753fc4ca7466..2f8fd3d9d964 100644 --- a/tests/unit/postTestBuildComment.ts +++ b/tests/unit/postTestBuildComment.ts @@ -54,10 +54,11 @@ const message = `:test_tube::test_tube: Use the links below to test this adhoc b Built from App PR Expensify/App#12 and Mobile-Expensify PR Expensify/Mobile-Expensify#13. | Android :robot: | iOS :apple: | | ------------- | ------------- | -| Android :robot::arrows_counterclockwise: | iOS :apple::arrows_counterclockwise: | | ${androidLink} | ${iOSLink} | | ${androidQRCode} | ${iOSQRCode} | + | Desktop :computer: | Web :spider_web: | +| ------------- | ------------- | | ${desktopLink} | ${webLink} | | ${desktopQRCode} | ${webQRCode} | @@ -70,13 +71,27 @@ const onlyAndroidMessage = `:test_tube::test_tube: Use the links below to test t Built from App PR Expensify/App#12. | Android :robot: | iOS :apple: | | ------------- | ------------- | -| Android :robot::arrows_counterclockwise: | iOS :apple::arrows_counterclockwise: | | N/A | N/A | | N/A | N/A | + | Desktop :computer: | Web :spider_web: | +| ------------- | ------------- | | N/A | N/A | | N/A | N/A | +--- + +:eyes: [View the workflow run that generated this build](https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/1234) :eyes: +`; + +const onlyMobileExpensifyMessage = `:test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS. Happy testing! :test_tube::test_tube: +Built from Mobile-Expensify PR Expensify/Mobile-Expensify#13. +| Android :robot: | iOS :apple: | +| ------------- | ------------- | +| ${androidLink} | ${iOSLink} | +| ${androidQRCode} | ${iOSQRCode} | + + --- :eyes: [View the workflow run that generated this build](https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/1234) :eyes: @@ -92,7 +107,7 @@ describe('Post test build comments action tests', () => { test('Test GH action', async () => { when(core.getInput).calledWith('REPO', {required: true}).mockReturnValue(CONST.APP_REPO); - when(core.getInput).calledWith('APP_PR_NUMBER', {required: true}).mockReturnValue('12'); + when(core.getInput).calledWith('APP_PR_NUMBER', {required: false}).mockReturnValue('12'); when(core.getInput).calledWith('MOBILE_EXPENSIFY_PR_NUMBER', {required: false}).mockReturnValue('13'); when(core.getInput).calledWith('ANDROID', {required: false}).mockReturnValue('success'); when(core.getInput).calledWith('IOS', {required: false}).mockReturnValue('success'); @@ -129,7 +144,7 @@ describe('Post test build comments action tests', () => { test('Test GH action when input is not complete', async () => { when(core.getInput).calledWith('REPO', {required: true}).mockReturnValue(CONST.APP_REPO); - when(core.getInput).calledWith('APP_PR_NUMBER', {required: true}).mockReturnValue('12'); + when(core.getInput).calledWith('APP_PR_NUMBER', {required: false}).mockReturnValue('12'); when(core.getInput).calledWith('MOBILE_EXPENSIFY_PR_NUMBER', {required: false}).mockReturnValue(''); when(core.getInput).calledWith('ANDROID', {required: false}).mockReturnValue(''); when(core.getInput).calledWith('IOS', {required: false}).mockReturnValue(''); @@ -160,4 +175,36 @@ describe('Post test build comments action tests', () => { expect(createCommentMock).toBeCalledTimes(1); expect(createCommentMock).toBeCalledWith(CONST.APP_REPO, 12, onlyAndroidMessage); }); + + test('Test GH action when only Mobile-Expensify PR number is provided', async () => { + when(core.getInput).calledWith('REPO', {required: true}).mockReturnValue(CONST.MOBILE_EXPENSIFY_REPO); + when(core.getInput).calledWith('MOBILE_EXPENSIFY_PR_NUMBER', {required: false}).mockReturnValue('13'); + when(core.getInput).calledWith('ANDROID', {required: false}).mockReturnValue('success'); + when(core.getInput).calledWith('IOS', {required: false}).mockReturnValue('success'); + when(core.getInput).calledWith('ANDROID_LINK').mockReturnValue(androidLink); + when(core.getInput).calledWith('IOS_LINK').mockReturnValue(iOSLink); + createCommentMock.mockResolvedValue({} as CreateCommentResponse); + mockListComments.mockResolvedValue({ + data: [ + { + body: ':test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS. Happy testing!', + // eslint-disable-next-line @typescript-eslint/naming-convention + node_id: 'IC_abcd', + }, + ], + }); + await ghAction(); + expect(mockGraphql).toBeCalledTimes(1); + expect(mockGraphql).toBeCalledWith(` + mutation { + minimizeComment(input: {classifier: OUTDATED, subjectId: "IC_abcd"}) { + minimizedComment { + minimizedReason + } + } + } + `); + expect(createCommentMock).toBeCalledTimes(1); + expect(createCommentMock).toBeCalledWith(CONST.MOBILE_EXPENSIFY_REPO, 13, onlyMobileExpensifyMessage); + }); }); From 1b6cffb1cbff080e35ca3c5dbedc8af7efd9eb2b Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Sat, 24 May 2025 09:13:37 +0700 Subject: [PATCH 13/22] fix unit test --- tests/unit/postTestBuildComment.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/unit/postTestBuildComment.ts b/tests/unit/postTestBuildComment.ts index 2f8fd3d9d964..617825709193 100644 --- a/tests/unit/postTestBuildComment.ts +++ b/tests/unit/postTestBuildComment.ts @@ -142,7 +142,7 @@ describe('Post test build comments action tests', () => { expect(createCommentMock).toBeCalledWith(CONST.APP_REPO, 12, message); }); - test('Test GH action when input is not complete', async () => { + test('Test GH action when only App PR number is provided', async () => { when(core.getInput).calledWith('REPO', {required: true}).mockReturnValue(CONST.APP_REPO); when(core.getInput).calledWith('APP_PR_NUMBER', {required: false}).mockReturnValue('12'); when(core.getInput).calledWith('MOBILE_EXPENSIFY_PR_NUMBER', {required: false}).mockReturnValue(''); @@ -178,6 +178,7 @@ describe('Post test build comments action tests', () => { test('Test GH action when only Mobile-Expensify PR number is provided', async () => { when(core.getInput).calledWith('REPO', {required: true}).mockReturnValue(CONST.MOBILE_EXPENSIFY_REPO); + when(core.getInput).calledWith('APP_PR_NUMBER', {required: false}).mockReturnValue(''); when(core.getInput).calledWith('MOBILE_EXPENSIFY_PR_NUMBER', {required: false}).mockReturnValue('13'); when(core.getInput).calledWith('ANDROID', {required: false}).mockReturnValue('success'); when(core.getInput).calledWith('IOS', {required: false}).mockReturnValue('success'); From 4c94eac84dc197da7174b05b5f0a8a3b7f56da9e Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Sat, 24 May 2025 09:31:01 +0700 Subject: [PATCH 14/22] update ut --- .github/actions/javascript/postTestBuildComment/index.js | 3 +-- .../javascript/postTestBuildComment/postTestBuildComment.ts | 3 +-- tests/unit/postTestBuildComment.ts | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/actions/javascript/postTestBuildComment/index.js b/.github/actions/javascript/postTestBuildComment/index.js index 8649d9f5707a..3a8a6fc28a4e 100644 --- a/.github/actions/javascript/postTestBuildComment/index.js +++ b/.github/actions/javascript/postTestBuildComment/index.js @@ -11532,9 +11532,8 @@ Built from${appPr ? ` App PR Expensify/App#${appPr}` : ''}${mobileExpensifyPr ? | ------------- | ------------- | | ${result.ANDROID.link} | ${result.IOS.link} | | ${result.ANDROID.qrCode} | ${result.IOS.qrCode} | - ${appPr - ? `| Desktop :computer: | Web :spider_web: | + ? `\n| Desktop :computer: | Web :spider_web: | | ------------- | ------------- | | ${result.DESKTOP.link} | ${result.WEB.link} | | ${result.DESKTOP.qrCode} | ${result.WEB.qrCode} |` diff --git a/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts b/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts index 330314d474a5..62cc29bf8646 100644 --- a/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts +++ b/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts @@ -41,10 +41,9 @@ Built from${appPr ? ` App PR Expensify/App#${appPr}` : ''}${mobileExpensifyPr ? | ------------- | ------------- | | ${result.ANDROID.link} | ${result.IOS.link} | | ${result.ANDROID.qrCode} | ${result.IOS.qrCode} | - ${ appPr - ? `| Desktop :computer: | Web :spider_web: | + ? `\n| Desktop :computer: | Web :spider_web: | | ------------- | ------------- | | ${result.DESKTOP.link} | ${result.WEB.link} | | ${result.DESKTOP.qrCode} | ${result.WEB.qrCode} |` diff --git a/tests/unit/postTestBuildComment.ts b/tests/unit/postTestBuildComment.ts index 617825709193..5c15d5988e8b 100644 --- a/tests/unit/postTestBuildComment.ts +++ b/tests/unit/postTestBuildComment.ts @@ -91,7 +91,6 @@ Built from Mobile-Expensify PR Expensify/Mobile-Expensify#13. | ${androidLink} | ${iOSLink} | | ${androidQRCode} | ${iOSQRCode} | - --- :eyes: [View the workflow run that generated this build](https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/1234) :eyes: From 48a17c807d700d13e30158a5f7e4e7642c4211c5 Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Sat, 24 May 2025 09:38:13 +0700 Subject: [PATCH 15/22] fix ut --- .github/actions/javascript/postTestBuildComment/index.js | 3 +-- .../javascript/postTestBuildComment/postTestBuildComment.ts | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/actions/javascript/postTestBuildComment/index.js b/.github/actions/javascript/postTestBuildComment/index.js index 3a8a6fc28a4e..527022e31bb1 100644 --- a/.github/actions/javascript/postTestBuildComment/index.js +++ b/.github/actions/javascript/postTestBuildComment/index.js @@ -11536,9 +11536,8 @@ ${appPr ? `\n| Desktop :computer: | Web :spider_web: | | ------------- | ------------- | | ${result.DESKTOP.link} | ${result.WEB.link} | -| ${result.DESKTOP.qrCode} | ${result.WEB.qrCode} |` +| ${result.DESKTOP.qrCode} | ${result.WEB.qrCode} |\n` : ''} - --- :eyes: [View the workflow run that generated this build](https://github.com/${github_1.context.repo.owner}/${github_1.context.repo.repo}/actions/runs/${github_1.context.runId}) :eyes: diff --git a/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts b/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts index 62cc29bf8646..25e57a56146a 100644 --- a/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts +++ b/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts @@ -46,10 +46,9 @@ ${ ? `\n| Desktop :computer: | Web :spider_web: | | ------------- | ------------- | | ${result.DESKTOP.link} | ${result.WEB.link} | -| ${result.DESKTOP.qrCode} | ${result.WEB.qrCode} |` +| ${result.DESKTOP.qrCode} | ${result.WEB.qrCode} |\n` : '' } - --- :eyes: [View the workflow run that generated this build](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}) :eyes: From 6173d79a68344f8be3738bd74f196d1e78db68a6 Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Sun, 1 Jun 2025 01:14:33 +0700 Subject: [PATCH 16/22] fix test --- .github/actions/javascript/postTestBuildComment/index.js | 2 +- .../javascript/postTestBuildComment/postTestBuildComment.ts | 2 +- tests/unit/postTestBuildComment.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/javascript/postTestBuildComment/index.js b/.github/actions/javascript/postTestBuildComment/index.js index 527022e31bb1..e4b69f7bcfc1 100644 --- a/.github/actions/javascript/postTestBuildComment/index.js +++ b/.github/actions/javascript/postTestBuildComment/index.js @@ -11527,7 +11527,7 @@ function getTestBuildMessage(appPr, mobileExpensifyPr) { return acc; }, {}); const message = `:test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS${appPr ? ', Desktop, and Web' : ''}. Happy testing! :test_tube::test_tube: -Built from${appPr ? ` App PR Expensify/App#${appPr}` : ''}${mobileExpensifyPr ? ` and Mobile-Expensify PR Expensify/Mobile-Expensify#${mobileExpensifyPr}` : ''}. +Built from${appPr ? ` App PR Expensify/App#${appPr}` : ''}${mobileExpensifyPr ? ` Mobile-Expensify PR Expensify/Mobile-Expensify#${mobileExpensifyPr}` : ''}. | Android :robot: | iOS :apple: | | ------------- | ------------- | | ${result.ANDROID.link} | ${result.IOS.link} | diff --git a/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts b/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts index c11a9cdeb82c..20788e5c9f32 100644 --- a/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts +++ b/.github/actions/javascript/postTestBuildComment/postTestBuildComment.ts @@ -39,7 +39,7 @@ function getTestBuildMessage(appPr?: number, mobileExpensifyPr?: number): string ); const message = `:test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS${appPr ? ', Desktop, and Web' : ''}. Happy testing! :test_tube::test_tube: -Built from${appPr ? ` App PR Expensify/App#${appPr}` : ''}${mobileExpensifyPr ? ` and Mobile-Expensify PR Expensify/Mobile-Expensify#${mobileExpensifyPr}` : ''}. +Built from${appPr ? ` App PR Expensify/App#${appPr}` : ''}${mobileExpensifyPr ? ` Mobile-Expensify PR Expensify/Mobile-Expensify#${mobileExpensifyPr}` : ''}. | Android :robot: | iOS :apple: | | ------------- | ------------- | | ${result.ANDROID.link} | ${result.IOS.link} | diff --git a/tests/unit/postTestBuildComment.ts b/tests/unit/postTestBuildComment.ts index 5dbf034457bd..5246f0345e87 100644 --- a/tests/unit/postTestBuildComment.ts +++ b/tests/unit/postTestBuildComment.ts @@ -54,7 +54,7 @@ const iOSQRCode = `![iOS](https://api.qrserver.com/v1/create-qr-code/?size=120x1 const webQRCode = `![Web](https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=${webLink})`; const message = `:test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! :test_tube::test_tube: -Built from App PR Expensify/App#12 and Mobile-Expensify PR Expensify/Mobile-Expensify#13. +Built from App PR Expensify/App#12 Mobile-Expensify PR Expensify/Mobile-Expensify#13. | Android :robot: | iOS :apple: | | ------------- | ------------- | | ${androidLink} | ${iOSLink} | From a5cf38abf76b2bda8df65e177b25c850366d1151 Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Sun, 1 Jun 2025 01:27:26 +0700 Subject: [PATCH 17/22] post comment to E/App PR if none was provided --- .github/workflows/testBuild.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index 1513c2b74385..37d699c4676b 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -5,7 +5,7 @@ on: inputs: # If not specified, only build iOS and Android apps from the main branch of Expensify/App APP_PULL_REQUEST_NUMBER: - description: Expensify/App PR number for correct placement of apps + description: Expensify/App PR number for correct placement of apps. Default to main. required: false default: '' # Pull Request number from Mobile-Expensify repo for correct placement of OD app. It will take precedence over MOBILE-EXPENSIFY from App's PR description if both are specified. If nothing is specified defaults to Mobile-Expensify's main @@ -61,13 +61,6 @@ jobs: echo "::error::🕵️‍♀️ Please carefully review the pull request before running a test build to ensure it does not contain any malicious code" exit 1 - - name: Check if either App or Mobile-Expensify pull request number is provided - if: ${{ inputs.APP_PULL_REQUEST_NUMBER || inputs.MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER }} - id: checkPRs - run: | - echo "::error::🕵️‍♀️ Please provide either App or Mobile-Expensify pull request number" - exit 1 - - name: Check if App pull request number is correct if: ${{ github.event_name == 'workflow_dispatch' }} id: getHeadRef @@ -115,7 +108,7 @@ jobs: runs-on: ubuntu-latest needs: [getMobileExpensifyPR] outputs: - MOBILE_EXPENSIFY_REF: ${{ steps.getHeadRef.outputs.REF }} + MOBILE_EXPENSIFY_REF: ${{ steps.getHeadRef.outputs.REF || 'main' }} steps: - name: Checkout # v4 @@ -474,7 +467,7 @@ jobs: uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e - name: Publish links to apps for download on Expensify/App PR - if: ${{ inputs.APP_PULL_REQUEST_NUMBER }} + if: ${{ inputs.APP_PULL_REQUEST_NUMBER || (!inputs.APP_PULL_REQUEST_NUMBER && !needs.getMobileExpensifyPR.outputs.MOBILE_EXPENSIFY_PR) }} uses: ./.github/actions/javascript/postTestBuildComment with: REPO: App From df6249a7d0c1c20080c39154ceb80297cda71952 Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Thu, 5 Jun 2025 01:39:24 +0700 Subject: [PATCH 18/22] remove postBuildStartedComment.yml --- .github/workflows/postBuildStartedComment.yml | 47 ------------------- .github/workflows/testBuild.yml | 36 ++++++++++++-- 2 files changed, 31 insertions(+), 52 deletions(-) delete mode 100644 .github/workflows/postBuildStartedComment.yml diff --git a/.github/workflows/postBuildStartedComment.yml b/.github/workflows/postBuildStartedComment.yml deleted file mode 100644 index 0e9f9e019ed8..000000000000 --- a/.github/workflows/postBuildStartedComment.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Post build has been started comment - -on: - workflow_call: - inputs: - APP_PULL_REQUEST_NUMBER: - description: Number of the Pull Request in Expensify/App repository where the comment will be posted - type: string - required: false - MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER: - description: Number of the Pull Request in Expensify/Mobile-Expensify repository where the comment will be posted - type: string - required: false - -jobs: - postGitHubCommentBuildStarted: - runs-on: ubuntu-latest - steps: - - name: Add build start comment to Expensify/App PR - if: ${{ inputs.APP_PULL_REQUEST_NUMBER != ''}} - # v7 - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea - with: - github-token: ${{ github.token }} - script: | - const workflowURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; - github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: ${{ inputs.APP_PULL_REQUEST_NUMBER }}, - body: `🚧 @${{ github.actor }} has triggered a test Expensify/App build. You can view the [workflow run here](${workflowURL}).` - }); - - - name: Add build start comment to Expensify/Mobile-Expensify PR - if: ${{ inputs.MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER != '' }} - # v7 - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea - with: - github-token: ${{ secrets.OS_BOTIFY_TOKEN }} - script: | - const workflowURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; - github.rest.issues.createComment({ - owner: context.repo.owner, - repo: 'Mobile-Expensify', - issue_number: ${{ inputs.MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER }}, - body: `🚧 @${{ github.actor }} has triggered a test Expensify/Mobile-Expensify build. You can view the [workflow run here](${workflowURL}).` - }); \ No newline at end of file diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index 37d699c4676b..3ff690243b42 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -129,12 +129,38 @@ jobs: postGitHubCommentBuildStarted: name: Post build started comment - uses: ./.github/workflows/postBuildStartedComment.yml + runs-on: ubuntu-latest needs: [prep, getMobileExpensifyPR, getMobileExpensifyRef] - secrets: inherit - with: - APP_PULL_REQUEST_NUMBER: ${{ inputs.APP_PULL_REQUEST_NUMBER }} - MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER: ${{ inputs.MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER }} + steps: + - name: Add build start comment to Expensify/App PR + if: ${{ inputs.APP_PULL_REQUEST_NUMBER != ''}} + # v7 + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea + with: + github-token: ${{ github.token }} + script: | + const workflowURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; + github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: ${{ inputs.APP_PULL_REQUEST_NUMBER }}, + body: `🚧 @${{ github.actor }} has triggered a test Expensify/App build. You can view the [workflow run here](${workflowURL}).` + }); + + - name: Add build start comment to Expensify/Mobile-Expensify PR + if: ${{ needs.getMobileExpensifyPR.outputs.MOBILE_EXPENSIFY_PR != '' }} + # v7 + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea + with: + github-token: ${{ secrets.OS_BOTIFY_TOKEN }} + script: | + const workflowURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; + github.rest.issues.createComment({ + owner: context.repo.owner, + repo: 'Mobile-Expensify', + issue_number: ${{ needs.getMobileExpensifyPR.outputs.MOBILE_EXPENSIFY_PR }}, + body: `🚧 @${{ github.actor }} has triggered a test Expensify/Mobile-Expensify build. You can view the [workflow run here](${workflowURL}).` + }); desktop: name: Build and deploy Desktop for testing From 4e6751e8051871558c2f5ab313df1cc925186be9 Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Thu, 5 Jun 2025 01:41:54 +0700 Subject: [PATCH 19/22] revert env name change --- .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 3ff690243b42..a525d4d9b197 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -37,7 +37,7 @@ on: env: # This variable is needed for fastlane to construct correct path - APP_PULL_REQUEST_NUMBER: ${{ inputs.APP_PULL_REQUEST_NUMBER }} + PULL_REQUEST_NUMBER: ${{ inputs.APP_PULL_REQUEST_NUMBER }} jobs: prep: From 922432bd3e2938fd84b1221dd541bdfa65f54885 Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Thu, 5 Jun 2025 01:48:28 +0700 Subject: [PATCH 20/22] correctly export .env.adhoc variables --- .github/workflows/testBuild.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index a525d4d9b197..a3c7e9611342 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -174,11 +174,11 @@ jobs: with: ref: ${{ needs.prep.outputs.APP_REF }} - - name: Create .env.adhoc file based on staging and add APP_PULL_REQUEST_NUMBER env to it + - 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 "APP_PULL_REQUEST_NUMBER=$APP_PULL_REQUEST_NUMBER" >> .env.adhoc + echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.adhoc - name: Setup Node uses: ./.github/actions/composite/setupNode @@ -228,11 +228,11 @@ jobs: with: ref: ${{ needs.prep.outputs.APP_REF }} - - name: Create .env.adhoc file based on staging and add APP_PULL_REQUEST_NUMBER env to it + - 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 "APP_PULL_REQUEST_NUMBER=$APP_PULL_REQUEST_NUMBER" >> .env.adhoc + echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.adhoc - name: Setup Node uses: ./.github/actions/composite/setupNode @@ -293,7 +293,7 @@ jobs: run: | cp .env.staging .env.adhoc sed -i 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc - echo "APP_PULL_REQUEST_NUMBER=${{ inputs.APP_PULL_REQUEST_NUMBER }}" >> .env.adhoc + echo "APP_PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.adhoc - name: Setup Java # v4 @@ -399,11 +399,11 @@ jobs: with: IS_HYBRID_BUILD: 'true' - - name: Create .env.adhoc file based on staging and add APP_PULL_REQUEST_NUMBER env to it + - 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 "APP_PULL_REQUEST_NUMBER=${{ inputs.APP_PULL_REQUEST_NUMBER }}" >> .env.adhoc + echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.adhoc - name: Setup Ruby # v1.229.0 From 3b36bdaac0819e90c4dfeebed2769a3364c69c1e Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Thu, 5 Jun 2025 01:50:55 +0700 Subject: [PATCH 21/22] correctly use env var --- .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 a3c7e9611342..75255a7c5a51 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -249,7 +249,7 @@ jobs: run: npm run build-adhoc - name: Deploy to S3 for internal testing - run: aws s3 cp --recursive --acl public-read "$GITHUB_WORKSPACE"/dist s3://ad-hoc-expensify-cash/web/"$APP_PULL_REQUEST_NUMBER" + run: aws s3 cp --recursive --acl public-read "$GITHUB_WORKSPACE"/dist s3://ad-hoc-expensify-cash/web/"$PULL_REQUEST_NUMBER" androidHybrid: name: Build Android HybridApp From 57d8a9cf3d5ae0ee250057a48d4b63be90ef64f2 Mon Sep 17 00:00:00 2001 From: gijoe0295 <153004152+gijoe0295@users.noreply.github.com> Date: Thu, 5 Jun 2025 01:53:46 +0700 Subject: [PATCH 22/22] fallback incase not provide APP_PR_NUMBER --- .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 75255a7c5a51..8039b92e6a01 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -37,7 +37,7 @@ on: env: # This variable is needed for fastlane to construct correct path - PULL_REQUEST_NUMBER: ${{ inputs.APP_PULL_REQUEST_NUMBER }} + PULL_REQUEST_NUMBER: ${{ inputs.APP_PULL_REQUEST_NUMBER || github.event.number }} jobs: prep: