Skip to content

Commit c25566e

Browse files
authored
Enhance testing utility, add CI gh action and format files (#13)
* Enhance testing utilities and options for PromptWithTests - Introduced internal testing utilities in `testHelpers.ts` for mock executor configurations and running tests with mock executors. - Updated `PromptWithTests` to allow default empty executor configurations and added convenience handling for single executor parameters. - Modified test cases to utilize the new testing utilities, improving flexibility in test execution. - Updated related types to support new executor options in test configurations. * Add CI workflow configuration for testing and linting * Update package manager to pnpm@9.0.0 in package.json and CI workflow configuration * Remove pnpm version specification from CI workflow configuration * Refactor code for improved type safety and clarity - Updated `basic-usage.ts` to access `systemPrompt` directly instead of using bracket notation. - Enhanced type definitions in `VercelAIExecutor.ts` for better clarity on tool descriptions. - Improved type handling in `zodToJsonSchema.ts` by specifying more precise types for schema definitions and results. - Adjusted `analytics.test.ts` to use more explicit types for instance management and circular reference handling. * Reformated multiple files - Reformatted `package.json` files for improved readability and consistency in indentation. - Updated example files to ensure consistent formatting and removed unnecessary newlines. - Enhanced code clarity in `basic-usage.ts`, `tool-integration.ts`, and other example files by standardizing console log statements. - Cleaned up trailing whitespace in various files to maintain code quality.
1 parent 1ad81af commit c25566e

36 files changed

+654
-422
lines changed

.github/workflows/ci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- '**'
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
test:
13+
name: Test & Lint
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 20
24+
25+
- name: Setup pnpm
26+
uses: pnpm/action-setup@v4
27+
28+
- name: Get pnpm store directory
29+
shell: bash
30+
run: |
31+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
32+
33+
- name: Setup pnpm cache
34+
uses: actions/cache@v4
35+
with:
36+
path: ${{ env.STORE_PATH }}
37+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
38+
restore-keys: |
39+
${{ runner.os }}-pnpm-store-
40+
41+
- name: Install dependencies
42+
run: pnpm install --frozen-lockfile
43+
44+
- name: Run linting
45+
run: pnpm run lint
46+
47+
- name: Check formatting
48+
run: pnpm run format:check
49+
50+
- name: Build packages
51+
run: pnpm run build
52+
53+
- name: Run tests
54+
run: pnpm run test
55+

examples/basic-usage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const p = prompt("You are a helpful customer service agent")
77

88
// Compile for different providers
99
console.log("=== Generic Format ===");
10-
console.log(p["systemPrompt"]);
10+
console.log(p.systemPrompt);
1111

1212
console.log("\n=== OpenAI Format ===");
1313
const openaiResult = p.toOpenAI();
@@ -26,4 +26,4 @@ const conversationMessages = [
2626

2727
const messagesWithSystem = p.toVercelAI(conversationMessages);
2828
console.log("\n=== Prepared Messages ===");
29-
console.log(JSON.stringify(messagesWithSystem, null, 2));
29+
console.log(JSON.stringify(messagesWithSystem, null, 2));

examples/eval-example.prompt.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,3 @@ export const emailWriter = prompt(
103103
},
104104
],
105105
});
106-

examples/tool-integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ console.log(' model: "gpt-4",');
7070
console.log(" messages: openaiResult.messages,");
7171
console.log(" tools: openaiResult.tools,");
7272
console.log(' tool_choice: "auto"');
73-
console.log("});");
73+
console.log("});");

examples/vercel-integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ export async function POSTAnthropic(req: Request) {
9090
console.error("Chat API error:", error);
9191
return new Response("Internal Server Error", { status: 500 });
9292
}
93-
}
93+
}

package.json

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
{
2-
"name": "marrakesh",
3-
"private": true,
4-
"version": "0.1.0-alpha.2",
5-
"description": "A structured, testable, and data-driven context engineering SDK",
6-
"license": "Apache-2.0",
7-
"scripts": {
8-
"build": "turbo build",
9-
"dev": "turbo dev",
10-
"test": "turbo test",
11-
"lint": "biome lint .",
12-
"format": "biome format --write .",
13-
"format:check": "biome format .",
14-
"clean": "turbo clean"
15-
},
16-
"devDependencies": {
17-
"turbo": "^2.0.0",
18-
"typescript": "^5.0.0",
19-
"tsup": "^8.0.0",
20-
"vitest": "^1.0.0",
21-
"@types/node": "^20.0.0",
22-
"@biomejs/biome": "^1.8.0"
23-
},
24-
"packageManager": "pnpm@8.0.0",
25-
"engines": {
26-
"node": ">=18.0.0"
27-
}
28-
}
2+
"name": "marrakesh",
3+
"private": true,
4+
"version": "0.1.0-alpha.2",
5+
"description": "A structured, testable, and data-driven context engineering SDK",
6+
"license": "Apache-2.0",
7+
"scripts": {
8+
"build": "turbo build",
9+
"dev": "turbo dev",
10+
"test": "turbo test",
11+
"lint": "biome lint .",
12+
"format": "biome format --write .",
13+
"format:check": "biome format .",
14+
"clean": "turbo clean"
15+
},
16+
"devDependencies": {
17+
"turbo": "^2.0.0",
18+
"typescript": "^5.0.0",
19+
"tsup": "^8.0.0",
20+
"vitest": "^1.0.0",
21+
"@types/node": "^20.0.0",
22+
"@biomejs/biome": "^1.8.0"
23+
},
24+
"packageManager": "pnpm@9.0.0",
25+
"engines": {
26+
"node": ">=18.0.0"
27+
}
28+
}

packages/cli/package.json

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "@marrakesh/cli",
3-
"version": "0.1.0-alpha.2",
4-
"description": "CLI for testing Marrakesh prompts",
5-
"license": "Apache-2.0",
2+
"name": "@marrakesh/cli",
3+
"version": "0.1.0-alpha.2",
4+
"description": "CLI for testing Marrakesh prompts",
5+
"license": "Apache-2.0",
66
"type": "module",
77
"bin": {
88
"marrakesh": "./dist/index.js"
@@ -15,10 +15,7 @@
1515
"import": "./dist/index.js"
1616
}
1717
},
18-
"files": [
19-
"dist",
20-
"README.md"
21-
],
18+
"files": ["dist", "README.md"],
2219
"scripts": {
2320
"build": "tsup",
2421
"dev": "tsup --watch",
@@ -41,4 +38,3 @@
4138
"@types/node": "^20.0.0"
4239
}
4340
}
44-

packages/cli/src/commands/test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,3 @@ export const testCommand = new Command("test")
9090
process.exit(1);
9191
}
9292
});
93-

packages/cli/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ program
3333
program.addCommand(testCommand);
3434

3535
program.parse();
36-

packages/cli/src/output/Reporter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,3 @@ export class Reporter {
308308
console.log(); // blank line
309309
}
310310
}
311-

0 commit comments

Comments
 (0)