Skip to content

Commit b982e7a

Browse files
ci: use only one e2e test
1 parent 471aca2 commit b982e7a

File tree

3 files changed

+115
-162
lines changed

3 files changed

+115
-162
lines changed

.github/workflows/e2e.yml

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -75,65 +75,3 @@ jobs:
7575
name: playwright-report
7676
path: ./playwright-report/
7777
retention-days: 30
78-
79-
resolve-python-dependencies:
80-
name: Resolve Python Dependencies
81-
timeout-minutes: 60
82-
strategy:
83-
fail-fast: true
84-
matrix:
85-
os: [ubuntu-22.04]
86-
defaults:
87-
run:
88-
shell: bash
89-
runs-on: ${{ matrix.os }}
90-
steps:
91-
- uses: actions/checkout@v4
92-
93-
# poetry lock will resolve for all supported python versions, don't need to add matrix
94-
- name: Set up python 3.11
95-
uses: actions/setup-python@v5
96-
with:
97-
python-version: "3.11"
98-
99-
- name: Install Poetry
100-
uses: snok/install-poetry@v1
101-
with:
102-
version: ${{ env.POETRY_VERSION }}
103-
104-
- uses: pnpm/action-setup@v3
105-
106-
- name: Setup Node.js
107-
uses: actions/setup-node@v4
108-
with:
109-
node-version: 18
110-
cache: "pnpm"
111-
112-
- name: Install dependencies
113-
run: pnpm install
114-
115-
- name: Install Playwright Browsers
116-
run: pnpm exec playwright install --with-deps
117-
working-directory: .
118-
119-
- name: Build create-llama
120-
run: pnpm run build
121-
working-directory: .
122-
123-
- name: Install
124-
run: pnpm run pack-install
125-
working-directory: .
126-
127-
- name: Run Python Dependencies Test
128-
run: pnpm exec playwright test e2e/resolve_python_dependencies.spec.ts
129-
env:
130-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
131-
LLAMA_CLOUD_API_KEY: ${{ secrets.LLAMA_CLOUD_API_KEY }}
132-
working-directory: .
133-
134-
- uses: actions/upload-artifact@v3
135-
if: always()
136-
with:
137-
name: playwright-report-python-dependencies
138-
path: ./playwright-report/
139-
retention-days: 30

e2e/resolve_python_dependencies.spec.ts

Lines changed: 114 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -3,121 +3,137 @@ import { exec } from "child_process";
33
import fs from "fs";
44
import path from "path";
55
import util from "util";
6-
import { TemplateVectorDB } from "../helpers/types";
6+
import { TemplateFramework, TemplateVectorDB } from "../helpers/types";
77
import { createTestDir, runCreateLlama } from "./utils";
88

99
const execAsync = util.promisify(exec);
1010

11-
const vectorDbs: TemplateVectorDB[] = [
12-
"mongo",
13-
"pg",
14-
"pinecone",
15-
"milvus",
16-
"astra",
17-
"qdrant",
18-
"chroma",
19-
"weaviate",
20-
];
11+
const templateFramework: TemplateFramework = process.env.FRAMEWORK
12+
? (process.env.FRAMEWORK as TemplateFramework)
13+
: "fastapi";
14+
const dataSource: string = process.env.DATASOURCE
15+
? process.env.DATASOURCE
16+
: "--example-file";
2117

22-
const toolOptions = [
23-
"wikipedia.WikipediaToolSpec",
24-
"google.GoogleSearchToolSpec",
25-
];
18+
if (
19+
templateFramework == "fastapi" && // test is only relevant for fastapi
20+
process.version.startsWith("v20.") && // XXX: Only run for Node.js version 20 (CI matrix will trigger other versions)
21+
dataSource === "--example-file" // XXX: this test provides its own data source - only trigger it on one data source (usually the CI matrix will trigger multiple data sources)
22+
) {
23+
// vectorDBs, tools, and data source combinations to test
24+
const vectorDbs: TemplateVectorDB[] = [
25+
"mongo",
26+
"pg",
27+
"pinecone",
28+
"milvus",
29+
"astra",
30+
"qdrant",
31+
"chroma",
32+
"weaviate",
33+
];
2634

27-
const dataSources = [
28-
"--example-file",
29-
"--web-source https://www.example.com",
30-
"--db-source mysql+pymysql://user:pass@localhost:3306/mydb",
31-
];
35+
const toolOptions = [
36+
"wikipedia.WikipediaToolSpec",
37+
"google.GoogleSearchToolSpec",
38+
];
3239

33-
test.describe("Test resolve python dependencies", () => {
34-
for (const vectorDb of vectorDbs) {
35-
for (const tool of toolOptions) {
36-
for (const dataSource of dataSources) {
37-
const dataSourceType = dataSource.split(" ")[0];
38-
const optionDescription = `vectorDb: ${vectorDb}, tools: ${tool}, dataSource: ${dataSourceType}`;
40+
const dataSources = [
41+
"--example-file",
42+
"--web-source https://www.example.com",
43+
"--db-source mysql+pymysql://user:pass@localhost:3306/mydb",
44+
];
3945

40-
test(`options: ${optionDescription}`, async () => {
41-
const cwd = await createTestDir();
46+
test.describe("Test resolve python dependencies", () => {
47+
for (const vectorDb of vectorDbs) {
48+
for (const tool of toolOptions) {
49+
for (const dataSource of dataSources) {
50+
const dataSourceType = dataSource.split(" ")[0];
51+
const optionDescription = `vectorDb: ${vectorDb}, tools: ${tool}, dataSource: ${dataSourceType}`;
4252

43-
const result = await runCreateLlama(
44-
cwd,
45-
"streaming",
46-
"fastapi",
47-
dataSource,
48-
vectorDb,
49-
3000, // port
50-
8000, // externalPort
51-
"none", // postInstallAction
52-
undefined, // ui
53-
"--no-frontend", // appType
54-
undefined, // llamaCloudProjectName
55-
undefined, // llamaCloudIndexName
56-
tool,
57-
);
58-
const name = result.projectName;
53+
test(`options: ${optionDescription}`, async () => {
54+
const cwd = await createTestDir();
5955

60-
// Check if the app folder exists
61-
const dirExists = fs.existsSync(path.join(cwd, name));
62-
expect(dirExists).toBeTruthy();
63-
64-
// Check if pyproject.toml exists
65-
const pyprojectPath = path.join(cwd, name, "pyproject.toml");
66-
const pyprojectExists = fs.existsSync(pyprojectPath);
67-
expect(pyprojectExists).toBeTruthy();
68-
69-
// Run poetry lock
70-
try {
71-
const { stdout, stderr } = await execAsync(
72-
"poetry config virtualenvs.in-project true && poetry lock --no-update",
73-
{
74-
cwd: path.join(cwd, name),
75-
},
56+
const result = await runCreateLlama(
57+
cwd,
58+
"streaming",
59+
"fastapi",
60+
dataSource,
61+
vectorDb,
62+
3000, // port
63+
8000, // externalPort
64+
"none", // postInstallAction
65+
undefined, // ui
66+
"--no-frontend", // appType
67+
undefined, // llamaCloudProjectName
68+
undefined, // llamaCloudIndexName
69+
tool,
7670
);
77-
console.log("poetry lock stdout:", stdout);
78-
console.error("poetry lock stderr:", stderr);
79-
} catch (error) {
80-
console.error("Error running poetry lock:", error);
81-
throw error;
82-
}
71+
const name = result.projectName;
8372

84-
// Check if poetry.lock file was created
85-
const poetryLockExists = fs.existsSync(
86-
path.join(cwd, name, "poetry.lock"),
87-
);
88-
expect(poetryLockExists).toBeTruthy();
73+
// Check if the app folder exists
74+
const dirExists = fs.existsSync(path.join(cwd, name));
75+
expect(dirExists).toBeTruthy();
8976

90-
// Verify that specific dependencies are in pyproject.toml
91-
const pyprojectContent = fs.readFileSync(pyprojectPath, "utf-8");
92-
if (vectorDb !== "none") {
93-
if (vectorDb === "pg") {
94-
expect(pyprojectContent).toContain(
95-
"llama-index-vector-stores-postgres",
96-
);
97-
} else {
98-
expect(pyprojectContent).toContain(
99-
`llama-index-vector-stores-${vectorDb}`,
77+
// Check if pyproject.toml exists
78+
const pyprojectPath = path.join(cwd, name, "pyproject.toml");
79+
const pyprojectExists = fs.existsSync(pyprojectPath);
80+
expect(pyprojectExists).toBeTruthy();
81+
82+
// Run poetry lock
83+
try {
84+
const { stdout, stderr } = await execAsync(
85+
"poetry config virtualenvs.in-project true && poetry lock --no-update",
86+
{
87+
cwd: path.join(cwd, name),
88+
},
10089
);
90+
console.log("poetry lock stdout:", stdout);
91+
console.error("poetry lock stderr:", stderr);
92+
} catch (error) {
93+
console.error("Error running poetry lock:", error);
94+
throw error;
10195
}
102-
}
103-
if (tool !== "none") {
104-
if (tool === "wikipedia.WikipediaToolSpec") {
105-
expect(pyprojectContent).toContain("wikipedia");
96+
97+
// Check if poetry.lock file was created
98+
const poetryLockExists = fs.existsSync(
99+
path.join(cwd, name, "poetry.lock"),
100+
);
101+
expect(poetryLockExists).toBeTruthy();
102+
103+
// Verify that specific dependencies are in pyproject.toml
104+
const pyprojectContent = fs.readFileSync(pyprojectPath, "utf-8");
105+
if (vectorDb !== "none") {
106+
if (vectorDb === "pg") {
107+
expect(pyprojectContent).toContain(
108+
"llama-index-vector-stores-postgres",
109+
);
110+
} else {
111+
expect(pyprojectContent).toContain(
112+
`llama-index-vector-stores-${vectorDb}`,
113+
);
114+
}
106115
}
107-
if (tool === "google.GoogleSearchToolSpec") {
108-
expect(pyprojectContent).toContain("google");
116+
if (tool !== "none") {
117+
if (tool === "wikipedia.WikipediaToolSpec") {
118+
expect(pyprojectContent).toContain("wikipedia");
119+
}
120+
if (tool === "google.GoogleSearchToolSpec") {
121+
expect(pyprojectContent).toContain("google");
122+
}
109123
}
110-
}
111124

112-
// Check for data source specific dependencies
113-
if (dataSource.includes("--web-source")) {
114-
expect(pyprojectContent).toContain("llama-index-readers-web");
115-
}
116-
if (dataSource.includes("--db-source")) {
117-
expect(pyprojectContent).toContain("llama-index-readers-database ");
118-
}
119-
});
125+
// Check for data source specific dependencies
126+
if (dataSource.includes("--web-source")) {
127+
expect(pyprojectContent).toContain("llama-index-readers-web");
128+
}
129+
if (dataSource.includes("--db-source")) {
130+
expect(pyprojectContent).toContain(
131+
"llama-index-readers-database ",
132+
);
133+
}
134+
});
135+
}
120136
}
121137
}
122-
}
123-
});
138+
});
139+
}

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
"build:ncc": "pnpm run clean && ncc build ./index.ts -o ./dist/ --minify --no-cache --no-source-map-register",
2525
"clean": "rimraf --glob ./dist ./templates/**/__pycache__ ./templates/**/node_modules ./templates/**/poetry.lock",
2626
"dev": "ncc build ./index.ts -w -o dist/",
27-
"e2e": "playwright test --grep-invert 'resolve_python_dependencies'",
28-
"e2e:python-deps": "playwright test --grep 'resolve_python_dependencies'",
27+
"e2e": "playwright test",
2928
"format": "prettier --ignore-unknown --cache --check .",
3029
"format:write": "prettier --ignore-unknown --write .",
3130
"lint": "eslint . --ignore-pattern dist --ignore-pattern e2e/cache",

0 commit comments

Comments
 (0)