Skip to content

Commit

Permalink
ci: setup github action
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas2D committed Aug 28, 2024
1 parent 6386ad6 commit dba7ad7
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 2 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
timeout-minutes: 20
name: Lint & Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Enable Corepack
run: corepack enable
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "yarn"
- name: Install dependencies
run: yarn install --immutable
- name: Code Lint
run: yarn lint
- name: Commits Lint
run: yarn commitlint --verbose --from "${{ github.event.pull_request.base.sha || github.event.commits[0].id }}" --to "${{ github.event.pull_request.head.sha || github.event.head_commit.id }}"
- name: Build
run: yarn build

test:
name: Tests
timeout-minutes: 20
needs:
- lint
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install dependencies
run: yarn install --immutable
- name: Unit Tests
run: yarn test:unit
- name: E2E Tests
env:
GENAI_API_KEY: ${{ secrets.GENAI_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
# TODO: enable WatsonX later
# WATSONX_API_KEY: ${{ secrets.WATSONX_API_KEY }}
# WATSONX_PROJECT_ID: ${{ secrets.WATSONX_PROJECT_ID }}
# WATSONX_SPACE_ID: ${{ secrets.WATSONX_SPACE_ID }}
# WATSONX_DEPLOYMENT_ID: ${{ secrets.WATSONX_DEPLOYMENT_ID }}
run: yarn test:e2e
5 changes: 5 additions & 0 deletions commitlint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import type { UserConfig } from "@commitlint/types";

const Configuration: UserConfig = {
extends: ["@commitlint/config-conventional"],
ignores: [
function ignoreDependabot(commit: string) {
return commit.includes("<[email protected]>") && commit.includes("dependabot");
},
],
};

export default Configuration;
9 changes: 9 additions & 0 deletions src/adapters/langchain/llms/llm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,17 @@ import { verifyDeserialization } from "@tests/e2e/utils.js";
import { LangChainLLM } from "@/adapters/langchain/llms/llm.js";
import { GenAIModel } from "@ibm-generative-ai/node-sdk/langchain";
import { Client } from "@ibm-generative-ai/node-sdk";
import { afterAll, beforeAll, vi } from "vitest";

describe("Langchain LLM", () => {
beforeAll(() => {
vi.stubEnv("GENAI_API_KEY", "123");
});

afterAll(() => {
vi.unstubAllEnvs();
});

const getInstance = () => {
return new LangChainLLM(
new GenAIModel({
Expand Down
1 change: 1 addition & 0 deletions src/memory/tokenMemory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe("Token Memory", () => {
};

it("Serializes", async () => {
vi.stubEnv("GENAI_API_KEY", "123");
const instance = getInstance();
await instance.add(
BaseMessage.of({
Expand Down
4 changes: 3 additions & 1 deletion src/serializer/serializer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as R from "remeda";
import { FrameworkError } from "@/errors.js";
import { AgentError } from "@/agents/base.js";
import { BaseMessage } from "@/llms/primitives/message.js";
import { beforeEach, expect } from "vitest";
import { beforeEach, expect, vi } from "vitest";
import { verifyDeserialization } from "@tests/e2e/utils.js";
import { BAMLLM } from "@/adapters/bam/llm.js";
import { BAMChatLLM } from "@/adapters/bam/chat.js";
Expand Down Expand Up @@ -231,6 +231,7 @@ describe("Serializer", () => {
});

beforeEach(() => {
vi.unstubAllEnvs();
Serializer.deregister(BaseMessage);
});

Expand Down Expand Up @@ -264,6 +265,7 @@ describe("Serializer", () => {
});

it("Handles nested functions", () => {
vi.stubEnv("GENAI_API_KEY", "123");
const { data } = JSON.parse(
`{"kind":"token","data":"{\\"__version\\":\\"0.0.35\\",\\"__root\\":{\\"__serializer\\":true,\\"__class\\":\\"Object\\",\\"__ref\\":\\"18\\",\\"__value\\":{\\"tokensUsed\\":{\\"__serializer\\":true,\\"__class\\":\\"Number\\",\\"__ref\\":\\"19\\",\\"__value\\":\\"66\\"},\\"config\\":{\\"__serializer\\":true,\\"__class\\":\\"Object\\",\\"__ref\\":\\"9\\",\\"__value\\":{\\"maxTokens\\":{\\"__serializer\\":true,\\"__class\\":\\"Number\\",\\"__ref\\":\\"10\\",\\"__value\\":\\"7000\\"},\\"llm\\":{\\"__serializer\\":true,\\"__class\\":\\"BAMChatLLM\\",\\"__ref\\":\\"3\\",\\"__value\\":{\\"llm\\":{\\"__serializer\\":true,\\"__class\\":\\"BAMLLM\\",\\"__ref\\":\\"4\\",\\"__value\\":{\\"modelId\\":\\"qwen/qwen2-72b-instruct\\",\\"parameters\\":{\\"__serializer\\":true,\\"__class\\":\\"Object\\",\\"__ref\\":\\"5\\",\\"__value\\":{}},\\"executionOptions\\":{\\"__serializer\\":true,\\"__class\\":\\"Object\\",\\"__ref\\":\\"6\\",\\"__value\\":{}}}},\\"config\\":{\\"__serializer\\":true,\\"__class\\":\\"Object\\",\\"__ref\\":\\"7\\",\\"__value\\":{\\"messagesToPrompt\\":{\\"__serializer\\":true,\\"__class\\":\\"Function\\",\\"__ref\\":\\"8\\",\\"__value\\":{\\"name\\":\\"messagesToPrompt\\",\\"fn\\":\\"messagesToPrompt(messages){return llamaTemplate.render({messages:messages.map(message=>({system:message.role===\\\\\\"system\\\\\\"?[message.text]:[],user:message.role===\\\\\\"user\\\\\\"?[message.text]:[],assistant:message.role===\\\\\\"assistant\\\\\\"?[message.text]:[]}))})}\\"}}}}}}}},\\"messages\\":{\\"__serializer\\":true,\\"__class\\":\\"Array\\",\\"__ref\\":\\"11\\",\\"__value\\":[{\\"__serializer\\":true,\\"__class\\":\\"BaseMessage\\",\\"__ref\\":\\"12\\",\\"__value\\":{\\"role\\":\\"user\\",\\"text\\":\\"My name is Tom, what is my name?\\",\\"meta\\":{\\"__serializer\\":true,\\"__class\\":\\"Undefined\\",\\"__ref\\":\\"13\\"}}},{\\"__serializer\\":true,\\"__class\\":\\"BaseMessage\\",\\"__ref\\":\\"14\\",\\"__value\\":{\\"role\\":\\"assistant\\",\\"text\\":\\"Your name is Tom.\\",\\"meta\\":{\\"__serializer\\":true,\\"__class\\":\\"Undefined\\",\\"__ref\\":\\"15\\"}}},{\\"__serializer\\":true,\\"__class\\":\\"BaseMessage\\",\\"__ref\\":\\"16\\",\\"__value\\":{\\"role\\":\\"user\\",\\"text\\":\\"My name is Tom, what is my name?\\",\\"meta\\":{\\"__serializer\\":true,\\"__class\\":\\"Undefined\\",\\"__ref\\":\\"17\\"}}},{\\"__serializer\\":true,\\"__class\\":\\"BaseMessage\\",\\"__ref\\":\\"14\\",\\"__value\\":\\"__ref\\"}]}}}}"}`,
);
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/agents/bee.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe("Bee Agent", () => {
{ prompt: "Who is the president of Czech Republic?" },
{
execution: {
maxIterations: 3,
maxIterations: 5,
totalMaxRetries: 5,
},
},
Expand Down

0 comments on commit dba7ad7

Please sign in to comment.