Skip to content

Commit

Permalink
Merge branch 'main' into fix/29379
Browse files Browse the repository at this point in the history
  • Loading branch information
ishpaul777 authored Dec 14, 2023
2 parents 1b7ea4b + 66ef49e commit 0610dc7
Show file tree
Hide file tree
Showing 1,183 changed files with 25,019 additions and 13,847 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ const restrictedImportPaths = [
importNames: ['TouchableOpacity', 'TouchableWithoutFeedback', 'TouchableNativeFeedback', 'TouchableHighlight'],
message: "Please use 'PressableWithFeedback' and/or 'PressableWithoutFeedback' from 'src/components/Pressable' instead.",
},
{
name: 'react-native-safe-area-context',
importNames: ['useSafeAreaInsets', 'SafeAreaConsumer', 'SafeAreaInsetsContext'],
message: "Please use 'useSafeAreaInsets' from 'src/hooks/useSafeAreaInset' and/or 'SafeAreaConsumer' from 'src/components/SafeAreaConsumer' instead.",
},
];

const restrictedImportPatterns = [
Expand Down Expand Up @@ -169,6 +174,7 @@ module.exports = {
'rulesdir/prefer-underscore-method': 'off',
'rulesdir/prefer-import-module-contents': 'off',
'react/require-default-props': 'off',
'react/prop-types': 'off',
'no-restricted-syntax': [
'error',
{
Expand Down
6 changes: 3 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ $ https://github.com/Expensify/App/issues/<issueID(comment)>
Do NOT only link the issue number like this: $ #<issueID>
--->
$
PROPOSAL:
$
PROPOSAL:


### Tests
Expand Down Expand Up @@ -98,7 +98,7 @@ This is a checklist for PR authors. Please make sure to complete all tasks and c
- [ ] The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
- [ ] If a new CSS style is added I verified that:
- [ ] A similar style doesn't already exist
- [ ] The style can't be created with an existing [StyleUtils](https://github.com/Expensify/App/blob/main/src/styles/StyleUtils.js) function (i.e. `StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)`)
- [ ] The style can't be created with an existing [StyleUtils](https://github.com/Expensify/App/blob/main/src/styles/utils/index.ts) function (i.e. `StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)`)
- [ ] If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
- [ ] If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like `Avatar` is modified, I verified that `Avatar` is working as expected in all cases)
- [ ] If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
Expand Down
5 changes: 5 additions & 0 deletions .github/actions/composite/setupGitForOSBotifyApp/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ runs:
if: runner.debug == '1'
run: echo "GIT_TRACE=true" >> "$GITHUB_ENV"

- name: Sync clock
shell: bash
run: sudo sntp -sS time.windows.com
if: runner.os == 'macOS'

- name: Generate a token
id: generateToken
uses: actions/create-github-app-token@9d97a4282b2c51a2f4f0465b9326399f53c890d4
Expand Down
64 changes: 33 additions & 31 deletions .github/scripts/findUnusedKeys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ LIB_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd ../../ && pwd)"

readonly SRC_DIR="${LIB_PATH}/src"
readonly STYLES_DIR="${LIB_PATH}/src/styles"
readonly STYLES_FILE="${LIB_PATH}/src/styles/styles.ts"
readonly UTILITIES_STYLES_FILE="${LIB_PATH}/src/styles/utilities"
readonly STYLES_FILE="${LIB_PATH}/src/styles/index.ts"
readonly UTILS_STYLES_FILE="${LIB_PATH}/src/styles/utils"
readonly UTILS_STYLES_GENERATORS_FILE="${LIB_PATH}/src/styles/utils/generators"
readonly STYLES_KEYS_FILE="${LIB_PATH}/scripts/style_keys_list_temp.txt"
readonly UTILITY_STYLES_KEYS_FILE="${LIB_PATH}/scripts/utility_keys_list_temp.txt"
readonly UTIL_STYLES_KEYS_FILE="${LIB_PATH}/scripts/util_keys_list_temp.txt"
readonly REMOVAL_KEYS_FILE="${LIB_PATH}/scripts/removal_keys_list_temp.txt"
readonly AMOUNT_LINES_TO_SHOW=3

Expand All @@ -29,7 +30,7 @@ ctrl_c() {
delete_temp_files
exit 1
}

count_lines() {
local file=$1
if [[ -e "$file" ]]; then
Expand All @@ -43,11 +44,11 @@ count_lines() {
show_unused_style_keywords() {
while IFS=: read -r key file line_number; do
title "File: $file:$line_number"

# Get lines before and after the error line
local lines_before=$((line_number - AMOUNT_LINES_TO_SHOW))
local lines_after=$((line_number + AMOUNT_LINES_TO_SHOW))

# Read the lines into an array
local lines=()
while IFS= read -r line; do
Expand Down Expand Up @@ -84,22 +85,22 @@ lookfor_unused_keywords() {

# Search for keywords starting with "styles"
while IFS= read -r keyword; do

# Remove any [ ] characters from the keyword
local clean_keyword="${keyword//[\[\]]/}"
# skip styles. keyword that might be used in comments
if [[ "$clean_keyword" == "styles." ]]; then
continue
fi

if ! remove_keyword "$clean_keyword" ; then
# In case of a leaf of the styles object is being used, it means the parent objects is being used
# we need to mark it as used.
if [[ "$clean_keyword" =~ ^styles\.[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+$ ]]; then
# Keyword has more than two words, remove words after the second word
local keyword_prefix="${clean_keyword%.*}"
remove_keyword "$keyword_prefix"
fi
fi
fi
done < <(grep -E -o '\bstyles\.[a-zA-Z0-9_.]*' "$file" | grep -v '\/\/' | grep -vE '\/\*.*\*\/')
done < <(find "${SRC_DIR}" -type f \( "${FILE_EXTENSIONS[@]}" \))
Expand Down Expand Up @@ -134,10 +135,10 @@ find_styles_object_and_store_keys() {
if [[ ! "$line" =~ ^[[:space:]]*(const|let|var)[[:space:]]+([a-zA-Z0-9_-]+)[[:space:]]*=[[:space:]]*\{|^[[:space:]]*([a-zA-Z0-9_-]+\.)?[a-zA-Z0-9_-]+:[[:space:]]*\{|^[[:space:]]*\} ]]; then
continue
fi

if [[ "$line" =~ ^[[:space:]]*(const|let|var)[[:space:]]+([a-zA-Z0-9_-]+)[[:space:]]*=[[:space:]]*\{ ]]; then
key="${BASH_REMATCH[2]%%:*{*)}"
echo "styles.${key}|...${key}|${base_name}.${key}:${file}:${line_number}" >> "$STYLES_KEYS_FILE"
echo "styles.${key}|...${key}|${base_name}.${key}:${file}:${line_number}" >> "$STYLES_KEYS_FILE"
fi
done < "$file"
}
Expand Down Expand Up @@ -225,7 +226,7 @@ find_theme_style_and_store_keys() {

continue
fi

if [[ "$line" =~ ^[[:space:]]*([a-zA-Z0-9_-]+\.)?[a-zA-Z0-9_-]+:[[:space:]]*\{|^[[:space:]]*([a-zA-Z0-9_-])+:[[:space:]]*\(.*\)[[:space:]]*'=>'[[:space:]]*\(\{ ]]; then
# Removing all the extra lines after the ":"
local key="${line%%:*}"
Expand Down Expand Up @@ -295,63 +296,64 @@ lookfor_unused_spread_keywords() {
done < "$STYLES_FILE"
}

find_utility_styles_store_prefix() {
find_util_styles_store_prefix() {
# Loop through all files in the src folder
while read -r file; do
# Search for keywords starting with "styles"
while IFS= read -r keyword; do
local variable="${keyword##*/}"
local variable_trimmed="${variable// /}" # Trim spaces
echo "$variable_trimmed" >> "$UTILITY_STYLES_KEYS_FILE"
done < <(grep -E -o './utilities/[a-zA-Z0-9_-]+' "$file" | grep -v '\/\/' | grep -vE '\/\*.*\*\/')

echo "$variable_trimmed" >> "$UTIL_STYLES_KEYS_FILE"
done < <(grep -E -o './utils/[a-zA-Z0-9_-]+' "$file" | grep -v '\/\/' | grep -vE '\/\*.*\*\/')
done < <(find "${STYLES_DIR}" -type f \( "${FILE_EXTENSIONS[@]}" \))

# Sort and remove duplicates from the temporary file
sort -u -o "${UTILITY_STYLES_KEYS_FILE}" "${UTILITY_STYLES_KEYS_FILE}"
sort -u -o "${UTIL_STYLES_KEYS_FILE}" "${UTIL_STYLES_KEYS_FILE}"
}

find_utility_usage_as_styles() {
find_util_usage_as_styles() {
while read -r file; do
local root_key
local parent_dir

# Get the folder name, given this utility files are index.js
# Get the folder name, given this util files are index.js
parent_dir=$(dirname "$file")
root_key=$(basename "${parent_dir}")

if [[ "${root_key}" == "utilities" ]]; then
if [[ "${root_key}" == "utils" ]]; then
continue
fi

find_theme_style_and_store_keys "${file}" 0 "${root_key}"
done < <(find "${UTILITIES_STYLES_FILE}" -type f \( "${FILE_EXTENSIONS[@]}" \))
done < <(find "${UTILS_STYLES_FILE}" -type f \( -path "${UTILS_STYLES_GENERATORS_FILE}" -prune -o -name "${FILE_EXTENSIONS[@]}" \) -print)

}

lookfor_unused_utilities() {
# Read each utility keyword from the file
lookfor_unused_utils() {
# Read each util keyword from the file
while read -r keyword; do
# Creating a copy so later the replacement can reference it
# Creating a copy so later the replacement can reference it
local original_keyword="${keyword}"

# Iterate through all files in "src/styles"
while read -r file; do
# Find all words that match "$keyword.[a-zA-Z0-9_-]+"
while IFS= read -r match; do
# Replace the utility prefix with "styles"
# Replace the util prefix with "styles"
local variable="${match/#$original_keyword/styles}"
# Call the remove_keyword function with the variable
remove_keyword "${variable}"
remove_keyword "${match}"
done < <(grep -E -o "$original_keyword\.[a-zA-Z0-9_-]+" "$file" | grep -v '\/\/' | grep -vE '\/\*.*\*\/')
done < <(find "${STYLES_DIR}" -type f \( "${FILE_EXTENSIONS[@]}" \))
done < "$UTILITY_STYLES_KEYS_FILE"
done < "$UTIL_STYLES_KEYS_FILE"
}

echo "🔍 Looking for styles."
# Find and store the name of the utility files as keys
find_utility_styles_store_prefix
find_utility_usage_as_styles
# Find and store the name of the util files as keys
find_util_styles_store_prefix
find_util_usage_as_styles

# Find and store keys from styles.ts
find_styles_object_and_store_keys "$STYLES_FILE"
Expand All @@ -360,8 +362,8 @@ collect_theme_keys_from_styles "$STYLES_FILE"

echo "🗄️ Now going through the codebase and looking for unused keys."

# Look for usages of utilities into src/styles
lookfor_unused_utilities
# Look for usages of utils into src/styles
lookfor_unused_utils
lookfor_unused_spread_keywords
lookfor_unused_keywords

Expand Down
12 changes: 2 additions & 10 deletions .github/workflows/createNewVersion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ on:
OS_BOTIFY_COMMIT_TOKEN:
description: OSBotify personal access token, used to workaround committing to protected branch
required: true
OS_BOTIFY_APP_ID:
description: Application ID for OS Botify App
required: true
OS_BOTIFY_PRIVATE_KEY:
description: OSBotify private key
required: true

jobs:
validateActor:
Expand Down Expand Up @@ -76,18 +70,16 @@ jobs:
token: ${{ secrets.OS_BOTIFY_COMMIT_TOKEN }}

- name: Setup git for OSBotify
uses: ./.github/actions/composite/setupGitForOSBotifyApp
uses: ./.github/actions/composite/setupGitForOSBotify
id: setupGitForOSBotify
with:
GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}
OS_BOTIFY_APP_ID: ${{ secrets.OS_BOTIFY_APP_ID }}
OS_BOTIFY_PRIVATE_KEY: ${{ secrets.OS_BOTIFY_PRIVATE_KEY }}

- name: Generate version
id: bumpVersion
uses: ./.github/actions/javascript/bumpVersion
with:
GITHUB_TOKEN: ${{ steps.setupGitForOSBotify.outputs.OS_BOTIFY_API_TOKEN }}
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_COMMIT_TOKEN }}
SEMVER_LEVEL: ${{ inputs.SEMVER_LEVEL }}

- name: Commit new version
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/deployBlocker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ jobs:
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Escape html characters in GH issue title
env:
GH_ISSUE_TITLE: ${{ github.event.issue.title }}
run: |
escaped_title=$(echo "$GH_ISSUE_TITLE" | sed -e 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#039;/g; s/|/\&verbar;/g')
echo "GH_ISSUE_TITLE=$escaped_title" >> "$GITHUB_ENV"
- name: 'Post the issue in the #expensify-open-source slack room'
if: ${{ success() }}
uses: 8398a7/action-slack@v3
Expand All @@ -32,7 +39,7 @@ jobs:
channel: '#expensify-open-source',
attachments: [{
color: "#DB4545",
text: '💥 We have found a New Expensify Deploy Blocker, if you have any idea which PR could be causing this, please comment in the issue: <${{ github.event.issue.html_url }}|${{ github.event.issue.title }}>'.replace(/[&<>"'|]/g, function(m) { return {'&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#039;', '|': '&verbar;'}[m]; }),
text: '💥 We have found a New Expensify Deploy Blocker, if you have any idea which PR could be causing this, please comment in the issue: <${{ github.event.issue.html_url }}|${{ env.GH_ISSUE_TITLE }}>'
}]
}
env:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/e2ePerformanceTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ jobs:
test_spec_file: tests/e2e/TestSpec.yml
test_spec_type: APPIUM_NODE_TEST_SPEC
remote_src: false
file_artifacts: Customer Artifacts.zip
file_artifacts: |
Customer Artifacts.zip
Test spec output.txt
log_artifacts: debug.log
cleanup: true
timeout: 5400
Expand All @@ -220,6 +222,7 @@ jobs:
if: failure()
run: |
echo ${{ steps.schedule-awsdf-main.outputs.data }}
cat "./mainResults/Host_Machine_Files/\$WORKING_DIRECTORY/Test spec output.txt"
unzip "Customer Artifacts.zip" -d mainResults
cat ./mainResults/Host_Machine_Files/\$WORKING_DIRECTORY/debug.log
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/platformDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ jobs:
- name: Setup Node
uses: ./.github/actions/composite/setupNode

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'oracle'
java-version: '17'

- name: Setup Ruby
uses: ruby/setup-ruby@a05e47355e80e57b9a67566a813648fa67d92011
with:
Expand Down Expand Up @@ -341,6 +347,9 @@ jobs:
if: ${{ failure() }}
needs: [android, desktop, iOS, web]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Post Slack message on failure
uses: ./.github/actions/composite/announceFailedWorkflowInSlack
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/reassurePerformanceTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ jobs:
- name: Setup NodeJS
uses: ./.github/actions/composite/setupNode

- name: Set dummy git credentials
run: |
git config --global user.email "[email protected]"
git config --global user.name "Test"
- name: Run performance testing script
shell: bash
run: |
Expand All @@ -27,6 +32,7 @@ jobs:
npm install --force
npx reassure --baseline
git switch --force --detach -
git merge --no-commit --allow-unrelated-histories "$BASELINE_BRANCH" -X ours
npm install --force
npx reassure --branch
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/testBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ jobs:
- name: Setup Node
uses: ./.github/actions/composite/setupNode

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'oracle'
java-version: '17'

- name: Setup Ruby
uses: ruby/setup-ruby@a05e47355e80e57b9a67566a813648fa67d92011
with:
Expand Down
3 changes: 2 additions & 1 deletion .imgbotconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"ignoredFiles": [
"assets/images/empty-state_background-fade.png" // Caused an issue with colour gradients, https://github.com/Expensify/App/issues/30499
"assets/images/themeDependent/empty-state_background-fade-dark.png", // Caused an issue with colour gradients, https://github.com/Expensify/App/issues/30499
"assets/images/themeDependent/empty-state_background-fade-light.png"
],
"aggressiveCompression": "false"
}
2 changes: 1 addition & 1 deletion .storybook/public/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ a.sidebar-item[data-selected="true"], a.sidebar-item[data-selected="true"]:focus
}

.sidebar-container {
background: #07271f;
background: #072419;
}
Loading

0 comments on commit 0610dc7

Please sign in to comment.