Skip to content

Commit 062566b

Browse files
authored
Merge branch 'Expensify:main' into fixSearch.ts
2 parents ab1e0f2 + 88db91a commit 062566b

153 files changed

Lines changed: 2894 additions & 1172 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 55 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,76 @@
11
#!/bin/bash
2+
set -euo pipefail
23

3-
# Ensure upstream/main exists
4-
git fetch --depth=50 upstream main:upstream/main
4+
# -----------------------------
5+
# 1. Ensure upstream remote exists
6+
# -----------------------------
7+
# The PR branch comes from either the base repo or a fork.
8+
# We need the base repository's main branch for comparison.
9+
git remote add upstream "https://github.com/${GITHUB_REPOSITORY}.git" 2>/dev/null || true
510

6-
# Determine diff range safely
7-
if git merge-base upstream/main HEAD >/dev/null 2>&1; then
8-
DIFF_RANGE="upstream/main...HEAD"
9-
else
10-
echo "No merge base with upstream/main; falling back to comparing HEAD against upstream/main"
11-
DIFF_RANGE="upstream/main HEAD"
11+
# -----------------------------
12+
# 2. Attempt shallow fetch first
13+
# -----------------------------
14+
# Start with a depth of 50 commits, which covers most PRs.
15+
DEPTH=50
16+
echo "Fetching upstream/main with depth=$DEPTH..."
17+
git fetch upstream main --depth=$DEPTH
18+
19+
# -----------------------------
20+
# 3. Check if a merge-base exists
21+
# -----------------------------
22+
# merge-base finds the common ancestor between the PR branch and main.
23+
# If this fails, it means our shallow history didn't go back far enough.
24+
if ! git merge-base upstream/main HEAD >/dev/null 2>&1; then
25+
echo "No merge base found with depth=$DEPTH, fetching full history..."
26+
27+
# Try unshallowing the entire repo (pulls full commit history).
28+
# If already full, this will be a no-op.
29+
git fetch --unshallow upstream || git fetch upstream main
1230
fi
1331

14-
# Get changed files in src directory
15-
readarray -t ALL_CHANGED_FILES < <(git diff --name-only "$DIFF_RANGE" | grep '^src/' | grep -E '\.(ts|tsx|js|jsx)$' || true)
32+
# -----------------------------
33+
# 4. Define the diff range
34+
# -----------------------------
35+
# Using three-dot notation (A...B) shows only the commits in HEAD
36+
# that aren't in upstream/main (i.e. just the PR changes).
37+
DIFF_RANGE="upstream/main...HEAD"
38+
39+
# -----------------------------
40+
# 5. Collect changed src/ files
41+
# -----------------------------
42+
readarray -t ALL_CHANGED_FILES < <(
43+
git diff --name-only "$DIFF_RANGE" \
44+
| grep '^src/' \
45+
| grep -E '\.(ts|tsx|js|jsx)$' || true
46+
)
1647

17-
# Filter out excluded directories and files
48+
# -----------------------------
49+
# 6. Filter excluded files/dirs
50+
# -----------------------------
1851
CHANGED_FILES=()
1952
for file in "${ALL_CHANGED_FILES[@]}"; do
20-
# Skip excluded directories
53+
# Exclude directories
2154
if [[ "$file" =~ ^src/(CONST|languages|setup|stories|styles|types)/ ]]; then
22-
echo "Skipping excluded directory: $file"
55+
echo "Skipping excluded directory: \"$file\""
2356
continue
2457
fi
25-
26-
# Skip excluded files in src root
27-
filename=$(basename "$file")
58+
59+
# Exclude specific files in src root
60+
filename="$(basename "$file")"
2861
if [[ "$filename" =~ ^(App\.tsx|CONFIG\.ts|Expensify\.tsx|HybridAppHandler\.tsx|NAICS\.ts|NAVIGATORS\.ts|ONYXKEYS\.ts|ROUTES\.ts|SCREENS\.ts|SplashScreenStateContext\.tsx|TIMEZONES\.ts)$ ]]; then
29-
echo "Skipping excluded file: $file"
62+
echo "Skipping excluded file: \"$file\""
3063
continue
3164
fi
3265

33-
# Add to coverage collection
3466
CHANGED_FILES+=("$file")
3567
done
3668

