Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Closes #

How have you tested the change?

- [ ] I ran `npm run test:all`
- [ ] I ran `npm run test:unit` and `npm run test:integ`
- [ ] I ran `npm run typecheck`
- [ ] I ran `npm run lint`
- [ ] If I modified `src/assets/`, I ran `npm run test:update-snapshots` and committed the updated snapshots
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: E2E Tests
on:
workflow_dispatch:
inputs:
aws_region:
description: 'AWS region for deployment'
default: 'us-east-1'

permissions:
id-token: write # OIDC — lets GitHub assume an AWS IAM role via short-lived token (no stored keys)
contents: read

jobs:
e2e:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '20.x'
cache: 'npm'
- name: Configure git
run: |
git config --global user.email "ci@amazon.com"
git config --global user.name "CI"
- uses: astral-sh/setup-uv@v5
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.E2E_AWS_ROLE_ARN }}
aws-region: ${{ inputs.aws_region }}
- name: Get AWS Account ID
id: aws
run: echo "account_id=$(aws sts get-caller-identity --query Account --output text)" >> "$GITHUB_OUTPUT"
- run: npm ci
- run: npm run build
- name: Run E2E tests
env:
AWS_ACCOUNT_ID: ${{ steps.aws.outputs.account_id }}
AWS_REGION: ${{ inputs.aws_region }}
run: npm run test:e2e
112 changes: 112 additions & 0 deletions e2e-tests/create-deploy-invoke.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import { hasAwsCredentials, parseJsonOutput, prereqs, runCLI } from '../src/test-utils/index.js';
import { execSync } from 'node:child_process';
import { randomUUID } from 'node:crypto';
import { mkdir, rm, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';

const hasAws = hasAwsCredentials();
const canRun = prereqs.npm && prereqs.git && prereqs.uv && hasAws;

describe.sequential('e2e: create → deploy → invoke', () => {
let testDir: string;
let projectPath: string;
let agentName: string;

beforeAll(async () => {
if (!canRun) return;

testDir = join(tmpdir(), `agentcore-e2e-${randomUUID()}`);
await mkdir(testDir, { recursive: true });

agentName = `E2e${Date.now()}`;
const result = await runCLI(
[
'create',
'--name',
agentName,
'--language',
'Python',
'--framework',
'Strands',
'--model-provider',
'Bedrock',
'--memory',
'none',
'--json',
],
testDir,
false
);

expect(result.exitCode, `Create failed: ${result.stderr}`).toBe(0);
const json = parseJsonOutput(result.stdout) as { projectPath: string };
projectPath = json.projectPath;

// TODO: Replace with `agentcore add target` once the CLI command is re-introduced
const account =
process.env.AWS_ACCOUNT_ID ||
execSync('aws sts get-caller-identity --query Account --output text').toString().trim();
const region = process.env.AWS_REGION || 'us-east-1';
const awsTargetsPath = join(projectPath, 'agentcore', 'aws-targets.json');
await writeFile(awsTargetsPath, JSON.stringify([{ name: 'default', account, region }]));
}, 120000);

afterAll(async () => {
if (projectPath && hasAws) {
await runCLI(['remove', 'all', '--json'], projectPath, false);
const result = await runCLI(['deploy', '--yes', '--json'], projectPath, false);

if (result.exitCode !== 0) {
console.log('Teardown stdout:', result.stdout);
console.log('Teardown stderr:', result.stderr);
}
}
if (testDir) await rm(testDir, { recursive: true, force: true });
}, 600000);

it.skipIf(!canRun)(
'deploys to AWS successfully',
async () => {
expect(projectPath, 'Project should have been created').toBeTruthy();

const result = await runCLI(['deploy', '--yes', '--json'], projectPath, false);

if (result.exitCode !== 0) {
console.log('Deploy stdout:', result.stdout);
console.log('Deploy stderr:', result.stderr);
}

expect(result.exitCode, `Deploy failed: ${result.stderr}`).toBe(0);

const json = parseJsonOutput(result.stdout) as { success: boolean };
expect(json.success, 'Deploy should report success').toBe(true);
},
300000
);

it.skipIf(!canRun)(
'invokes the deployed agent',
async () => {
expect(projectPath, 'Project should have been created').toBeTruthy();

const result = await runCLI(
['invoke', '--prompt', 'Say hello', '--agent', agentName, '--json'],
projectPath,
false
);

if (result.exitCode !== 0) {
console.log('Invoke stdout:', result.stdout);
console.log('Invoke stderr:', result.stderr);
}

expect(result.exitCode, `Invoke failed: ${result.stderr}`).toBe(0);

const json = parseJsonOutput(result.stdout) as { success: boolean };
expect(json.success, 'Invoke should report success').toBe(true);
},
120000
);
});
121 changes: 0 additions & 121 deletions integ-tests/deploy.test.ts

This file was deleted.

84 changes: 0 additions & 84 deletions integ-tests/invoke-agent.test.ts

This file was deleted.

Loading
Loading