Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run e2e performance regression tests on merge into main via AWS Device farm #12320

Merged
merged 109 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
b857f73
Apply some logging tweaks
AndrewGable Oct 31, 2022
106a88b
Add TestSpec
AndrewGable Oct 31, 2022
9ce17a6
Tweak TestSpec to a working solution
AndrewGable Oct 31, 2022
b06342f
Tweak artifacts
AndrewGable Oct 31, 2022
7bec64d
Move e2e to tests folder and remove unused code
AndrewGable Nov 2, 2022
6c255fb
Try making run from GitHub actions
AndrewGable Nov 2, 2022
1631bea
Use correct version
AndrewGable Nov 2, 2022
cb30060
Use `workflow_dispatch` as well
AndrewGable Nov 2, 2022
30d1c33
Use macos for Bundle
AndrewGable Nov 2, 2022
579141e
Delete unused workflows to clean up my inbox
AndrewGable Nov 2, 2022
478ee01
Run on push
AndrewGable Nov 2, 2022
48c9f8c
Set up ruby and include device pool
AndrewGable Nov 2, 2022
574b8fb
Tweak android build settings
AndrewGable Nov 2, 2022
84b94e4
Add debug lines
AndrewGable Nov 3, 2022
90f41cc
Correct env file location
AndrewGable Nov 3, 2022
57dc2d7
Tweak two configs to pass tests
AndrewGable Nov 3, 2022
1d3a54b
Remove debug
AndrewGable Nov 3, 2022
0633815
Tweak install path for adb
AndrewGable Nov 3, 2022
a57301e
Show all files
AndrewGable Nov 3, 2022
6b53c5d
Add find
AndrewGable Nov 3, 2022
278350d
Try to fix file paths
AndrewGable Nov 3, 2022
1a95f0a
Try to grab artifacts from device farm
AndrewGable Nov 3, 2022
3e9deb0
Try to see if this improves perf of build
AndrewGable Nov 3, 2022
4ad6c44
Test cache
AndrewGable Nov 3, 2022
4bd55e1
Try to use straight npm ci
AndrewGable Nov 3, 2022
1ffc8d0
Try different path for artifacts
AndrewGable Nov 3, 2022
665296a
Try one last path
AndrewGable Nov 3, 2022
540f36b
Clean up TestSpec
AndrewGable Nov 3, 2022
2048bd7
Try to save to `WORKING_DIRECTORY`
AndrewGable Nov 3, 2022
f090796
Add debug lines
AndrewGable Nov 3, 2022
3b5ad5a
Try to leave as a comment
AndrewGable Nov 3, 2022
e472470
Add \
AndrewGable Nov 4, 2022
e3e4456
Remove debug
AndrewGable Nov 4, 2022
01ea314
Try to use ./
AndrewGable Nov 4, 2022
6711db7
Try ubuntu
AndrewGable Nov 4, 2022
827de9e
More debug
AndrewGable Nov 4, 2022
3bba04e
Escape $
AndrewGable Nov 4, 2022
5e0bf35
Fix env too
AndrewGable Nov 4, 2022
b2a7bb6
Last fix?
AndrewGable Nov 4, 2022
ebd543c
Use quotes?
AndrewGable Nov 4, 2022
9c3c4c5
Use multi line env variable
AndrewGable Nov 4, 2022
f985b4f
Try a different comment action
AndrewGable Nov 4, 2022
47cdafe
Clean up debug
AndrewGable Nov 4, 2022
fa5049f
Try to build two APKs
AndrewGable Nov 4, 2022
68b2c1a
Tweak checkout command
AndrewGable Nov 4, 2022
f39aa10
Merge branch 'main' into andrew-aws-df
AndrewGable Nov 7, 2022
e861d70
Update file names
AndrewGable Nov 7, 2022
79aea8e
Add param
AndrewGable Nov 7, 2022
862c7fb
Merge branch 'main' into andrew-aws-df
AndrewGable Nov 7, 2022
0f6f593
Current -> Compare
AndrewGable Nov 7, 2022
7d002b1
Try to use npm install from GitHub runner
AndrewGable Nov 7, 2022
7baa3e5
Debug
AndrewGable Nov 7, 2022
1e91780
Try npm-bundle
AndrewGable Nov 8, 2022
47b9069
More debug
AndrewGable Nov 8, 2022
543aed0
Testing bundle in different spot
AndrewGable Nov 8, 2022
8c22a84
Try a debug
AndrewGable Nov 8, 2022
a19e5aa
Undo debug
AndrewGable Nov 8, 2022
11e298f
More debug
AndrewGable Nov 8, 2022
a7e89bb
Use custom fork to try to fix bug
AndrewGable Nov 8, 2022
c9a1dbc
Use zip instead of bundle
AndrewGable Nov 8, 2022
95da732
Clean up after runs
AndrewGable Nov 8, 2022
ae7278b
Install correct node and do not switch branches
AndrewGable Nov 8, 2022
2a86245
Quick debug test
AndrewGable Nov 8, 2022
1fae6ec
Undo debug
AndrewGable Nov 8, 2022
31220d7
Fix path
AndrewGable Nov 9, 2022
eb7da36
Checkout preivous branch
AndrewGable Nov 9, 2022
5b314b0
Remove debug lines
AndrewGable Nov 9, 2022
573c24b
Quiet zip and use npmrc file
AndrewGable Nov 9, 2022
899ea8e
Undo removal of other workflows
AndrewGable Nov 9, 2022
7c7cb99
Filter outliers via different method
AndrewGable Nov 9, 2022
769b8ed
Bump formatting to 3 digits
AndrewGable Nov 9, 2022
b1d95ca
Reduce test runs by half, see how long it takes
AndrewGable Nov 9, 2022
5e4f62b
Undo reducing number of runs
AndrewGable Nov 9, 2022
8bd22d8
Use large runner
AndrewGable Nov 11, 2022
dbdc9fd
Only zip up required e2e tests
AndrewGable Nov 14, 2022
ff9f04f
Update TestSpec
AndrewGable Nov 14, 2022
62ca8de
Merge branch 'main' into andrew-aws-df
AndrewGable Nov 14, 2022
4d2b888
Merge branch 'main' into andrew-aws-df
AndrewGable Nov 15, 2022
17c693e
Make a zip directory
AndrewGable Nov 15, 2022
7b72a08
fix path
AndrewGable Nov 15, 2022
9a34e71
Add recursive flag
AndrewGable Nov 15, 2022
ba07fed
Fix another path
AndrewGable Nov 15, 2022
5cd62d9
Tweak commands now that we have a stripped down test
AndrewGable Nov 15, 2022
6e5853c
Remove fork
AndrewGable Nov 15, 2022
d1bc36b
Fix path again and more debug
AndrewGable Nov 15, 2022
8caab9a
Try to install underscore elsewhere
AndrewGable Nov 15, 2022
d6700e6
Remove some debug lines
AndrewGable Nov 15, 2022
46b2a1e
Fix lint
AndrewGable Nov 15, 2022
0255d3f
Fix lint
AndrewGable Nov 16, 2022
911864a
Try to fix lint more
AndrewGable Nov 16, 2022
82cadee
Try one last thing for linting
AndrewGable Nov 16, 2022
a493465
Move back to runs-on
AndrewGable Nov 16, 2022
1d7de1d
Skip linting specific workflow due to bug
AndrewGable Nov 16, 2022
11568bf
Forgot $
AndrewGable Nov 16, 2022
789e695
Merge branch 'main' into andrew-aws-df
AndrewGable Nov 28, 2022
32e12b8
Re-add checkout
AndrewGable Nov 29, 2022
a9ca824
Use my branch
AndrewGable Nov 29, 2022
5381ce1
Add test for fail/pass
AndrewGable Nov 29, 2022
08202e4
Tweak syntax
AndrewGable Nov 29, 2022
e333c47
Adjust test
AndrewGable Nov 29, 2022
5d63147
Fix lint and remove unused file
AndrewGable Nov 29, 2022
98e836f
Checkout latest release as baseline
AndrewGable Nov 29, 2022
1db38a8
Add "
AndrewGable Nov 29, 2022
92a52ad
One more test
AndrewGable Nov 29, 2022
90b9ed9
More testing
AndrewGable Nov 29, 2022
372aa2e
Remove test file
AndrewGable Nov 29, 2022
e679eef
Move checkout back
AndrewGable Nov 29, 2022
e11332d
Merge branch 'main' into andrew-aws-df
AndrewGable Dec 2, 2022
df5905f
Apply peer review
AndrewGable Dec 2, 2022
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
4 changes: 4 additions & 0 deletions .github/actionlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# See https://github.com/rhysd/actionlint/blob/main/docs/config.md
self-hosted-runner:
labels:
- ubuntu-20.04-64core
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ inputs:
AWS_SECRET_ACCESS_KEY:
description: 'Secret Access Key to AWS'
required: true
AWS_REGION:
description: 'Region for AWS'
required: true
default: 'us-east-1'

