Skip to content

Commit

Permalink
Create callable workflow to run E2E performance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
roryabraham committed Mar 2, 2023
1 parent 988dcfe commit 8be2ec4
Showing 1 changed file with 139 additions and 0 deletions.
139 changes: 139 additions & 0 deletions .github/workflows/e2ePerformanceTests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: E2E Performance Tests

on:
workflow_call:
inputs:
DELTA_REF:
description: A branch or commit ref to build the test build on
type: string
required: true
PR_NUMBER:
description: The number of a merged PR, if this workflow is being triggered by a PR merge
type: string
required: true

workflow_dispatch:
inputs:
DELTA_REF:
description: A branch or commit ref to build the test build on
type: string
required: true

jobs:
# TODO: Actor validation needed?

buildBaseline:
runs-on: ubuntu-20.04-64core
name: Build apk from latest release as a baseline
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
fetch-depth: 0

# TODO: If the baseline hasn't changed since the last time this job ran, we don't need to re-run the build and can reuse the old artifact
- name: Checkout "Baseline" commit (last release)
run: git checkout "$(gh release list --limit 1 | awk '{ print $1 }')"
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Build APK
uses: Expensify/App/.github/actions/composite/buildAndroidAPK@main
with:
ARTIFACT_NAME: baseline-apk-${{ github.run_id }}

buildDelta:
runs-on: ubuntu-20.04-64core
name: Build apk from delta ref
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
fetch-depth: 0

- name: Checkout "delta ref"
run: git checkout ${{ inputs.DELTA_REF }}
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Build APK
uses: Expensify/App/.github/actions/composite/buildAndroidAPK@main
with:
ARTIFACT_NAME: delta-apk-${{ inputs.DELTA_REF }}

runTestsInAWS:
runs-on: ubuntu-20.04-64core
needs: [buildBaseline, buildDelta]
name: Run E2E tests in AWS device farm
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
ref: ${{ inputs.DELTA_REF }}

- name: Make zip directory for everything to send to AWS Device Farm
run: mkdir zip

- name: Download baseline APK
uses: actions/download-artifact@e9ef242655d12993efdcda9058dee2db83a2cb9b
with:
name: baseline-apk-${{ github.run_id }}
path: zip

- name: Download delta APK
uses: actions/download-artifact@e9ef242655d12993efdcda9058dee2db83a2cb9b
with:
name: delta-apk-${{ inputs.DELTA_REF }}
path: zip

- name: Copy e2e code into zip folder
run: cp -r tests/e2e zip

- name: Zip everything in the zip directory up
run: zip -qr App.zip ./zip

- name: Configure AWS Credentials
uses: Expensify/App/.github/actions/composite/configureAwsCredentials@main
with:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-west-2

- name: Schedule AWS Device Farm test run
uses: realm/aws-devicefarm/test-application@7b9a91236c456c97e28d384c9e476035d5ea686b
with:
name: App E2E Performance Regression Tests
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }}
app_file: zip/app-e2eRelease-baseline.apk
app_type: ANDROID_APP
test_type: APPIUM_NODE
test_package_file: App.zip
test_package_type: APPIUM_NODE_TEST_PACKAGE
test_spec_file: tests/e2e/TestSpec.yml
test_spec_type: APPIUM_NODE_TEST_SPEC
remote_src: false
file_artifacts: CustomerArtifacts.zip
cleanup: true

- name: Unzip AWS Device Farm results
if: ${{ always() }}
run: unzip CustomerArtifacts.zip

- name: Print AWS Device Farm run results
if: ${{ always() }}
run: cat "./Host_Machine_Files/\$WORKING_DIRECTORY/output.md"

- name: Print AWS Device Farm verbose run results
if: ${{ always() && fromJSON(runner.debug) }}
run: cat "./Host_Machine_Files/\$WORKING_DIRECTORY/debug.log"

- name: Check if test failed, if so post the results and add the DeployBlocker label
if: github.event_name == 'workflow_call'
run: |
if grep -q '🔴' ./Host_Machine_Files/\$WORKING_DIRECTORY/output.md; then
gh pr edit ${{ inputs.PR_NUMBER }} --add-label DeployBlockerCash
gh pr comment ${{ inputs.PR_NUMBER }} -F ./Host_Machine_Files/\$WORKING_DIRECTORY/output.md
gh pr comment ${{ inputs.PR_NUMBER }} -b "@Expensify/mobile-deployers 📣 Please look into this performance regression as it's a deploy blocker."
else
echo '✅ no performance regression detected'
fi
env:
GITHUB_TOKEN: ${{ github.token }}

0 comments on commit 8be2ec4

Please sign in to comment.