Skip to content

chore: e2e and dependabot management scripting + agent docs#14625

Merged
svidgen merged 6 commits intodevfrom
wirej/agentic-stuff
Mar 12, 2026
Merged

chore: e2e and dependabot management scripting + agent docs#14625
svidgen merged 6 commits intodevfrom
wirej/agentic-stuff

Conversation

@svidgen
Copy link
Copy Markdown
Member

@svidgen svidgen commented Feb 26, 2026

Adds scripting and agentic guidance to assist with:

  1. Running, monitoring, and troubleshooting e2e test runs
  2. Agent-driven/bulk dependabot upgrades
  3. Testing CB images with CODEBUILD_IMAGE_OVERRIDE environment variable

Adapted from amplify-category-api.

- Add AGENTS.md with workflow guide for AI agents
- Add .agent-docs/DEPENDABOT.md for dependency management workflow
- Add .agent-docs/LOCAL_E2E_TESTING.md for local testing guide
- Add scripts/e2e-test-manager.ts for e2e test management
- Add scripts/check-dependabot.ts for checking security alerts
- Add e2e management commands to package.json (e2e-status, e2e-retry, e2e-monitor, etc.)
- Add AWS SDK dependencies to scripts/package.json

This infrastructure enables AI coding tools to:
- Monitor e2e test status with auto-retry
- Check and manage Dependabot alerts
- Follow consistent workflows for development and testing
console.log(`Retrying ${failedBuildIds.length} failed builds using retry-build-batch`);

