Skip to content

Commit ae695b4

Browse files
connect the flow (CopilotKit#943)
1 parent ec2c5ab commit ae695b4

12 files changed

Lines changed: 394 additions & 133 deletions

.github/workflows/e2e.yml

Lines changed: 64 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ on:
1212
urls:
1313
description: "urls"
1414
required: true
15-
15+
pr_number:
16+
description: "Pull Request number"
17+
required: true
1618
jobs:
1719
e2e_tests:
1820
name: E2E Tests
@@ -31,12 +33,23 @@ jobs:
3133
- name: Save E2E URLs
3234
working-directory: examples/e2e
3335
run: |
34-
echo "${{ inputs.urls }}" | base64 -d > urls.json
36+
echo "${{ inputs.urls }}" | base64 -d > app-configs.json
3537
36-
- name: Print E2E URLs
37-
working-directory: examples/e2e
38+
- name: Setup pnpm
39+
uses: pnpm/action-setup@v2
40+
with:
41+
version: 8
42+
43+
- name: Setup Node.js
44+
uses: actions/setup-node@v3
45+
with:
46+
node-version: "22"
47+
48+
- name: Install Dependencies
49+
working-directory: ./examples/e2e
3850
run: |
39-
cat urls.json
51+
pnpm install
52+
pnpm exec playwright install --with-deps
4053
4154
- name: Create Status Check
4255
uses: actions/github-script@v6
@@ -51,33 +64,50 @@ jobs:
5164
started_at: new Date().toISOString()
5265
})
5366
54-
# - name: Run Tests
55-
# id: run_tests
56-
# run: |
57-
# cat tests/.env.test
58-
# echo "Running E2E tests..."
59-
# # Your actual test commands here
67+
- name: Print app configs
68+
working-directory: examples/e2e
69+
run: |
70+
cat app-configs.json
71+
72+
- name: Run Tests
73+
id: run_tests
74+
working-directory: ./examples/e2e
75+
continue-on-error: true
76+
run: |
77+
pnpm playwright test
6078
61-
- name: Wait 1 minute
62-
run: sleep 60
63-
64-
# - name: Update Status Check
65-
# if: always()
66-
# uses: actions/github-script@v6
67-
# with:
68-
# script: |
69-
# const conclusion = '${{ steps.run_tests.outcome }}' === 'success' ? 'success' : 'failure';
70-
# await github.rest.checks.create({
71-
# owner: context.repo.owner,
72-
# repo: context.repo.repo,
73-
# name: 'E2E Tests',
74-
# head_sha: '${{ github.event.client_payload.sha }}',
75-
# status: 'completed',
76-
# conclusion: conclusion,
77-
# completed_at: new Date().toISOString(),
78-
# output: {
79-
# title: conclusion === 'success' ? 'E2E Tests Passed' : 'E2E Tests Failed',
80-
# summary: conclusion === 'success' ? 'All tests passed successfully' : 'Some tests failed'
81-
# }
82-
# });
83-
79+
- name: Comment post-deployment
80+
uses: thollander/actions-comment-pull-request@v3
81+
with:
82+
pr-number: ${{ inputs.pr_number }}
83+
comment-tag: test-run-status-update
84+
file-path: ./examples/e2e/test-results/test-run-comment.md
85+
86+
- uses: actions/upload-artifact@v4
87+
if: always()
88+
with:
89+
name: playwright-report
90+
path: |
91+
examples/e2e/playwright-report/
92+
examples/e2e/test-results/
93+
retention-days: 30
94+
95+
- name: Update Status Check
96+
if: always()
97+
uses: actions/github-script@v6
98+
with:
99+
script: |
100+
const conclusion = '${{ steps.run_tests.outcome }}' === 'success' ? 'success' : 'failure';
101+
await github.rest.checks.create({
102+
owner: context.repo.owner,
103+
repo: context.repo.repo,
104+
name: 'E2E Tests',
105+
head_sha: '${{ inputs.sha }}',
106+
status: 'completed',
107+
conclusion: conclusion,
108+
completed_at: new Date().toISOString(),
109+
output: {
110+
title: conclusion === 'success' ? 'E2E Tests Passed' : 'E2E Tests Failed',
111+
summary: conclusion === 'success' ? 'All tests passed successfully' : 'Some tests failed'
112+
}
113+
});

