Skip to content

Commit d89daad

Browse files
authored
Merge branch 'gen2-migration' into extend-default-resolvers
2 parents 62fe0b4 + 8ec55c5 commit d89daad

303 files changed

Lines changed: 9105 additions & 3134 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.

.agent-docs/DEPENDABOT.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Dependabot Upgrade Workflow
2+
3+
Guide for handling Dependabot alerts, dependency upgrades, and security fixes.
4+
5+
## Checking Dependabot Alerts
6+
7+
**Prerequisites:** GitHub CLI (`gh`) must be installed and authenticated.
8+
9+
Install:
10+
11+
```bash
12+
# macOS
13+
brew install gh
14+
15+
# Windows
16+
winget install GitHub.cli
17+
18+
# Linux
19+
# See https://github.com/cli/cli#installation
20+
```
21+
22+
Authenticate:
23+
24+
```bash
25+
gh auth login
26+
```
27+
28+
Check alerts:
29+
30+
```bash
31+
npx ts-node scripts/check-dependabot.ts
32+
```
33+
34+
## Workflow for Agents
35+
36+
When asked to handle dependency upgrades, security fixes, or Dependabot issues:
37+
38+
### 1. Check Outstanding Alerts
39+
40+
Run the Dependabot checker to get current alerts.
41+
42+
### 2. Summarize and Categorize
43+
44+
Group alerts into categories:
45+
46+
- **Dependency updates only** - Simple version bumps in package.json
47+
- **Code changes required** - Breaking changes needing code modifications
48+
- **Security fixes** - CVE patches (prioritize by severity: critical > high > medium > low)
49+
50+
Present summary to user with counts per category.
51+
52+
### 3. Ask User for Scope
53+
54+
Confirm what to address:
55+
56+
- All alerts in a single PR?
57+
- Only dependency updates?
58+
- Only security fixes above a certain severity?
59+
- Specific packages?
60+
61+
### 4. Make Changes
62+
63+
For each change:
64+
65+
- Update package.json (or relevant package files)
66+
- Run `yarn install` to update yarn.lock
67+
- Run `yarn build` to verify build succeeds
68+
- Run `yarn test` to verify tests pass
69+
- Fix any breaking changes if needed
70+
71+
### 5. Commit and Push
72+
73+
```bash
74+
git checkout -b dependabot-fixes-YYYY-MM-DD
75+
git add .
76+
git commit -m "fix: address dependabot alerts
77+
78+
- Update package1 to vX.Y.Z
79+
- Update package2 to vX.Y.Z
80+
- Fix breaking changes in ..."
81+
git push origin dependabot-fixes-YYYY-MM-DD
82+
```
83+
84+
### 6. E2E Test
85+
86+
Follow the e2e workflow from AGENTS.md:
87+
88+
```bash
89+
yarn cloud-e2e
90+
yarn e2e-monitor {batchId}
91+
```
92+
93+
### 7. Resolve Errors
94+
95+
- If e2e tests fail due to code issues, fix and repeat from step 4
96+
- If timeouts/quota errors, retry the build
97+
- Ask user for guidance if errors persist after multiple attempts
98+
99+
## Notes
100+
101+
- Always run local tests before pushing
102+
- Group related updates together when possible
103+
- Document breaking changes in commit messages
104+
- Check for peer dependency conflicts after updates

.agent-docs/LOCAL_E2E_TESTING.md