37-
# Check if any files remain for coverage
69+
# -----------------------------
70+
# 7. Output results
71+
# -----------------------------
3872
if [ ${#CHANGED_FILES[@]} -eq 0 ]; then
39-
echo "No relevant src files changed (all changes were in excluded directories/files), skipping coverage"
73+
echo "No relevant src files changed, skipping coverage"
4074
echo "run_coverage=false" >> "$GITHUB_OUTPUT"
4175
exit 0
4276
fi
@@ -45,5 +79,5 @@ echo "Changed src files for coverage:"
4579
printf '%s\n' "${CHANGED_FILES[@]}"
4680
echo "run_coverage=true" >> "$GITHUB_OUTPUT"
4781

48-
# Save changed files for coverage collection
82+
# Save changed files for later coverage steps
4983
printf '%s\n' "${CHANGED_FILES[@]}" > changed_files.txt

.github/workflows/testCoverage.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ jobs:
4545
repository: ${{ steps.get_pr.outputs.repo }}
4646
ref: ${{ steps.get_pr.outputs.ref }}
4747

48-
- name: Fetch Upstream Remote for Base Repository
49-
run: |
50-
git remote add upstream https://github.com/${{ github.repository }}.git
51-
git fetch upstream main
52-
5348
- name: Setup Git for OSBotify
5449
uses: Expensify/GitHub-Actions/setupGitForOSBotify@main
5550
id: setupGitForOSBotify

Mobile-Expensify

__mocks__/@ua/react-native-airship.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ enum EventType {
66
PushReceived = 'com.airship.push_received',
77
}
88

9+
// eslint-disable-next-line no-restricted-syntax
10+
enum PermissionStatus {
11+
Granted = 'granted',
12+
Denied = 'denied',
13+
NotDetermined = 'not_determined',
14+
}
15+
916
// eslint-disable-next-line @typescript-eslint/no-namespace
1017
namespace iOS {
1118
/**
@@ -71,4 +78,4 @@ const Airship: Partial<AirshipRoot> = {
7178

7279
export default Airship;
7380

74-
export {EventType, iOS};
81+
export {EventType, iOS, PermissionStatus};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const NitroModules = {
2+
createHybridObject: jest.fn(() => ({
3+
getAll: jest.fn(() => Promise.resolve([])),
4+
})),
5+
};
6+
7+
export {
8+
// eslint-disable-next-line import/prefer-default-export
9+
NitroModules,
10+
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* eslint-disable no-console */
2+
import type {Compiler} from 'webpack';
3+
4+
/**
5+
* Custom webpack plugin that forces garbage collection every 5 compilations
6+
* and logs memory usage to help monitor memory consumption during development.
7+
*
8+
* Note: Requires Node.js to be started with --expose-gc flag to enable garbage collection.
9+
*/
10+
class ForceGarbageCollectionPlugin {
11+
private compilationCount = 0;
12+
13+
apply(compiler: Compiler) {
14+
if (gc && typeof gc === 'function') {
15+
compiler.hooks.done.tap(this.constructor.name, () => {
16+
this.compilationCount++;
17+
18+
const memUsage = process.memoryUsage();
19+
const heapUsedMB = Math.round(memUsage.heapUsed / 1024 / 1024);
20+
const heapTotalMB = Math.round(memUsage.heapTotal / 1024 / 1024);
21+
22+
console.log(`📊 Compilation #${this.compilationCount} - Heap: ${heapUsedMB}MB/${heapTotalMB}MB`);
23+
if (this.compilationCount % 5 === 0) {
24+
console.log(`🗑️ Forcing garbage collection after ${this.compilationCount} compilations`);
25+
gc?.();
26+
27+
const memAfterGC = process.memoryUsage();
28+
const heapAfterMB = Math.round(memAfterGC.heapUsed / 1024 / 1024);
29+
console.log(`✅ Post-GC heap size: ${heapAfterMB}MB (freed ${heapUsedMB - heapAfterMB}MB)`);
30+
}
31+
});
32+
} else {
33+
console.warn('⚠️ ForceGarbageCollectionPlugin: gc() function not available. Start Node.js with --expose-gc flag to enable garbage collection.');
34+
}
35+
}
36+
}
37+
38+
export default ForceGarbageCollectionPlugin;

0 commit comments

Comments
 (0)