Skip to content

Commit

Permalink
Reset amount on reset button click
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushiktd committed Jul 10, 2024
1 parent 8042286 commit 5a2602c
Show file tree
Hide file tree
Showing 771 changed files with 28,480 additions and 6,601 deletions.
11 changes: 7 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const restrictedImportPaths = [
'',
"For 'useWindowDimensions', please use '@src/hooks/useWindowDimensions' instead.",
"For 'TouchableOpacity', 'TouchableWithoutFeedback', 'TouchableNativeFeedback', 'TouchableHighlight', 'Pressable', please use 'PressableWithFeedback' and/or 'PressableWithoutFeedback' from '@components/Pressable' instead.",
"For 'StatusBar', please use '@src/libs/StatusBar' instead.",
"For 'StatusBar', please use '@libs/StatusBar' instead.",
"For 'Text', please use '@components/Text' instead.",
"For 'ScrollView', please use '@components/ScrollView' instead.",
].join('\n'),
Expand Down Expand Up @@ -59,8 +59,12 @@ const restrictedImportPaths = [
},
{
name: 'expensify-common',
importNames: ['Device'],
message: "Do not import Device directly, it's known to make VSCode's IntelliSense crash. Please import the desired module from `expensify-common/dist/Device` instead.",
importNames: ['Device', 'ExpensiMark'],
message: [
'',
"For 'Device', do not import it directly, it's known to make VSCode's IntelliSense crash. Please import the desired module from `expensify-common/dist/Device` instead.",
"For 'ExpensiMark', please use '@libs/Parser' instead.",
].join('\n'),
},
];