Lines changed: 291 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,291 @@
1+
# Local E2E Testing and Build Simulation
2+
3+
This guide explains how to run e2e test steps and build jobs locally to debug failures before pushing to CI.
4+
5+
## Overview
6+
7+
E2E tests run in AWS CodeBuild with specific build steps defined in `codebuild_specs/*.yml`. Each build spec calls functions from `shared-scripts.sh`. You can simulate these steps locally to debug issues.
8+
9+
## Prerequisites
10+
11+
### Authentication
12+
13+
Most e2e operations require AWS credentials. The repository uses `ada` (Amazon's credential management tool) for authentication, which is called automatically by the scripts.
14+
15+
**Setup:**
16+
17+
1. Ensure you have `ada` and `mwinit` installed
18+
2. Create `scripts/.env` file with account details:
19+
```bash
20+
# scripts/.env
21+
E2E_ACCOUNT_PROD=<account-id>
22+
E2E_ACCOUNT_BETA=<account-id>
23+
```
24+
3. If you see authentication errors, run `mwinit` in your terminal
25+
26+
**Note:** The scripts automatically call `ada` for credential refresh. You don't need to run `ada` commands manually.
27+
28+
## Common Build Steps
29+
30+
### 1. Unit Tests (`test` build)
31+
32+
**What it does:** Runs all unit tests with coverage in CI mode
33+
34+
**Command:**
35+
36+
```bash
37+
yarn test-ci
38+
```
39+
40+
**Equivalent to:**
41+
42+
```bash
43+
lerna run test --concurrency 4 -- --ci -i
44+
```
45+
46+
**Common issues:**
47+
48+
- Coverage threshold failures: Check `jest.config.js` in the failing package
49+
- Pre-existing coverage issues may not be related to your changes
50+
- To verify if an issue is pre-existing, test on the base branch
51+
52+
### 2. Linting (`lint` build)
53+
54+
**What it does:** Checks code style and linting rules
55+
56+
**Command:**
57+
58+
```bash
59+
yarn lint-check
60+
```
61+
62+
**Common issues:**
63+
64+
- Use `yarn lint-fix` to auto-fix some issues
65+
- Some lint errors require manual fixes
66+
- Check `.eslintrc.js` for linting rules
67+
68+
### 3. Local Registry Publish (`publish_to_local_registry` build)
69+
70+
**What it does:** Publishes packages to a local Verdaccio registry for e2e testing
71+
72+
**Command:**
73+
74+
```bash
75+
# Start Verdaccio (in separate terminal)
76+
yarn verdaccio-start
77+
78+
# Publish packages
79+
yarn publish-to-verdaccio
80+
81+
# Stop Verdaccio when done
82+
yarn verdaccio-stop
83+
```
84+
85+
**Common issues:**
86+
87+
- Requires Verdaccio running locally
88+
- May fail if packages have version conflicts
89+
- Check `lerna.json` for version configuration
90+
91+
### 4. Windows Build (`build_windows` build)
92+
93+
**What it does:** Builds all packages on Windows with Node.js 22 or later
94+
95+
**Command (on Windows):**
96+
97+
```powershell
98+
yarn production-build
99+
yarn build-tests
100+
```
101+
102+
**Command (on macOS/Linux):**
103+
Cannot be fully simulated on non-Windows systems. However, you can:
104+
105+
```bash
106+
yarn production-build
107+
yarn build-tests
108+
```
109+
110+
**Common issues:**
111+
112+
- Path separator differences (Windows uses `\`, Unix uses `/`)
113+
- Line ending differences (CRLF vs LF)
114+
- Case-sensitive filesystem differences
115+
- Windows-specific Node.js modules
116+
117+
### 5. Linux Build (`build_linux` build)
118+
119+
**What it does:** Builds all packages on Linux
120+
121+
**Command:**
122+
123+
```bash
124+
yarn production-build
125+
yarn build-tests
126+
```
127+
128+
**Common issues:**
129+
130+
- Build errors usually indicate TypeScript or dependency issues
131+
- Check for missing dependencies in package.json files
132+
133+
## Debugging E2E Failures
134+
135+
### Step 1: Identify the Failing Build
136+
137+
```bash
138+
yarn e2e-failed <batch-id>
139+
```
140+
141+
This shows which specific builds failed.
142+
143+
### Step 2: Get Build Logs
144+
145+
```bash
146+
yarn e2e-logs <build-id>
147+
```
148+
149+
This downloads and displays the full build log.
150+
151+
### Step 3: Simulate Locally
152+
153+
Run the equivalent local command (see sections above) to reproduce the issue.
154+
155+
### Step 4: Check for Pre-existing Issues
156+
157+
Before fixing, verify the issue exists on the base branch:
158+
159+
```bash
160+
# Stash your changes
161+
git stash
162+
163+
# Checkout base branch
164+
git checkout dev
165+
166+
# Run the failing command
167+
yarn <command>
168+
169+
# Restore your changes
170+
git checkout <your-branch>
171+
git stash pop
172+
```
173+
174+
## E2E Test Workflow
175+
176+
### Full E2E Test Suite
177+
178+
```bash
179+
# 1. Commit and push all changes
180+
git push
181+
182+
# 2. Trigger e2e suite
183+
yarn cloud-e2e
184+
185+
# 3. Monitor with auto-retry
186+
yarn e2e-monitor <batch-id>
187+
```
188+
189+
### Targeted E2E Tests
190+
191+
You can run specific e2e test files locally:
192+
193+
```bash
194+
# Run specific test file
195+
cd packages/amplify-e2e-tests
196+
yarn e2e src/__tests__/api_1.test.ts
197+
```
198+
199+
**Note:** Local e2e tests still require AWS credentials and will create real resources in your AWS account.
200+
201+
## Common Failure Patterns
202+
203+
### 1. Transient Infrastructure Failures
204+
205+
**Symptoms:**
206+
207+
- Timeout errors
208+
- Credential expiration
209+
- Quota/limit errors
210+
211+
**Solution:** Retry the build
212+
213+
```bash
214+
yarn e2e-retry <batch-id>
215+
```
216+
217+
### 2. Code-Related Failures
218+
219+
**Symptoms:**
220+
221+
- Test failures
222+
- Build errors
223+
- Linting errors
224+
- Coverage threshold failures
225+
226+
**Solution:** Fix the code and re-run locally, then push and re-trigger e2e tests
227+
228+
### 3. Dependency-Related Failures
229+
230+
**Symptoms:**
231+
232+
- Module not found errors
233+
- Version conflicts
234+
- Breaking API changes
235+
236+
**Solution:**
237+
238+
- Check if dependency upgrade is necessary
239+
- Look for major version changes that may have breaking changes
240+
- Consider pinning to a compatible version
241+
242+
## Build Job Types
243+
244+
The e2e workflow includes these build types:
245+
246+
- `build_linux` - Build on Linux (not retried by monitor)
247+
- `build_windows` - Build on Windows (not retried by monitor)
248+
- `test` - Run unit tests (not retried by monitor)
249+
- `lint` - Run linting (not retried by monitor)
250+
- `verify_yarn_lock` - Verify yarn.lock consistency
251+
- `publish_to_local_registry` - Publish to Verdaccio
252+
- `amplify_e2e_tests_*` - E2E test suites (multiple jobs)
253+
254+
**Note:** The monitor script skips auto-retrying `build_linux`, `build_windows`, `test`, and `lint` because failures in these are typically code-related and require fixes, not retries.
255+
256+
## Tips
257+
258+
1. **Always test locally first** before pushing to CI
259+
2. **Check pre-commit hooks** - they run tests automatically
260+
3. **Monitor resource usage** - e2e tests create real AWS resources
261+
4. **Clean up resources** - use cleanup scripts periodically
262+
5. **Check credentials** - most failures are due to expired credentials
263+
6. **Read the logs** - build logs contain detailed error information
264+
265+
## Troubleshooting
266+
267+
### "Command failed with exit code 1"
268+
269+
This is a generic error. Check the full output for the actual error message.
270+
271+
### "Cannot read properties of undefined"
272+
273+
Often indicates a dependency version mismatch or breaking API change.
274+
275+
### "Coverage threshold not met"
276+
277+
Check if this is a pre-existing issue by testing on the base branch. Coverage can change due to:
278+
279+
- Code changes
280+
- Dependency updates affecting how coverage is calculated
281+
- Test changes
282+
283+
### "Linting errors"
284+
285+
Run `yarn lint-fix` to auto-fix some issues. Others require manual fixes.
286+
287+
## Related Documentation
288+
289+
- [DEPENDABOT.md](./DEPENDABOT.md) - Dependency update workflow
290+
- [AGENTS.md](../AGENTS.md) - General agent workflow
291+
- [shared-scripts.sh](../shared-scripts.sh) - Build step implementations

0 commit comments

Comments
 (0)