Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(build system): add React tests for loadtest #3703

Merged
merged 111 commits into from
Apr 19, 2023
Merged

Conversation

0618
Copy link
Contributor

@0618 0618 commented Apr 11, 2023

Description of changes

Image (2)

  • Add Build System test workflow for 9 React apps of different frameworks
  • Add templates for 9 React apps of different frameworks
Framework Build Tool Language Node Version Pkg Manager App Name
React 18 CRA latest ts 18 npm react-18-cra-latest-node-18-ts
React 18 CRA latest js 18 npm react-18-cra-latest-node-18-js
React 18 CRA latest ts 16 npm react-18-cra-latest-node-16-ts
React 18 CRA latest ts 18 yarn react-18-cra-latest-node-18-ts
React 16 CRA latest ts 18 npm react-16-cra-latest-node-18-ts
React 18 Next latest ts 18 npm react-18-next-latest-node-18-ts
React 17 Next 11 ts 16 npm react-18-next-11-node-16-js
React 18 Vite latest ts 18 npm react-18-vite-latest-node-18-ts
React 17 Vite 2 ts 16 npm react-18-vite-11-node-16-js

TODO:

  • Gatsby app is commented out and will be added later.
  • The trigger of the workflow will be enabled once it's approved.

Issue #, if available

Description of how you validated changes

Tested on fork's build: Mega App Canary - React

PoC PR on fork: 0618#20

PoC PR in this repo: #3751

Checklist

  • PR description included
  • yarn test passes
  • Tests are updated
  • No side effects or sideEffects field updated
  • Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@0618 0618 temporarily deployed to ci April 17, 2023 17:39 — with GitHub Actions Inactive
@0618 0618 temporarily deployed to ci April 17, 2023 17:39 — with GitHub Actions Inactive
@0618 0618 temporarily deployed to ci April 17, 2023 17:39 — with GitHub Actions Inactive
@0618 0618 temporarily deployed to ci April 17, 2023 17:39 — with GitHub Actions Inactive
@0618 0618 temporarily deployed to ci April 18, 2023 20:18 — with GitHub Actions Inactive
@0618 0618 temporarily deployed to ci April 18, 2023 20:18 — with GitHub Actions Inactive
@0618 0618 temporarily deployed to ci April 18, 2023 20:18 — with GitHub Actions Inactive
@0618 0618 temporarily deployed to ci April 18, 2023 20:18 — with GitHub Actions Inactive
@0618 0618 changed the title test(build system): add React tests test(build system): add React tests for loadtest Apr 18, 2023
@0618 0618 temporarily deployed to ci April 18, 2023 21:23 — with GitHub Actions Inactive
@0618 0618 temporarily deployed to ci April 18, 2023 21:23 — with GitHub Actions Inactive
@0618 0618 temporarily deployed to ci April 18, 2023 21:23 — with GitHub Actions Inactive
@0618 0618 temporarily deployed to ci April 18, 2023 21:23 — with GitHub Actions Inactive
@0618 0618 temporarily deployed to ci April 19, 2023 19:10 — with GitHub Actions Inactive
@0618 0618 temporarily deployed to ci April 19, 2023 19:10 — with GitHub Actions Inactive
@0618 0618 temporarily deployed to ci April 19, 2023 19:10 — with GitHub Actions Inactive
@0618 0618 temporarily deployed to ci April 19, 2023 19:10 — with GitHub Actions Inactive
@@ -0,0 +1,35 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this file autogenerated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was modified from the auto-generated nextjs 13

} from '@aws-amplify/ui-react';
import { StorageManager } from '@aws-amplify/ui-react-storage';
import '@aws-amplify/ui-react/styles.css';
import awsconfig from '@/data/aws-exports';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use relative path instead of @/?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@/ was from the auto-generated config. Since we try to mimic the users behavior, it might be better not change it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, not blocking then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good with leaving tsconfig as-is then, but let's use relative path in the import statement, since that's what we use in docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good catch. The newer version of Next.js auto generated the relative path as default, so I kept it here

@@ -0,0 +1,13 @@
// @ts-nocheck
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is @ts-nocheck necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise there would be a lot of red marks in VS Code.

That might be a good point. Would that prevent some necessary build failures if there's any TS issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we're interested in catching TS errors, let's remove it.

<AccountSettings.ChangePassword onSuccess={() => {}} />
<AccountSettings.DeleteUser onSuccess={() => {}} />
<StorageManager
acceptedFileTypes={['image/*']}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, but spacing seems off. Can you run prettier?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 3f68159

Comment on lines +8 to +9
push:
branches: [main] # Run when merge to main
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we run this on push? I don't see much value in this, because build-system-tests will test against @latest, not the commit that was just merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that might be my mis-understanding. I thought push on main is publish to @latest 😂

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

push on main is by default publish to @next unless the commit is from "Version Packages" PR. In either way, we would have to wait until publish-next finishes to run build test against it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done b645eeb

"next": "^11.1.3",
"react": "17",
"react-dom": "17",
"typescript": "5.0.3"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is typescript meant to be pinned?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I'll test and address it in the real PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 3f68159

Comment on lines +33 to +35
{({ signOut, user = { username: '' } }) => (
<main>
<h1>Hello {user.username}</h1>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about

Suggested change
{({ signOut, user = { username: '' } }) => (
<main>
<h1>Hello {user.username}</h1>
{({ signOut, user }) => (
<main>
<h1>Hello {user.username}</h1>

to mimic our documentation code?

Copy link
Contributor

@wlee221 wlee221 Apr 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or user?.username if above isn't TS strict compliant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our docs would have a type error. We have to either set a default value or add a question mark like user?.username 😂

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a question mark for now. Let's add a ticket for updating our docs for TS strict customers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 3f68159

@0618 0618 merged commit 271da8b into main Apr 19, 2023
@0618 0618 deleted the mega-app-canary-react branch April 19, 2023 21:30
0618 added a commit that referenced this pull request Apr 19, 2023
0618 added a commit that referenced this pull request Apr 19, 2023
@0618 0618 mentioned this pull request Jun 20, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants