Skip to content

Commit

Permalink
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-he…
Browse files Browse the repository at this point in the history
…lper-text-custom-list
  • Loading branch information
mananjadhav committed Sep 30, 2024
2 parents 454fd46 + 96d8973 commit 68c3e0b
Show file tree
Hide file tree
Showing 458 changed files with 7,638 additions and 6,297 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ module.exports = {
'plugin:you-dont-need-lodash-underscore/all',
'plugin:prettier/recommended',
],
plugins: ['@typescript-eslint', 'jsdoc', 'you-dont-need-lodash-underscore', 'react-native-a11y', 'react', 'testing-library', 'eslint-plugin-react-compiler', 'lodash'],
plugins: ['@typescript-eslint', 'jsdoc', 'you-dont-need-lodash-underscore', 'react-native-a11y', 'react', 'testing-library', 'eslint-plugin-react-compiler', 'lodash', 'deprecation'],
ignorePatterns: ['lib/**'],
parser: '@typescript-eslint/parser',
parserOptions: {
Expand Down Expand Up @@ -177,6 +177,7 @@ module.exports = {
// ESLint core rules
'es/no-nullish-coalescing-operators': 'off',
'es/no-optional-chaining': 'off',
'deprecation/deprecation': 'off',

// Import specific rules
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/composite/setupGitForOSBotify/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ runs:
- name: Set up git for OSBotify
shell: bash
run: |
git config user.signingkey 367811D53E34168C
git config user.signingkey AEE1036472A782AB
git config commit.gpgsign true
git config user.name OSBotify
git config user.email [email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ runs:
- name: Set up git for OSBotify
shell: bash
run: |
git config user.signingkey 367811D53E34168C
git config user.signingkey AEE1036472A782AB
git config commit.gpgsign true
git config user.name OSBotify
git config user.email [email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ inputs:
GITHUB_TOKEN:
description: "Github token for authentication"
required: true
default: "${{ github.token }}"
ANDROID:
description: "Android job result ('success', 'failure', 'cancelled', or 'skipped')"
required: true
Expand All @@ -27,6 +26,12 @@ inputs:
WEB:
description: "Web job result ('success', 'failure', 'cancelled', or 'skipped')"
required: true
DATE:
description: "The date of deployment"
required: false
NOTE:
description: "Additional note from the deployer"
required: false
runs:
using: "node20"
main: "./index.js"
11 changes: 10 additions & 1 deletion .github/actions/javascript/markPullRequestsAsDeployed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12713,16 +12713,25 @@ async function run() {
const desktopResult = getDeployTableMessage(core.getInput('DESKTOP', { required: true }));
const iOSResult = getDeployTableMessage(core.getInput('IOS', { required: true }));
const webResult = getDeployTableMessage(core.getInput('WEB', { required: true }));
const date = core.getInput('DATE');
const note = core.getInput('NOTE');
function getDeployMessage(deployer, deployVerb, prTitle) {
let message = `🚀 [${deployVerb}](${workflowURL}) to ${isProd ? 'production' : 'staging'}`;
message += ` by https://github.com/${deployer} in version: ${version} 🚀`;
message += ` by https://github.com/${deployer} in version: ${version} `;
if (date) {
message += `on ${date}`;
}
message += `🚀`;
message += `\n\nplatform | result\n---|---\n🤖 android 🤖|${androidResult}\n🖥 desktop 🖥|${desktopResult}`;
message += `\n🍎 iOS 🍎|${iOSResult}\n🕸 web 🕸|${webResult}`;
if (deployVerb === 'Cherry-picked' && !/no ?qa/gi.test(prTitle ?? '')) {
// eslint-disable-next-line max-len
message +=
'\n\n@Expensify/applauseleads please QA this PR and check it off on the [deploy checklist](https://github.com/Expensify/App/issues?q=is%3Aopen+is%3Aissue+label%3AStagingDeployCash) if it passes.';
}
if (note) {
message += `\n\n_Note:_ ${note}`;
}
return message;
}
if (isProd) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,16 @@ async function run() {
const iOSResult = getDeployTableMessage(core.getInput('IOS', {required: true}) as PlatformResult);
const webResult = getDeployTableMessage(core.getInput('WEB', {required: true}) as PlatformResult);

const date = core.getInput('DATE');
const note = core.getInput('NOTE');

function getDeployMessage(deployer: string, deployVerb: string, prTitle?: string): string {
let message = `🚀 [${deployVerb}](${workflowURL}) to ${isProd ? 'production' : 'staging'}`;
message += ` by https://github.com/${deployer} in version: ${version} 🚀`;
message += ` by https://github.com/${deployer} in version: ${version} `;
if (date) {
message += `on ${date}`;
}
message += `🚀`;
message += `\n\nplatform | result\n---|---\n🤖 android 🤖|${androidResult}\n🖥 desktop 🖥|${desktopResult}`;
message += `\n🍎 iOS 🍎|${iOSResult}\n🕸 web 🕸|${webResult}`;

Expand All @@ -67,6 +74,10 @@ async function run() {
'\n\n@Expensify/applauseleads please QA this PR and check it off on the [deploy checklist](https://github.com/Expensify/App/issues?q=is%3Aopen+is%3Aissue+label%3AStagingDeployCash) if it passes.';
}

if (note) {
message += `\n\n_Note:_ ${note}`;
}

return message;
}

Expand Down
34 changes: 34 additions & 0 deletions .github/scripts/verifyDeploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

ENV="$1"
EXPECTED_VERSION="$2"

BASE_URL=""
if [[ "$ENV" == 'staging' ]]; then
BASE_URL='https://staging.new.expensify.com'
else
BASE_URL='https://new.expensify.com'
fi

sleep 5
ATTEMPT=0
MAX_ATTEMPTS=10
while [[ $ATTEMPT -lt $MAX_ATTEMPTS ]]; do
((ATTEMPT++))

echo "Attempt $ATTEMPT: Checking deployed version..."
DOWNLOADED_VERSION="$(wget -q -O /dev/stdout "$BASE_URL"/version.json | jq -r '.version')"

if [[ "$EXPECTED_VERSION" == "$DOWNLOADED_VERSION" ]]; then
echo "Success: Deployed version matches local version: $DOWNLOADED_VERSION"
exit 0
fi

if [[ $ATTEMPT -lt $MAX_ATTEMPTS ]]; then
echo "Version mismatch, found $DOWNLOADED_VERSION. Retrying in 5 seconds..."
sleep 5
fi
done

echo "Error: Deployed version did not match local version after $MAX_ATTEMPTS attempts. Something went wrong..."
exit 1
Binary file modified .github/workflows/OSBotify-private-key.asc.gpg
Binary file not shown.
68 changes: 20 additions & 48 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -386,23 +386,11 @@ jobs:

- name: Verify staging deploy
if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }}
run: |
sleep 5
DOWNLOADED_VERSION="$(wget -q -O /dev/stdout https://staging.new.expensify.com/version.json | jq -r '.version')"
if [[ '${{ needs.prep.outputs.APP_VERSION }}' != "$DOWNLOADED_VERSION" ]]; then
echo "Error: deployed version $DOWNLOADED_VERSION does not match local version ${{ needs.prep.outputs.APP_VERSION }}. Something went wrong..."
exit 1
fi
run: ./.github/scripts/verifyDeploy.sh staging ${{ needs.prep.outputs.APP_VERSION }}

- name: Verify production deploy
if: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }}
run: |
sleep 5
DOWNLOADED_VERSION="$(wget -q -O /dev/stdout https://new.expensify.com/version.json | jq -r '.version')"
if [[ '${{ needs.prep.outputs.APP_VERSION }}' != "$DOWNLOADED_VERSION" ]]; then
echo "Error: deployed version $DOWNLOADED_VERSION does not match local version ${{ needs.prep.outputs.APP_VERSION }}. Something went wrong..."
exit 1
fi
run: ./.github/scripts/verifyDeploy.sh production ${{ needs.prep.outputs.APP_VERSION }}

- name: Upload web sourcemaps artifact
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -507,11 +495,13 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}

- name: Rename web and desktop sourcemaps artifacts before assets upload in order to have unique ReleaseAsset.name
continue-on-error: true
run: |
mv ./desktop-staging-sourcemaps-artifact/merged-source-map.js.map ./desktop-staging-sourcemaps-artifact/desktop-staging-merged-source-map.js.map
mv ./web-staging-sourcemaps-artifact/merged-source-map.js.map ./web-staging-sourcemaps-artifact/web-staging-merged-source-map.js.map
- name: Upload artifacts to GitHub Release
continue-on-error: true
run: |
gh release upload ${{ needs.prep.outputs.APP_VERSION }} --repo ${{ github.repository }} --clobber \
./android-sourcemaps-artifact/index.android.bundle.map#android-sourcemap-${{ needs.prep.outputs.APP_VERSION }} \
Expand Down Expand Up @@ -552,11 +542,6 @@ jobs:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4

- name: Rename web and desktop sourcemaps artifacts before assets upload in order to have unique ReleaseAsset.name
run: |
mv ./desktop-sourcemaps-artifact/merged-source-map.js.map ./desktop-sourcemaps-artifact/desktop-merged-source-map.js.map
mv ./web-sourcemaps-artifact/merged-source-map.js.map ./web-sourcemaps-artifact/web-merged-source-map.js.map
- name: 🚀 Edit the release to be no longer a prerelease 🚀
run: |
LATEST_RELEASE="$(gh release list --repo ${{ github.repository }} --exclude-pre-releases --json tagName,isLatest --jq '.[] | select(.isLatest) | .tagName')"
Expand All @@ -565,7 +550,14 @@ jobs:
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Rename web and desktop sourcemaps artifacts before assets upload in order to have unique ReleaseAsset.name
continue-on-error: true
run: |
mv ./desktop-sourcemaps-artifact/merged-source-map.js.map ./desktop-sourcemaps-artifact/desktop-merged-source-map.js.map
mv ./web-sourcemaps-artifact/merged-source-map.js.map ./web-sourcemaps-artifact/web-merged-source-map.js.map
- name: Upload artifacts to GitHub Release
continue-on-error: true
run: |
gh release upload ${{ needs.prep.outputs.APP_VERSION }} --repo ${{ github.repository }} --clobber \
./desktop-sourcemaps-artifact/desktop-merged-source-map.js.map#desktop-sourcemap-${{ needs.prep.outputs.APP_VERSION }} \
Expand Down Expand Up @@ -649,34 +641,14 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

postGithubComment:
name: Post a GitHub comments on all deployed PRs when platforms are done building and deploying
runs-on: ubuntu-latest
postGithubComments:
uses: ./.github/workflows/postDeployComments.yml
if: ${{ always() && fromJSON(needs.checkDeploymentSuccess.outputs.IS_AT_LEAST_ONE_PLATFORM_DEPLOYED) }}
needs: [prep, android, desktop, iOS, web, checkDeploymentSuccess, createPrerelease, finalizeRelease]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: ./.github/actions/composite/setupNode

- name: Get Release Pull Request List
id: getReleasePRList
uses: ./.github/actions/javascript/getDeployPullRequestList
with:
TAG: ${{ needs.prep.outputs.APP_VERSION }}
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}
IS_PRODUCTION_DEPLOY: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }}

- name: Comment on issues
uses: ./.github/actions/javascript/markPullRequestsAsDeployed
with:
PR_LIST: ${{ steps.getReleasePRList.outputs.PR_LIST }}
IS_PRODUCTION_DEPLOY: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }}
DEPLOY_VERSION: ${{ needs.prep.outputs.APP_VERSION }}
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}
ANDROID: ${{ needs.android.result }}
DESKTOP: ${{ needs.desktop.result }}
IOS: ${{ needs.iOS.result }}
WEB: ${{ needs.web.result }}
with:
version: ${{ needs.prep.outputs.APP_VERSION }}
env: ${{ github.ref == 'refs/heads/production' && 'production' || 'staging' }}
android: ${{ needs.android.result }}
ios: ${{ needs.iOS.result }}
web: ${{ needs.web.result }}
desktop: ${{ needs.desktop.result }}
110 changes: 110 additions & 0 deletions .github/workflows/deployNewHelp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Deploy New Help Site

on:
# Run on any push to main that has changes to the help directory. This will cause this
# to deploy the latest code to newhelp.expensify.com
push:
branches:
- main
paths:
- 'help/**'
- './.github/workflows/deployNewHelp.yml'

# Run on any pull request (except PRs against staging or production) that has
# changes to the help directory. This will cause it to deploy this unmerged branch to
# a Cloudflare "preview" environment
pull_request:
types: [opened, synchronize]
branches-ignore: [staging, production]
paths:
- 'help/**'
- './.github/workflows/deployNewHelp.yml'
# Run on any manual trigger
workflow_dispatch:

# Allow only one concurrent deployment
concurrency:
group: "newhelp"
cancel-in-progress: false

jobs:
build:
env:
# Open source contributors do not have write access to the Expensify/App repo,
# so must submit PRs from forks. This variable detects if the PR is coming
# from a fork, and thus is from an outside contributor.
IS_PR_FROM_FORK: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork }}

# Set up a clean Ubuntu build environment
runs-on: ubuntu-latest

steps:
# We start by checking out the entire repo into a clean build environment within
# the Github Action
- name: Checkout code
uses: actions/checkout@v4

# Set up Ruby and run bundle install inside the /help directory
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
working-directory: ./help

# Manually run Jekyll, bypassing Github Pages
- name: Build Jekyll site
run: bundle exec jekyll build --source ./ --destination ./_site
working-directory: ./help # Ensure Jekyll is building the site in /help

# This will copy the contents of /help/_site to Cloudflare. The pages-action will
# evaluate the current branch to determine into which CF environment to deploy:
# - If you are on 'main', it will deploy to 'production' in Cloudflare
# - Otherwise it will deploy to a 'preview' environment made for this branch
- name: Deploy to Cloudflare Pages
uses: cloudflare/pages-action@v1
id: cloudflarePagesAction
if: ${{ env.IS_PR_FROM_FORK != 'true' }}
with:
apiToken: ${{ secrets.CLOUDFLARE_PAGES_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: newhelp
directory: ./help/_site # Deploy the built site

# After deploying Cloudflare preview build, share wherever it deployed to in the PR comment.
- name: Leave a comment on the PR
uses: actions-cool/[email protected]
if: ${{ github.event_name == 'pull_request' && env.IS_PR_FROM_FORK != 'true' }}
with:
token: ${{ github.token }}
body: ${{ format('Your New Help changes have been deployed to {0} :zap:️', steps.cloudflarePagesAction.outputs.alias) }}

- name: Get merged pull request
if: ${{ github.event_name == 'push' }}
id: getMergedPullRequest
uses: actions-ecosystem/action-get-merged-pull-request@59afe90821bb0b555082ce8ff1e36b03f91553d9
with:
github_token: ${{ github.token }}

- name: Leave a comment on the PR after it's merged
if: ${{ github.event_name == 'push' }}
run: |
gh pr comment ${{ steps.getMergedPullRequest.outputs.number }} --body "$(cat <<'EOF'
🚀Deployed to [NewHelp production](https://newhelp.expensify.com)! 🚀
([_View deploy workflow run_](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}))
EOF
)"
env:
GITHUB_TOKEN: ${{ github.token }}

# Use the Cloudflare CLI...
- name: Setup Cloudflare CLI
if: ${{ env.IS_PR_FROM_FORK != 'true' }}
run: pip3 install cloudflare==2.19.0

# ... to purge the cache, such that all users will see the latest content.
- name: Purge Cloudflare cache
if: ${{ env.IS_PR_FROM_FORK != 'true' }}
run: /home/runner/.local/bin/cli4 --verbose --delete hosts=["newhelp.expensify.com"] /zones/:9ee042e6cfc7fd45e74aa7d2f78d617b/purge_cache
env:
CF_API_KEY: ${{ secrets.CLOUDFLARE_TOKEN }}
Loading

0 comments on commit 68c3e0b

Please sign in to comment.