.github/workflows/preview-envs-deploy.yml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,28 @@ jobs:
1616
strategy:
1717
matrix:
1818
app:
19-
- { project: "coagents-research-canvas", type: "agent", deps: "remote-deps" }
20-
- { project: "coagents-research-canvas", type: "agent", deps: "local-deps" }
19+
- {
20+
project: "coagents-research-canvas",
21+
type: "agent",
22+
deps: "remote-deps",
23+
}
24+
- {
25+
project: "coagents-research-canvas",
26+
type: "agent",
27+
deps: "local-deps",
28+
}
2129
- { project: "coagents-research-canvas", type: "ui" }
2230
- { project: "coagents-routing", type: "agent", deps: "remote-deps" }
2331
- { project: "coagents-routing", type: "agent", deps: "local-deps" }
2432
- { project: "coagents-routing", type: "ui" }
2533
- { project: "coagents-qa-text", type: "agent", deps: "remote-deps" }
2634
- { project: "coagents-qa-text", type: "agent", deps: "local-deps" }
2735
- { project: "coagents-qa-text", type: "ui" }
28-
- { project: "coagents-qa-native", type: "agent", deps: "remote-deps" }
36+
- {
37+
project: "coagents-qa-native",
38+
type: "agent",
39+
deps: "remote-deps",
40+
}
2941
- { project: "coagents-qa-native", type: "agent", deps: "local-deps" }
3042
- { project: "coagents-qa-native", type: "ui" }
3143
steps:
@@ -51,7 +63,7 @@ jobs:
5163
- name: AWS ECR Login
5264
run: |
5365
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 058264219587.dkr.ecr.us-east-1.amazonaws.com
54-
66+
5567
- name: (UI) Setup pnpm
5668
if: matrix.app.type == 'ui'
5769
uses: pnpm/action-setup@v4
@@ -63,8 +75,8 @@ jobs:
6375
uses: actions/setup-node@v2
6476
with:
6577
node-version: 21.x
66-
cache: 'pnpm'
67-
cache-dependency-path: '**/pnpm-lock.yaml'
78+
cache: "pnpm"
79+
cache-dependency-path: "**/pnpm-lock.yaml"
6880

6981
- name: (UI) Install dependencies
7082
if: matrix.app.type == 'ui'
@@ -147,8 +159,8 @@ jobs:
147159
uses: actions/setup-node@v2
148160
with:
149161
node-version: 21.x
150-
cache: 'pnpm'
151-
cache-dependency-path: '**/pnpm-lock.yaml'
162+
cache: "pnpm"
163+
cache-dependency-path: "**/pnpm-lock.yaml"
152164

153165
- name: Infra install dependencies
154166
working-directory: infra
@@ -174,10 +186,10 @@ jobs:
174186
working-directory: ./infra
175187
run: cdk deploy --profile default --all --require-approval never --outputs-file=cdk_outputs.json --concurrency 10
176188
env:
177-
UNIQUE_ENV_ID: 'PR${{ github.event.number }}'
189+
UNIQUE_ENV_ID: "PR${{ github.event.number }}"
178190
GITHUB_ACTIONS_RUN_ID: "${{ github.run_id }}"
179191
GITHUB_PR_NUMBER: "${{ github.event.number }}"
180-
192+
181193
- name: Generate table from outputs
182194
id: generate-table
183195
working-directory: infra
@@ -207,11 +219,11 @@ jobs:
207219
working-directory: infra
208220
run: |
209221
echo "e2e-urls=$(node get-e2e-tests-urls.js | base64 -w 0)" >> "$GITHUB_OUTPUT"
210-
222+
211223
- name: Trigger E2E Tests
212224
uses: benc-uk/workflow-dispatch@v1
213225
with:
214226
token: ${{ secrets.GITHUB_TOKEN }}
215227
workflow: "e2e.yml"
216228
ref: "${{ github.event.pull_request.head.ref }}"
217-
inputs: '{"ref": "${{ github.event.pull_request.head.ref }}", "sha": "${{ github.event.pull_request.head.sha }}", "urls": "${{ steps.export-e2e-urls.outputs.e2e-urls }}"}'
229+
inputs: '{"ref": "${{ github.event.pull_request.head.ref }}", "sha": "${{ github.event.pull_request.head.sha }}", "urls": "${{ steps.export-e2e-urls.outputs.e2e-urls }}", "pr_number": "${{ github.event.pull_request.number }}"}'

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ __snapshots__
88
node_modules
99
.idea/
1010
cdk_outputs.json
11-
.turbo
11+
.turbo
12+
test-run-comment.md

examples/e2e/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules/
33
/playwright-report/
44
/blob-report/
55
/playwright/.cache/
6+
app-configs.json

examples/e2e/lib/config-helper.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// lib/config-helper.ts
2+
import configs from "../app-configs.json";
3+
4+
// Project name constants with type safety
5+
export const PROJECT_NAMES = {
6+
AI_RESEARCHER: "coagents-ai-researcher",
7+
QA_NATIVE: "coagents-qa-native",
8+
QA_TEXT: "coagents-qa-text",
9+
RESEARCH_CANVAS: "coagents-research-canvas",
10+
} as const;
11+
12+
export type ProjectName = (typeof PROJECT_NAMES)[keyof typeof PROJECT_NAMES];
13+
14+
export interface ConfigItem {
15+
url: string;
16+
description: string;
17+
projectName: ProjectName;
18+
}
19+
20+
export interface ConfigMap {
21+
[key: string]: ConfigItem;
22+
}
23+
24+
/**
25+
* Returns raw config map
26+
*/
27+
export const getConfigs = (): ConfigMap => {
28+
return configs as ConfigMap;
29+
};
30+
31+
/**
32+
* Groups configuration items by project name and description
33+
*/
34+
export const groupConfigsByDescription = (
35+
configs: ConfigMap
36+
): Record<ProjectName, Record<string, ConfigItem[]>> => {
37+
return Object.entries(configs).reduce((acc, [key, value]) => {
38+
const { projectName, description } = value;
39+
40+
if (!acc[projectName]) {
41+
acc[projectName] = {};
42+
}
43+
44+
if (!acc[projectName][description]) {
45+
acc[projectName][description] = [];
46+
}
47+
48+
acc[projectName][description].push({ ...value, key });
49+
50+
return acc;
51+
}, {} as Record<ProjectName, Record<string, ConfigItem[]>>);
52+
};
53+
54+
/**
55+
* Filter configs by project name
56+
*/
57+
export const filterConfigsByProject = (
58+
configs: ConfigMap,
59+
projectName: ProjectName
60+
): ConfigMap => {
61+
return Object.entries(configs).reduce((acc, [key, value]) => {
62+
if (value.projectName === projectName) {
63+
acc[key] = value;
64+
}
65+
return acc;
66+
}, {} as ConfigMap);
67+
};

examples/e2e/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"license": "ISC",
1818
"devDependencies": {
1919
"@playwright/test": "^1.48.2",
20-
"@types/node": "^22.8.4"
20+
"@types/node": "^22.8.4",
21+
"json2md": "^2.0.1"
2122
}
2223
}

examples/e2e/playwright.config.ts

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig, devices } from '@playwright/test';
1+
import { defineConfig, devices } from "@playwright/test";
22

33
/**
44
* Read environment variables from file.
@@ -12,8 +12,7 @@ import { defineConfig, devices } from '@playwright/test';
1212
* See https://playwright.dev/docs/test-configuration.
1313
*/
1414
export default defineConfig({
15-
timeout: 340000,
16-
testDir: './tests',
15+
testDir: "./tests",
1716
/* Run tests in files in parallel */
1817
fullyParallel: true,
1918
/* Fail the build on CI if you accidentally left test.only in the source code. */
@@ -23,52 +22,29 @@ export default defineConfig({
2322
/* Opt out of parallel tests on CI. */
2423
workers: process.env.CI ? 1 : undefined,
2524
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
26-
reporter: 'html',
25+
reporter: [
26+
[
27+
"./reporters/structured-reporter.ts",
28+
{
29+
outputFile: "test-results/test-run-comment.md",
30+
},
31+
],
32+
],
2733
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
2834
use: {
2935
/* Base URL to use in actions like `await page.goto('/')`. */
3036
// baseURL: 'http://127.0.0.1:3000',
3137

3238
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
33-
trace: 'on-first-retry',
39+
trace: "on-first-retry",
3440
},
3541

3642
/* Configure projects for major browsers */
3743
projects: [
3844
{
39-
name: 'chromium',
40-
use: { ...devices['Desktop Chrome'] },
45+
name: "chromium",
46+
use: { ...devices["Desktop Chrome"] },
4147
},
42-
43-
{
44-
name: 'firefox',
45-
use: { ...devices['Desktop Firefox'] },
46-
},
47-
48-
{
49-
name: 'webkit',
50-
use: { ...devices['Desktop Safari'] },
51-
},
52-
53-
/* Test against mobile viewports. */
54-
// {
55-
// name: 'Mobile Chrome',
56-
// use: { ...devices['Pixel 5'] },
57-
// },
58-
// {
59-
// name: 'Mobile Safari',
60-
// use: { ...devices['iPhone 12'] },
61-
// },
62-
63-
/* Test against branded browsers. */
64-
// {
65-
// name: 'Microsoft Edge',
66-
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
67-
// },
68-
// {
69-
// name: 'Google Chrome',
70-
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
71-
// },
7248
],
7349

7450
/* Run your local dev server before starting the tests */

0 commit comments

Comments
 (0)