Skip to content

Commit eb9c49d

Browse files
alexrischAlex Risch
and
Alex Risch
authored
feat: Performance Tests (#924)
* feat: Performance Tests Added Performance tests * feat: Performance Tests Updated scripts * try direct script * Add tests for release branches * Version Bumps --------- Co-authored-by: Alex Risch <alex@xmtp.com>
1 parent d81f822 commit eb9c49d

9 files changed

+774
-22
lines changed

.github/workflows/check-android-build.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
pull_request:
55
branches:
66
- main
7+
- release/*
78
paths:
89
- "android/**"
910
- "package.json"

.github/workflows/check-ios-build.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
pull_request:
55
branches:
66
- main
7+
- release/*
78
paths:
89
- "ios/**"
910
- "package.json"

.github/workflows/typescript.yml

+46-10
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,77 @@ on:
33
pull_request:
44
branches:
55
- main
6-
6+
- release/*
7+
paths:
8+
- "**/*.ts"
9+
- "**/*.tsx"
10+
- "package.json"
711
jobs:
812
tsc:
913
runs-on: ubuntu-latest
1014
steps:
11-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1216
with:
1317
fetch-depth: 0
14-
- uses: actions/setup-node@v4.0.2
18+
- uses: actions/setup-node@v4
1519
with:
16-
node-version: 18.x
20+
node-version: 20.x
1721
cache: "yarn"
1822
- run: yarn
1923
- run: yarn typecheck
2024
lint:
2125
runs-on: ubuntu-latest
2226
steps:
23-
- uses: actions/checkout@v2
27+
- uses: actions/checkout@v4
2428
with:
2529
fetch-depth: 0
26-
- uses: actions/setup-node@v4.0.2
30+
- uses: actions/setup-node@v4
2731
with:
28-
node-version: 18.x
32+
node-version: 20.x
2933
cache: "yarn"
3034
- run: yarn
3135
- run: yarn lint
3236
test:
3337
runs-on: ubuntu-latest
3438
steps:
35-
- uses: actions/checkout@v2
39+
- uses: actions/checkout@v4
3640
with:
3741
fetch-depth: 0
38-
- uses: actions/setup-node@v4.0.2
42+
- uses: actions/setup-node@v4
3943
with:
40-
node-version: 18.x
44+
node-version: 20.x
4145
cache: "yarn"
4246
- run: yarn
4347
- run: yarn test
48+
performance-test:
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v4
52+
with:
53+
fetch-depth: 0
54+
- uses: actions/setup-node@v4
55+
with:
56+
node-version: 20.x
57+
cache: "yarn"
58+
- run: |
59+
BASELINE_BRANCH=${GITHUB_BASE_REF:="main"}
60+
61+
# Required for `git switch` on CI
62+
git fetch origin
63+
64+
# Gather baseline perf measurements
65+
git switch "$BASELINE_BRANCH"
66+
67+
yarn
68+
yarn reassure --baseline
69+
70+
# Gather current perf measurements & compare results
71+
git switch --detach -
72+
73+
yarn
74+
yarn reassure --branch
75+
76+
- name: Run Danger.js
77+
run: yarn danger ci
78+
env:
79+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ builds
1919

2020
# iOS
2121
ios/Converse.xcworkspace/xcshareddata/swiftpm/Package.resolved
22+
# Reassure output directory
23+
.reassure
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { jest, test } from "@jest/globals";
2+
import { screen } from "@testing-library/react-native";
3+
import React from "react";
4+
import { measureRenders } from "reassure";
5+
6+
import Avatar from "../Avatar";
7+
8+
jest.setTimeout(600_000);
9+
10+
const TestComponent = ({ uri }: { uri?: string }) => <Avatar uri={uri} />;
11+
12+
test("Empty Avatar 10 runs", async () => {
13+
const scenario = async () => {
14+
await screen.findByTestId("avatar-placeholder");
15+
};
16+
17+
await measureRenders(<TestComponent />, { scenario, runs: 10 });
18+
});
19+
20+
test("Empty Avatar 50 runs", async () => {
21+
const scenario = async () => {
22+
await screen.findByTestId("avatar-placeholder");
23+
};
24+
25+
await measureRenders(<TestComponent />, { scenario, runs: 50 });
26+
});
27+
28+
test("Avatar Image 10 runs", async () => {
29+
const scenario = async () => {
30+
await screen.findByTestId("avatar-image");
31+
};
32+
33+
await measureRenders(<TestComponent uri="https://picsum.photos/200/300" />, {
34+
scenario,
35+
runs: 10,
36+
});
37+
});
38+
39+
test("Avatar Image 50 runs", async () => {
40+
const scenario = async () => {
41+
await screen.findByTestId("avatar-image");
42+
};
43+
44+
await measureRenders(<TestComponent uri="https://picsum.photos/200/300" />, {
45+
scenario,
46+
runs: 50,
47+
});
48+
});

dangerfile.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* eslint-disable import/no-extraneous-dependencies */
2+
import path from 'path';
3+
import { dangerReassure } from 'reassure';
4+
5+
dangerReassure({
6+
inputFilePath: path.join(__dirname, './.reassure/output.md'),
7+
});

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"ios": "EXPO_ENV=dev expo start --ios",
1212
"postinstall": "patch-package && node scripts/wasm.js && husky install && cross-os postinstall",
1313
"start": "EXPO_ENV=dev expo start",
14-
"test": "echo \"➜ Running tests...\" && jest",
14+
"test": "echo \"➜ Running tests...\" && jest --testPathIgnorePatterns='.*\\.perf-test\\.tsx$'",
15+
"test:perf": "echo \"➜ Running tests with performance...\" && echo \"➜ Capture baseline performance tests...\" && yarn reassure --baseline && echo \"➜ Running current performance tests...\" && jest --testPathIgnorePatterns='.*\\.perf-test\\.tsx$'",
1516
"typecheck": "echo \"➜ Typechecking project...\" && tsc --noEmit",
1617
"update": "node scripts/build/update.js",
1718
"web:preview": "EXPO_ENV=preview expo export -p web"
@@ -218,6 +219,7 @@
218219
"@typescript-eslint/typescript-estree": "^6.3.0",
219220
"@welldone-software/why-did-you-render": "^8.0.3",
220221
"cross-os": "^1.5.0",
222+
"danger": "^12.3.3",
221223
"eslint": "^8.47.0",
222224
"eslint-config-prettier": "^9.0.0",
223225
"eslint-config-universe": "^12.0.0",
@@ -237,6 +239,7 @@
237239
"plist": "^3.0.6",
238240
"prettier": "^3.0.1",
239241
"process": "^0.11.10",
242+
"reassure": "^1.2.1",
240243
"sqlite3": "^5.1.4",
241244
"ts-node": "^10.9.2",
242245
"typescript": "^5.3.0",

reassure-tests.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
BASELINE_BRANCH=${GITHUB_BASE_REF:="main"}
5+
6+
# Required for `git switch` on CI
7+
git fetch origin
8+
9+
# Gather baseline perf measurements
10+
git switch "$BASELINE_BRANCH"
11+
12+
yarn
13+
yarn reassure --baseline
14+
15+
# Gather current perf measurements & compare results
16+
git switch --detach -
17+
18+
yarn
19+
yarn reassure --branch

0 commit comments

Comments
 (0)