Expand Down Expand Up @@ -109,7 +113,6 @@ module.exports = {
},
rules: {
// TypeScript specific rules
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/prefer-enum-initializers': 'error',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-non-null-assertion': 'error',
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/javascript/bumpVersion/bumpVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ if (!semanticVersionLevel || !versionUpdater.isValidSemverLevel(semanticVersionL
console.log(`Invalid input for 'SEMVER_LEVEL': ${semanticVersionLevel}`, `Defaulting to: ${semanticVersionLevel}`);
}

const {version: previousVersion}: PackageJson = JSON.parse(fs.readFileSync('./package.json').toString());
const {version: previousVersion} = JSON.parse(fs.readFileSync('./package.json').toString()) as PackageJson;
if (!previousVersion) {
core.setFailed('Error: Could not read package.json');
}
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/javascript/bumpVersion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1928,7 +1928,7 @@ class SemVer {
do {
const a = this.build[i]
const b = other.build[i]
debug('prerelease compare', i, a, b)
debug('build compare', i, a, b)
if (a === undefined && b === undefined) {
return 0
} else if (b === undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import GitUtils from '@github/libs/GitUtils';

type IssuesCreateResponse = Awaited<ReturnType<typeof GithubUtils.octokit.issues.create>>['data'];

type PackageJSON = {
type PackageJson = {
version: string;
};

async function run(): Promise<IssuesCreateResponse | void> {
// Note: require('package.json').version does not work because ncc will resolve that to a plain string at compile time
const packageJson: PackageJSON = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8')) as PackageJson;
const newVersionTag = packageJson.version;

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,27 @@ async function run() {
status: 'completed',
event: isProductionDeploy ? 'release' : 'push',
})
).data.workflow_runs;
).data.workflow_runs
// Note: we filter out cancelled runs instead of looking only for success runs
// because if a build fails on even one platform, then it will have the status 'failure'
.filter((workflowRun) => workflowRun.conclusion !== 'cancelled');

// Find the most recent deploy workflow for which at least one of the build jobs finished successfully.
let lastSuccessfulDeploy = completedDeploys.shift();
while (
lastSuccessfulDeploy &&
!(
await GithubUtils.octokit.actions.listJobsForWorkflowRun({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
// eslint-disable-next-line @typescript-eslint/naming-convention
run_id: lastSuccessfulDeploy.id,
filter: 'latest',
})
).data.jobs.some((job) => job.name.startsWith('Build and deploy') && job.conclusion === 'success')
) {
lastSuccessfulDeploy = completedDeploys.shift();
}

const priorTag = completedDeploys[0].head_branch;
console.log(`Looking for PRs deployed to ${deployEnv} between ${priorTag} and ${inputTag}`);
Expand Down
17 changes: 16 additions & 1 deletion .github/actions/javascript/getDeployPullRequestList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11515,7 +11515,22 @@ async function run() {
workflow_id: 'platformDeploy.yml',
status: 'completed',
event: isProductionDeploy ? 'release' : 'push',
})).data.workflow_runs;
})).data.workflow_runs
// Note: we filter out cancelled runs instead of looking only for success runs
// because if a build fails on even one platform, then it will have the status 'failure'
.filter((workflowRun) => workflowRun.conclusion !== 'cancelled');
// Find the most recent deploy workflow for which at least one of the build jobs finished successfully.
let lastSuccessfulDeploy = completedDeploys.shift();
while (lastSuccessfulDeploy &&
!(await GithubUtils_1.default.octokit.actions.listJobsForWorkflowRun({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
// eslint-disable-next-line @typescript-eslint/naming-convention
run_id: lastSuccessfulDeploy.id,
filter: 'latest',
})).data.jobs.some((job) => job.name.startsWith('Build and deploy') && job.conclusion === 'success')) {
lastSuccessfulDeploy = completedDeploys.shift();
}
const priorTag = completedDeploys[0].head_branch;
console.log(`Looking for PRs deployed to ${deployEnv} between ${priorTag} and ${inputTag}`);
const prList = await GitUtils_1.default.getPullRequestsMergedBetween(priorTag ?? '', inputTag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const run = () => {
}

try {
const current: RegressionEntry = JSON.parse(entry);
const current = JSON.parse(entry) as RegressionEntry;

// Extract timestamp, Graphite accepts timestamp in seconds
if (current.metadata?.creationDate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function run() {
core.setFailed(`'Error: Invalid input for 'SEMVER_LEVEL': ${semverLevel}`);
}

const {version: currentVersion}: PackageJson = JSON.parse(readFileSync('./package.json', 'utf8'));
const {version: currentVersion} = JSON.parse(readFileSync('./package.json', 'utf8')) as PackageJson;
if (!currentVersion) {
core.setFailed('Error: Could not read package.json');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {CompareResult, PerformanceEntry} from '@callstack/reassure-compare/
import fs from 'fs';

const run = (): boolean => {
const regressionOutput: CompareResult = JSON.parse(fs.readFileSync('.reassure/output.json', 'utf8'));
const regressionOutput = JSON.parse(fs.readFileSync('.reassure/output.json', 'utf8')) as CompareResult;
const countDeviation = Number(core.getInput('COUNT_DEVIATION', {required: true}));
const durationDeviation = Number(core.getInput('DURATION_DEVIATION_PERCENTAGE', {required: true}));

Expand Down
38 changes: 37 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ jobs:

- name: 🚀 Push tags to trigger staging deploy 🚀
run: git push --tags

- name: Warn deployers if staging deploy failed
if: ${{ failure() }}
uses: 8398a7/action-slack@v3
with:
status: custom
custom_payload: |
{
channel: '#deployer',
attachments: [{
color: "#DB4545",
pretext: `<!subteam^S4TJJ3PSL>`,
text: `💥 NewDot staging deploy failed. 💥`,
}]
}
env:
GITHUB_TOKEN: ${{ github.token }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

deployProduction:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -65,6 +83,24 @@ jobs:
PR_LIST: ${{ steps.getReleasePRList.outputs.PR_LIST }}

- name: 🚀 Create release to trigger production deploy 🚀
run: gh release create ${{ env.PRODUCTION_VERSION }} --generate-notes
run: gh release create ${{ env.PRODUCTION_VERSION }} --notes '${{ steps.getReleaseBody.outputs.RELEASE_BODY }}'
env:
GITHUB_TOKEN: ${{ steps.setupGitForOSBotify.outputs.OS_BOTIFY_API_TOKEN }}

- name: Warn deployers if production deploy failed
if: ${{ failure() }}
uses: 8398a7/action-slack@v3
with:
status: custom
custom_payload: |
{
channel: '#deployer',
attachments: [{
color: "#DB4545",
pretext: `<!subteam^S4TJJ3PSL>`,
text: `💥 NewDot production deploy failed. 💥`,
}]
}
env:
GITHUB_TOKEN: ${{ github.token }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
3 changes: 3 additions & 0 deletions .github/workflows/e2ePerformanceTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ jobs:

- name: Copy e2e code into zip folder
run: cp tests/e2e/dist/index.js zip/testRunner.ts

- name: Copy profiler binaries into zip folder
run: cp -r node_modules/@perf-profiler/android/cpp-profiler/bin zip/bin

- name: Zip everything in the zip directory up
run: zip -qr App.zip ./zip
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reassurePerformanceTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ jobs:
git fetch origin "$BASELINE_BRANCH" --no-tags --depth=1
git switch "$BASELINE_BRANCH"
npm install --force
npx reassure --baseline
NODE_OPTIONS=--experimental-vm-modules npx reassure --baseline
git switch --force --detach -
git merge --no-commit --allow-unrelated-histories "$BASELINE_BRANCH" -X ours
git checkout --ours .
npm install --force
npx reassure --branch
NODE_OPTIONS=--experimental-vm-modules npx reassure --branch
- name: Validate output.json
id: validateReassureOutput
Expand Down
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
arrowParens: 'always',
printWidth: 190,
singleAttributePerLine: true,
plugins: [require.resolve('@trivago/prettier-plugin-sort-imports')],
/** `importOrder` should be defined in an alphabetical order. */
importOrder: [
'@assets/(.*)$',
Expand Down
18 changes: 9 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ GEM
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
Expand All @@ -20,17 +20,17 @@ GEM
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.944.0)
aws-sdk-core (3.197.0)
aws-partitions (1.948.0)
aws-sdk-core (3.199.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.85.0)
aws-sdk-core (~> 3, >= 3.197.0)
aws-sdk-kms (1.87.0)
aws-sdk-core (~> 3, >= 3.199.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.152.3)
aws-sdk-core (~> 3, >= 3.197.0)
aws-sdk-s3 (1.154.0)
aws-sdk-core (~> 3, >= 3.199.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.8)
aws-sigv4 (1.8.0)
Expand Down Expand Up @@ -119,7 +119,7 @@ GEM
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.3.1)
fastlane (2.221.0)
fastlane (2.221.1)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
Expand Down
66 changes: 61 additions & 5 deletions __mocks__/@react-navigation/native/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,65 @@
import {useIsFocused as realUseIsFocused, useTheme as realUseTheme} from '@react-navigation/native';
/* eslint-disable import/prefer-default-export, import/no-import-module-exports */
import type * as ReactNavigation from '@react-navigation/native';
import createAddListenerMock from '../../../tests/utils/createAddListenerMock';

// We only want these mocked for storybook, not jest
const useIsFocused: typeof realUseIsFocused = process.env.NODE_ENV === 'test' ? realUseIsFocused : () => true;
const isJestEnv = process.env.NODE_ENV === 'test';

const useTheme = process.env.NODE_ENV === 'test' ? realUseTheme : () => ({});
const realReactNavigation = isJestEnv ? jest.requireActual<typeof ReactNavigation>('@react-navigation/native') : (require('@react-navigation/native') as typeof ReactNavigation);

const useIsFocused = isJestEnv ? realReactNavigation.useIsFocused : () => true;
const useTheme = isJestEnv ? realReactNavigation.useTheme : () => ({});

const {triggerTransitionEnd, addListener} = isJestEnv
? createAddListenerMock()
: {
triggerTransitionEnd: () => {},
addListener: () => {},
};

const useNavigation = () => ({
...realReactNavigation.useNavigation,
navigate: jest.fn(),
getState: () => ({
routes: [],
}),
addListener,
});

type NativeNavigationMock = typeof ReactNavigation & {
triggerTransitionEnd: () => void;
};

export * from '@react-navigation/core';
export {useIsFocused, useTheme};
const Link = realReactNavigation.Link;
const LinkingContext = realReactNavigation.LinkingContext;
const NavigationContainer = realReactNavigation.NavigationContainer;
const ServerContainer = realReactNavigation.ServerContainer;
const DarkTheme = realReactNavigation.DarkTheme;
const DefaultTheme = realReactNavigation.DefaultTheme;
const ThemeProvider = realReactNavigation.ThemeProvider;
const useLinkBuilder = realReactNavigation.useLinkBuilder;
const useLinkProps = realReactNavigation.useLinkProps;
const useLinkTo = realReactNavigation.useLinkTo;
const useScrollToTop = realReactNavigation.useScrollToTop;
export {
// Overriden modules
useIsFocused,
useTheme,
useNavigation,
triggerTransitionEnd,

// Theme modules are left alone
Link,
LinkingContext,
NavigationContainer,
ServerContainer,
DarkTheme,
DefaultTheme,
ThemeProvider,
useLinkBuilder,
useLinkProps,
useLinkTo,
useScrollToTop,
};

export type {NativeNavigationMock};
16 changes: 8 additions & 8 deletions __mocks__/@ua/react-native-airship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,31 @@ const iOS: Partial<typeof AirshipIOS> = {
},
};

const pushIOS: AirshipPushIOS = jest.fn().mockImplementation(() => ({
const pushIOS = jest.fn().mockImplementation(() => ({
setBadgeNumber: jest.fn(),
setForegroundPresentationOptions: jest.fn(),
setForegroundPresentationOptionsCallback: jest.fn(),
}))();
}))() as AirshipPushIOS;

const pushAndroid: AirshipPushAndroid = jest.fn().mockImplementation(() => ({
const pushAndroid = jest.fn().mockImplementation(() => ({
setForegroundDisplayPredicate: jest.fn(),
}))();
}))() as AirshipPushAndroid;

const push: AirshipPush = jest.fn().mockImplementation(() => ({
const push = jest.fn().mockImplementation(() => ({
iOS: pushIOS,
android: pushAndroid,
enableUserNotifications: () => Promise.resolve(false),
clearNotifications: jest.fn(),
getNotificationStatus: () => Promise.resolve({airshipOptIn: false, systemEnabled: false, airshipEnabled: false}),
getActiveNotifications: () => Promise.resolve([]),
}))();
}))() as AirshipPush;

const contact: AirshipContact = jest.fn().mockImplementation(() => ({
const contact = jest.fn().mockImplementation(() => ({
identify: jest.fn(),
getNamedUserId: () => Promise.resolve(undefined),
reset: jest.fn(),
module: jest.fn(),
}))();
}))() as AirshipContact;

const Airship: Partial<AirshipRoot> = {
addListener: jest.fn(),
Expand Down
1 change: 1 addition & 0 deletions __mocks__/fs.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
const {fs} = require('memfs');

module.exports = fs;
Loading

0 comments on commit 5a2602c

Please sign in to comment.