runs:
using: composite
Expand All @@ -18,4 +22,4 @@ runs:
with:
aws-access-key-id: ${{ inputs.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ inputs.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
aws-region: ${{ inputs.AWS_REGION }}
Copy link
Contributor

Choose a reason for hiding this comment

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

I see what you mean about this action being pointless now ... annoying that local composite actions from the same repo don't have access to secrets.

6 changes: 6 additions & 0 deletions .github/scripts/validateActionsAndWorkflows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ done

for ((i=0; i < ${#WORKFLOWS[@]}; i++)); do
WORKFLOW=${WORKFLOWS[$i]}

# Skip linting e2e workflow due to bug here: https://github.com/SchemaStore/schemastore/issues/2579
if [[ "$WORKFLOW" == './workflows/preDeploy.yml' ]]; then
continue
fi

ajv -s ./tempSchemas/github-workflow.json -d "$WORKFLOW" --strict=false &
ASYNC_PROCESSES[${#ACTIONS[@]} + $i]=$!
done
Expand Down
83 changes: 0 additions & 83 deletions .github/workflows/e2ePerformanceRegressionTests.yml

This file was deleted.

101 changes: 101 additions & 0 deletions .github/workflows/preDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,104 @@ jobs:
3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. :moneybag:

So it might take a while before you're paid for your work, but we typically post multiple new jobs every day, so there's plenty of opportunity. I hope you've had a positive experience contributing to this repo! :blush:

e2e-tests:
AndrewGable marked this conversation as resolved.
Show resolved Hide resolved
name: "Run e2e performance regression tests"
runs-on: ubuntu-20.04-64core
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
fetch-depth: 0

- uses: Expensify/App/.github/actions/composite/setupNode@main

- uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7
with:
ruby-version: '2.7'
roryabraham marked this conversation as resolved.
Show resolved Hide resolved
bundler-cache: true

# Cache gradle to improve Android build time
- name: Gradle cache
uses: gradle/gradle-build-action@3fbe033aaae657f011f88f29be9e65ed26bd29ef

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

- name: Checkout "Compare" commit
run: git checkout ${{ github.event.before }}

- name: Build "Compare" APK
run: npm run android-build-e2e

- name: Copy "Compare" APK
run: cp android/app/build/outputs/apk/e2eRelease/app-e2eRelease.apk zip/app-e2eRelease-compare.apk

- name: Checkout "Baseline" commit (last release)
run: git checkout "$(gh release list --limit 1 | awk '{ print $1 }')"

- name: Build "Baseline" APK
run: npm run android-build-e2e

- name: Copy "Baseline" APK
run: cp android/app/build/outputs/apk/e2eRelease/app-e2eRelease.apk zip/app-e2eRelease-baseline.apk

- name: Checkout previous branch for source code to run on AWS Device farm
run: git checkout -

- 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
PauloGasparSv marked this conversation as resolved.
Show resolved Hide resolved

- 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: Customer Artifacts.zip
cleanup: true

- name: Unzip AWS Device Farm results
run: unzip Customer\ Artifacts.zip

- name: Set output of AWS Device Farm into GitHub ENV
run: |
{ echo 'OUTPUT<<EOF'; cat ./Host_Machine_Files/\$WORKING_DIRECTORY/output.md; echo 'EOF'; } >> "$GITHUB_ENV"
AndrewGable marked this conversation as resolved.
Show resolved Hide resolved

- name: Get merged pull request
id: getMergedPullRequest
# TODO: Point back action actions-ecosystem after https://github.com/actions-ecosystem/action-get-merged-pull-request/pull/223 is merged
uses: roryabraham/action-get-merged-pull-request@7a7a194f6ff8f3eef58c822083695a97314ebec1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Leave output of AWS Device Farm as a PR comment
run: |
gh pr comment ${{ steps.getMergedPullRequest.outputs.number }} -F ./Host_Machine_Files/\$WORKING_DIRECTORY/output.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check if test failed, if so leave a deploy blocker label
AndrewGable marked this conversation as resolved.
Show resolved Hide resolved
if: ${{ !contains(env.OUTPUT, 'There are no entries') }}
run: |
gh pr edit ${{ steps.getMergedPullRequest.outputs.number }} --add-label 'DeployBlockerCash'
gh pr comment ${{ steps.getMergedPullRequest.outputs.number }} -b "@Expensify/mobile-deployers 📣 Please look into this performance regression as it's a deploy blocker."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ storybook-static
.jest-cache

# E2E test reports
e2e/.results/
tests/e2e/.results/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ variables referenced here get updated since your local `.env` file is ignored.
- `ONYX_METRICS` (optional) - Set this to `true` to capture even more performance metrics and see them in Flipper
see [React-Native-Onyx#benchmarks](https://github.com/Expensify/react-native-onyx#benchmarks) for more information
- `E2E_TESTING` (optional) - This needs to be set to `true` when running the e2e tests for performance regression testing.
This happens usually automatically, read [this](e2e/README.md) for more information
This happens usually automatically, read [this](tests/e2e/README.md) for more information

----

Expand Down
35 changes: 0 additions & 35 deletions e2e/measure/math.js

This file was deleted.

6 changes: 0 additions & 6 deletions e2e/utils/androidReversePort.js

This file was deleted.

39 changes: 0 additions & 39 deletions e2e/utils/startRecordingVideo.js

This file was deleted.

2 changes: 1 addition & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ opt_out_usage
platform :android do
desc "Generate a new local APK for e2e testing"
lane :build_e2e do
ENV["ENVFILE"]="e2e/.env.e2e"
ENV["ENVFILE"]="tests/e2e/.env.e2e"
ENV["ENTRY_FILE"]="src/libs/E2E/reactNativeLaunchingTest.js"

gradle(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"analyze-packages": "ANALYZE_BUNDLE=true webpack --config config/webpack/webpack.common.js --env envFile=.env.production",
"symbolicate:android": "npx metro-symbolicate android/app/build/generated/sourcemaps/react/release/index.android.bundle.map",
"symbolicate:ios": "npx metro-symbolicate main.jsbundle.map",
"test:e2e": "node ./e2e/testRunner.js"
"test:e2e": "node tests/e2e/testRunner.js"
},
"dependencies": {
"@expensify/react-native-web": "0.18.9",
Expand Down
4 changes: 2 additions & 2 deletions src/libs/E2E/client.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Routes from '../../../e2e/server/routes';
import Config from '../../../e2e/config';
import Routes from '../../../tests/e2e/server/routes';
import Config from '../../../tests/e2e/config';

const SERVER_ADDRESS = `http://localhost:${Config.SERVER_PORT}`;

Expand Down
2 changes: 1 addition & 1 deletion src/libs/E2E/reactNativeLaunchingTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Performance.markStart('regularAppStart');
import '../../../index';
Performance.markEnd('regularAppStart');

import E2EConfig from '../../../e2e/config';
import E2EConfig from '../../../tests/e2e/config';
import E2EClient from './client';

console.debug('==========================');
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion e2e/README.md → tests/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ It will run the tests of a test case multiple time to average out the results.

## Adding tests

To add a test checkout the [designed guide](./ADDING_TESTS.md).
To add a test checkout the [designed guide](tests/e2e/ADDING_TESTS.md).

## Structure

Expand Down
26 changes: 26 additions & 0 deletions tests/e2e/TestSpec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: 0.1

phases:
install:
commands:
# Install correct version of node
- export NVM_DIR=$HOME/.nvm
- . $NVM_DIR/nvm.sh
- nvm install 16.15.1
- nvm use 16.15.1

# Reverse ports using AWS magic
- PORT=4723
- IP_ADDRESS=$(ip -4 addr show eth0 | grep -Po "(?<=inet\s)\d+(\.\d+){3}")
- reverse_values="{\"ip_address\":\"$IP_ADDRESS\",\"local_port\":\"$PORT\",\"remote_port\":\"$PORT\"}"
- "curl -H \"Content-Type: application/json\" -X POST -d \"$reverse_values\" http://localhost:31007/reverse_forward_tcp"
- adb reverse tcp:$PORT tcp:$PORT

test:
commands:
- cd zip
- npm install underscore
- node e2e/testRunner.js -- --skipInstallDeps --skipBuild

artifacts:
- $WORKING_DIRECTORY
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading