Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 53 additions & 26 deletions .github/workflows/testBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ 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. Default to main.
APP_PULL_REQUEST_URL:
description: The Expensify/App pull request URL (e.g., https://github.com/Expensify/App/pull/12345). Defaults to main.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if we need the "Defaults to main." here still, but since we're pulling the PR number from the URL, rather than using the URL explicitly, might be good to leave in there. Please let me know if you have any suggestions for rephrasing this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems clear enough to me

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.
# Pull Request URL 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_URL:
description: The Expensify/Mobile-Expensify pull request URL. Defaults to main. Overrides MOBILE-EXPENSIFY set in App's PR description.
required: false
default: ''
REVIEWED_CODE:
Expand All @@ -35,15 +35,13 @@ on:
type: boolean
default: true

env:
# This variable is needed for fastlane to construct correct path
PULL_REQUEST_NUMBER: ${{ inputs.APP_PULL_REQUEST_NUMBER || github.event.number }}

jobs:
prep:
runs-on: ubuntu-latest
outputs:
APP_REF: ${{ steps.getHeadRef.outputs.REF || 'main' }}
APP_PR_NUMBER: ${{ steps.extractAppPRNumber.outputs.PR_NUMBER }}
MOBILE_PR_NUMBER: ${{ steps.extractMobilePRNumber.outputs.PR_NUMBER }}
steps:
- name: Checkout
# v4
Expand All @@ -61,15 +59,37 @@ 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: Extract App PR number from URL
id: extractAppPRNumber
if: ${{ inputs.APP_PULL_REQUEST_URL != '' }}
run: |
PR_NUMBER=$(echo '${{ inputs.APP_PULL_REQUEST_URL }}' | sed -E 's|.*/pull/([0-9]+).*|\1|')
if ! [[ "$PR_NUMBER" =~ ^[0-9]+$ ]]; then
echo "::error::❌ Could not extract PR number from URL. Please provide a valid GitHub PR URL (e.g., https://github.com/Expensify/App/pull/12345)"
exit 1
fi
echo "PR_NUMBER=$PR_NUMBER" >> "$GITHUB_OUTPUT"

- name: Extract Mobile-Expensify PR number from URL
id: extractMobilePRNumber
if: ${{ inputs.MOBILE_EXPENSIFY_PULL_REQUEST_URL != '' }}
run: |
PR_NUMBER=$(echo '${{ inputs.MOBILE_EXPENSIFY_PULL_REQUEST_URL }}' | sed -E 's|.*/pull/([0-9]+).*|\1|')
if ! [[ "$PR_NUMBER" =~ ^[0-9]+$ ]]; then
echo "::error::❌ Could not extract PR number from URL. Please provide a valid GitHub PR URL (e.g., https://github.com/Expensify/Mobile-Expensify/pull/12345)"
exit 1
fi
echo "PR_NUMBER=$PR_NUMBER" >> "$GITHUB_OUTPUT"

- name: Check if App pull request number is correct
if: ${{ github.event_name == 'workflow_dispatch' }}
id: getHeadRef
run: |
set -e
if [ -z "${{ inputs.APP_PULL_REQUEST_NUMBER }}" ]; then
if [ -z "${{ steps.extractAppPRNumber.outputs.PR_NUMBER }}" ]; then
echo "REF=" >> "$GITHUB_OUTPUT"
else
echo "REF=$(gh pr view ${{ inputs.APP_PULL_REQUEST_NUMBER }} --json headRefOid --jq '.headRefOid')" >> "$GITHUB_OUTPUT"
echo "REF=$(gh pr view ${{ steps.extractAppPRNumber.outputs.PR_NUMBER }} --json headRefOid --jq '.headRefOid')" >> "$GITHUB_OUTPUT"
fi
env:
GITHUB_TOKEN: ${{ github.token }}
Expand All @@ -88,14 +108,14 @@ jobs:
github-token: ${{ github.token }}
result-encoding: string
script: |
if ('${{ inputs.MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER}}') return '${{ inputs.MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER}}';
if ('${{ needs.prep.outputs.MOBILE_PR_NUMBER }}') return '${{ needs.prep.outputs.MOBILE_PR_NUMBER }}';

if (!'${{ inputs.APP_PULL_REQUEST_NUMBER }}') return '';
if (!'${{ needs.prep.outputs.APP_PR_NUMBER }}') return '';

const pullRequest = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: '${{ inputs.APP_PULL_REQUEST_NUMBER }}',
pull_number: '${{ needs.prep.outputs.APP_PR_NUMBER }}',
});

const body = pullRequest.data.body;
Expand All @@ -106,7 +126,7 @@ jobs:

getMobileExpensifyRef:
runs-on: ubuntu-latest
needs: [getMobileExpensifyPR]
needs: [prep, getMobileExpensifyPR]
outputs:
MOBILE_EXPENSIFY_REF: ${{ steps.getHeadRef.outputs.REF || 'main' }}
steps:
Expand All @@ -118,11 +138,11 @@ jobs:
id: getHeadRef
run: |
set -e
if [[ -z "${{ inputs.MOBILE_EXPENSIFY_PULL_REQUEST_NUMBER }}" && -z "${{ needs.getMobileExpensifyPR.outputs.MOBILE_EXPENSIFY_PR }}" ]]; then
if [[ -z "${{ needs.prep.outputs.MOBILE_PR_NUMBER }}" && -z "${{ needs.getMobileExpensifyPR.outputs.MOBILE_EXPENSIFY_PR }}" ]]; then
echo "REF=" >> "$GITHUB_OUTPUT"
else
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"
echo "PR=${{ needs.prep.outputs.MOBILE_PR_NUMBER || needs.getMobileExpensifyPR.outputs.MOBILE_EXPENSIFY_PR }}" >> "$GITHUB_OUTPUT"
echo "REF=$(gh pr view ${{ needs.prep.outputs.MOBILE_PR_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 }}
Expand All @@ -133,7 +153,7 @@ jobs:
needs: [prep, getMobileExpensifyPR, getMobileExpensifyRef]
steps:
- name: Add build start comment to Expensify/App PR
if: ${{ inputs.APP_PULL_REQUEST_NUMBER != ''}}
if: ${{ needs.prep.outputs.APP_PR_NUMBER != '' }}
# v7
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
with:
Expand All @@ -143,7 +163,7 @@ jobs:
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ inputs.APP_PULL_REQUEST_NUMBER }},
issue_number: ${{ needs.prep.outputs.APP_PR_NUMBER }},
body: `🚧 @${{ github.actor }} has triggered a test Expensify/App build. You can view the [workflow run here](${workflowURL}).`
});

Expand All @@ -164,9 +184,11 @@ jobs:

desktop:
name: Build and deploy Desktop for testing
if: ${{ inputs.DESKTOP && inputs.APP_PULL_REQUEST_NUMBER }}
if: ${{ inputs.DESKTOP && needs.prep.outputs.APP_PR_NUMBER }}
needs: [prep]
runs-on: macos-14-large
env:
PULL_REQUEST_NUMBER: ${{ needs.prep.outputs.APP_PR_NUMBER }}
steps:
- name: Checkout
# v4
Expand Down Expand Up @@ -231,9 +253,11 @@ jobs:

web:
name: Build and deploy Web
if: ${{ inputs.WEB && inputs.APP_PULL_REQUEST_NUMBER }}
if: ${{ inputs.WEB && needs.prep.outputs.APP_PR_NUMBER }}
needs: [prep]
runs-on: ubuntu-latest-xl
env:
PULL_REQUEST_NUMBER: ${{ needs.prep.outputs.APP_PR_NUMBER }}
steps:
- name: Checkout
# v4
Expand Down Expand Up @@ -271,6 +295,8 @@ jobs:
if: ${{ inputs.ANDROID }}
needs: [prep, getMobileExpensifyPR, getMobileExpensifyRef]
runs-on: ubuntu-latest-xl
env:
PULL_REQUEST_NUMBER: ${{ needs.prep.outputs.APP_PR_NUMBER }}
outputs:
S3_APK_PATH: ${{ steps.exportAndroidS3Path.outputs.S3_APK_PATH }}
steps:
Expand Down Expand Up @@ -392,6 +418,7 @@ jobs:
needs: [prep, getMobileExpensifyPR, getMobileExpensifyRef]
env:
DEVELOPER_DIR: /Applications/Xcode_26.0.app/Contents/Developer
PULL_REQUEST_NUMBER: ${{ needs.prep.outputs.APP_PR_NUMBER }}
runs-on: macos-15-xlarge
outputs:
IOS_PATH: ${{ steps.export-ios-path.outputs.IOS_PATH }}
Expand Down Expand Up @@ -517,21 +544,21 @@ jobs:
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e

- name: Publish links to apps for download on Expensify/App PR
if: ${{ inputs.APP_PULL_REQUEST_NUMBER || (!inputs.APP_PULL_REQUEST_NUMBER && !needs.getMobileExpensifyPR.outputs.MOBILE_EXPENSIFY_PR) }}
if: ${{ needs.prep.outputs.APP_PR_NUMBER || (!needs.prep.outputs.APP_PR_NUMBER && !needs.getMobileExpensifyPR.outputs.MOBILE_EXPENSIFY_PR) }}
uses: ./.github/actions/javascript/postTestBuildComment
with:
REPO: App
APP_PR_NUMBER: ${{ inputs.APP_PULL_REQUEST_NUMBER }}
APP_PR_NUMBER: ${{ needs.prep.outputs.APP_PR_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.APP_PULL_REQUEST_NUMBER }}/NewExpensify.dmg
DESKTOP_LINK: https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/${{ needs.prep.outputs.APP_PR_NUMBER }}/NewExpensify.dmg
IOS_LINK: ${{ needs.iosHybrid.outputs.IOS_PATH }}
WEB_LINK: https://${{ inputs.APP_PULL_REQUEST_NUMBER }}.pr-testing.expensify.com
WEB_LINK: https://${{ needs.prep.outputs.APP_PR_NUMBER }}.pr-testing.expensify.com

- name: Publish links to apps for download on Expensify/Mobile-Expensify PR
if: ${{ needs.getMobileExpensifyPR.outputs.MOBILE_EXPENSIFY_PR }}
Expand Down
Loading