try {
const result = execSync(`aws codebuild retry-build-batch --region=${REGION} --profile=${E2E_PROFILE_NAME} --id="${batchId}"`, {

Check warning

Code scanning / CodeQL

Indirect uncontrolled command line Medium

This command depends on an unsanitized
command-line argument
.

Copilot Autofix

AI about 2 months ago

In general, the way to fix this is to avoid passing untrusted data into a shell command string. Instead of execSync (string), use an API that does not invoke a shell and accepts arguments as an array, such as execFileSync from child_process. This prevents shell metacharacters in batchId from being interpreted by the shell.

Concretely for this script:

  • Change the import from execSync to execFileSync.
  • Replace the execSync call in retryFailedBuilds with an execFileSync call where:
    • The command is 'aws'.
    • The arguments are passed as an array: ['codebuild', 'retry-build-batch', '--region', REGION, '--profile', E2E_PROFILE_NAME, '--id', batchId].
  • Keep the options object with encoding: 'utf8', stdio: 'pipe' so the behavior (capturing JSON output as a string) is preserved.
  • Do not add additional validation or change how batchId is passed to AWS, to avoid altering existing functionality; simply prevent the shell from interpreting it.

All necessary changes are within scripts/e2e-test-manager.ts:

  1. Update the import line at the top to import execFileSync instead of execSync.
  2. Update the body of retryFailedBuilds to use execFileSync with an array of args.

No other parts of the script need to change.

Suggested changeset 1
scripts/e2e-test-manager.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/scripts/e2e-test-manager.ts b/scripts/e2e-test-manager.ts
--- a/scripts/e2e-test-manager.ts
+++ b/scripts/e2e-test-manager.ts
@@ -16,7 +16,7 @@
 import { CloudWatchLogsClient, GetLogEventsCommand } from '@aws-sdk/client-cloudwatch-logs';
 import { fromIni } from '@aws-sdk/credential-providers';
 import * as process from 'process';
-import { execSync } from 'child_process';
+import { execFileSync } from 'child_process';
 
 const E2E_PROFILE_NAME = 'AmplifyE2EProd';
 const REGION = 'us-east-1';
@@ -125,10 +125,23 @@
   console.log(`Retrying ${failedBuildIds.length} failed builds using retry-build-batch`);
 
   try {
-    const result = execSync(`aws codebuild retry-build-batch --region=${REGION} --profile=${E2E_PROFILE_NAME} --id="${batchId}"`, {
-      encoding: 'utf8',
-      stdio: 'pipe',
-    });
+    const result = execFileSync(
+      'aws',
+      [
+        'codebuild',
+        'retry-build-batch',
+        '--region',
+        REGION,
+        '--profile',
+        E2E_PROFILE_NAME,
+        '--id',
+        batchId,
+      ],
+      {
+        encoding: 'utf8',
+        stdio: 'pipe',
+      },
+    );
 
     // Parse the result to get the new batch ID
     const output = JSON.parse(result);
EOF
@@ -16,7 +16,7 @@
import { CloudWatchLogsClient, GetLogEventsCommand } from '@aws-sdk/client-cloudwatch-logs';
import { fromIni } from '@aws-sdk/credential-providers';
import * as process from 'process';
import { execSync } from 'child_process';
import { execFileSync } from 'child_process';

const E2E_PROFILE_NAME = 'AmplifyE2EProd';
const REGION = 'us-east-1';
@@ -125,10 +125,23 @@
console.log(`Retrying ${failedBuildIds.length} failed builds using retry-build-batch`);

try {
const result = execSync(`aws codebuild retry-build-batch --region=${REGION} --profile=${E2E_PROFILE_NAME} --id="${batchId}"`, {
encoding: 'utf8',
stdio: 'pipe',
});
const result = execFileSync(
'aws',
[
'codebuild',
'retry-build-batch',
'--region',
REGION,
'--profile',
E2E_PROFILE_NAME,
'--id',
batchId,
],
{
encoding: 'utf8',
stdio: 'pipe',
},
);

// Parse the result to get the new batch ID
const output = JSON.parse(result);
Copilot is powered by AI and may make mistakes. Always verify output.
console.error('Error: batchId required for retry command');
process.exit(1);
}
const maxRetries = arg2 ? parseInt(arg2, 10) : DEFAULT_MAX_RETRIES;

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable maxRetries.

Copilot Autofix

AI about 2 months ago

In general, to fix an unused variable warning, either remove the variable (and any associated computation) if it truly isn’t needed, or refactor the code so that the variable is actually used as intended. Here, maxRetries is calculated from CLI input but not used; current behavior ignores the second argument to retry. To avoid changing behavior, the safest fix is to stop declaring maxRetries altogether and keep treating retry as a single-argument command.

Concretely, in scripts/e2e-test-manager.ts, within the case 'retry': block of the main function, remove the declaration of maxRetries on line 472. Do not change the call to retryFailedBuilds(arg1) or any other logic, so command behavior remains the same while the unused variable disappears.

No extra imports, methods, or definitions are needed.

Suggested changeset 1
scripts/e2e-test-manager.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/scripts/e2e-test-manager.ts b/scripts/e2e-test-manager.ts
--- a/scripts/e2e-test-manager.ts
+++ b/scripts/e2e-test-manager.ts
@@ -469,7 +469,6 @@
           console.error('Error: batchId required for retry command');
           process.exit(1);
         }
-        const maxRetries = arg2 ? parseInt(arg2, 10) : DEFAULT_MAX_RETRIES;
         const newBatchId = await retryFailedBuilds(arg1);
         console.log(`New batch started: ${newBatchId}`);
         break;
EOF
@@ -469,7 +469,6 @@
console.error('Error: batchId required for retry command');
process.exit(1);
}
const maxRetries = arg2 ? parseInt(arg2, 10) : DEFAULT_MAX_RETRIES;
const newBatchId = await retryFailedBuilds(arg1);
console.log(`New batch started: ${newBatchId}`);
break;
Copilot is powered by AI and may make mistakes. Always verify output.
- Remove automatic mwinit call that prompts for credentials
- Let ada command fail naturally if credentials not available
- Provide clear error message instructing user to run mwinit
- Matches pattern from amplify-category-api repo
- Change from CodebuildDeveloper (category-api) to CodeBuildE2E (cli-gen1)
- Matches role name used in cloud-cli-utils.sh
- Add blank lines between sections per prettier rules
- Fixes lint failure in e2e tests
- Allow specifying custom container image via CODEBUILD_IMAGE_OVERRIDE env var
- Matches pattern from amplify-category-api repo
- Enables testing with updated container images

Usage: CODEBUILD_IMAGE_OVERRIDE=<image-uri> yarn cloud-e2e
@svidgen svidgen marked this pull request as ready for review March 6, 2026 22:08
@svidgen svidgen requested a review from a team as a code owner March 6, 2026 22:08
@svidgen svidgen merged commit 7e73fd3 into dev Mar 12, 2026
6 checks passed
@svidgen svidgen deleted the wirej/agentic-stuff branch March 12, 2026 15:49
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.

3 participants