Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
4bd62c6
core: add ancient ci, trunk-check and a test ci
ijusttookadnatest Apr 24, 2025
0f196b4
fix: test.yml workflow_dispatch trigger event
ijusttookadnatest Apr 24, 2025
75bf2e3
core: update ci with new config files
ijusttookadnatest Apr 24, 2025
6270a7b
chore: clean up trunk files
ijusttookadnatest Apr 24, 2025
e026359
fix: trunk format
ijusttookadnatest Apr 24, 2025
819a8c2
fix: unit test
ijusttookadnatest Apr 25, 2025
210cc5e
testdocquality available and add basic integration test ci
ijusttookadnatest Apr 28, 2025
0b77663
fix: name script test
ijusttookadnatest Apr 28, 2025
5f2e516
fix: name script test
ijusttookadnatest Apr 28, 2025
bd20a58
fix: remove useless s added in types/index
ijusttookadnatest Apr 28, 2025
cb00a02
test: ci
ijusttookadnatest Apr 30, 2025
e526770
fix: name of secrets ci
ijusttookadnatest Apr 30, 2025
f3f8c0d
fix: ci
ijusttookadnatest Apr 30, 2025
ca16de8
fix: env ci
ijusttookadnatest Apr 30, 2025
1adab80
fix: setup pnpm cache
ijusttookadnatest Apr 30, 2025
f39839c
Merge branch 'main' into ci/update
ijusttookadnatest May 1, 2025
23186b9
core: add ingester, snak import and generation code test logic in ci,…
ijusttookadnatest May 1, 2025
ecebf14
fix: remove langsmith
ijusttookadnatest May 1, 2025
e9dcc67
fix: remove backend/test/compilation.test.ts from unit testing
ijusttookadnatest May 2, 2025
c68d1c6
feat: add snak test in addition of snak server launching to ci, impro…
ijusttookadnatest May 5, 2025
87e177d
fix: better handle env parameters for snak test file
ijusttookadnatest May 5, 2025
524df2e
fix: fix import ingester
ijusttookadnatest May 5, 2025
e67808b
debug: debugging package export issue for ingester unit test
ijusttookadnatest May 5, 2025
5e01ec4
fix: modify tsconfig to remove wrong file that would make build of ba…
ijusttookadnatest May 5, 2025
b748085
fix: remove useless .js in code quality repo
ijusttookadnatest May 5, 2025
9632f5d
fix: make snak.test return true to test whole ci, remove .env.test
ijusttookadnatest May 5, 2025
f5e3759
feat: improve error displaying when snak test failures
ijusttookadnatest May 6, 2025
a68f3ea
debug: server connection to test-snak
ijusttookadnatest May 6, 2025
d32b660
debug: add test basic API connectivity and fix api key in first conne…
ijusttookadnatest May 6, 2025
6fcfae7
fix: ai provder api key in snak env
ijusttookadnatest May 6, 2025
bf3a5f1
fix: add scarb installation request before tests in snak-test, remove…
ijusttookadnatest May 6, 2025
c77f7d3
trunked
ijusttookadnatest May 6, 2025
78f7bf5
unable all tests of snak-test
ijusttookadnatest May 6, 2025
43d0f28
fix: remove snak server checker to avoid security issue
ijusttookadnatest May 6, 2025
23811b8
Merge branch 'main' into ci/update
ijusttookadnatest May 6, 2025
a805a10
fix: remove unnecessary logs from script test
ijusttookadnatest May 6, 2025
d6cfe01
fix: name model in ingester ci
ijusttookadnatest May 6, 2025
e4a5a77
remove unusued comment
ijusttookadnatest May 7, 2025
a72adcc
fix: add backend env file
ijusttookadnatest May 7, 2025
f7a1f15
feat: add image build workflow
ijusttookadnatest May 8, 2025
9e4305c
fix: add push event test-build workflow
ijusttookadnatest May 8, 2025
bee9c9f
fix: workflow_dispatch fix
ijusttookadnatest May 8, 2025
853b09d
fix: remove config file from image push
ijusttookadnatest May 8, 2025
3703090
feat: add ingester image build in test-build and backend image test: OK
ijusttookadnatest May 8, 2025
a8edb0e
feat: fix ingester dockerfile name, add task-build-image generic work…
ijusttookadnatest May 9, 2025
a3dbbc4
fix: name ingester dockerfile in test-build
ijusttookadnatest May 9, 2025
e92ec3e
debug: add debug log for assess gemini stream response delay and fix …
ijusttookadnatest May 12, 2025
64fd8c9
fix: update ingester dockerfile to add certificat installation
ijusttookadnatest May 12, 2025
8dfcd58
fix: compose update on the server
ijusttookadnatest May 12, 2025
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
208 changes: 208 additions & 0 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
name: Backend-CI

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

permissions:
contents: read
pull-requests: write

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 9.10.0

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') || github.sha }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install

- name: Install turbo
run: pnpm add turbo@latest -g

- name: Build
run: turbo build

- name: Create config file
run: |
mkdir -p packages/agents
cat > packages/agents/config.toml << 'EOL'
[API_KEYS]
OPENAI = "${{ secrets.OPENAI }}"
ANTHROPIC = "${{ secrets.ANTHROPIC }}"
GEMINI = "${{ secrets.GEMINI }}"

[VECTOR_DB]
POSTGRES_USER = "${{ secrets.POSTGRES_USER }}"
POSTGRES_HOST = "postgres"
POSTGRES_ROOT_DB = "${{ secrets.POSTGRES_ROOT_DB }}"
POSTGRES_PASSWORD = "${{ secrets.POSTGRES_PASSWORD }}"
POSTGRES_PORT = "${{ secrets.POSTGRES_PORT }}"

[GENERAL]
PORT = 3001
SIMILARITY_MEASURE = "cosine"

[HOSTED_MODE]
DEFAULT_CHAT_PROVIDER = "gemini"
DEFAULT_CHAT_MODEL = "Gemini Flash 2.5"
DEFAULT_FAST_CHAT_PROVIDER = "gemini"
DEFAULT_FAST_CHAT_MODEL = "Gemini Flash 2.5"
DEFAULT_EMBEDDING_PROVIDER = "openai"
DEFAULT_EMBEDDING_MODEL = "Text embedding 3 large"

[VERSIONS]
STARKNET_FOUNDRY = "0.37.0"
SCARB = "2.9.2"
EOL

- name: Create env file
run: |
cat > .env << 'EOL'
POSTGRES_USER = "${{ secrets.POSTGRES_USER }}"
POSTGRES_HOST = "localhost"
POSTGRES_ROOT_DB = "${{ secrets.POSTGRES_ROOT_DB }}"
POSTGRES_PASSWORD = "${{ secrets.POSTGRES_PASSWORD }}"
POSTGRES_PORT = "${{ secrets.POSTGRES_PORT }}"
EOL

- name: Create backend env file
run: |
touch packages/backend/.env

- name: Run unit tests
run: pnpm run test:unit

- name: Build docker image
run: docker build -t cairo-coder-backend:${{ github.sha }} -f backend.dockerfile .

- name: Run backend and database integration tests
run: |
docker compose up -d postgres backend
echo "Waiting for services to be ready..."
sleep 20

chmod +x ./scripts/integration-tests.sh
chmod +x ./scripts/database-connection.sh

echo -e "\n=== Running basic integration tests ==="
./scripts/integration-tests.sh
INTEGRATION_RESULT=$?

echo -e "\n=== Running database connection test via chat/completions endpoint ==="
./scripts/database-connection.sh
DB_CONNECTION_RESULT=$?

if [ $INTEGRATION_RESULT -ne 0 ] || [ $DB_CONNECTION_RESULT -ne 0 ]; then
echo "❌ Integration tests failed!"
exit 1
else
echo "✅ All integration tests passed!"
fi

- name: Build ingester image
run: docker compose --profile ingester build ingester

- name: Run data ingestion
run: docker compose --profile ingester up -d ingester

- name: Import snak repository
run: |
mkdir -p ./snak
git clone https://github.com/KasarLabs/snak ./snak
cd ./snak
git checkout fix/server-for-reuse

- name: Create snak env file
run: |
cd ./snak
cat > .env << 'EOL'

STARKNET_PUBLIC_ADDRESS="${{ secrets.STARKNET_PUBLIC_ADDRESS }}"
STARKNET_PRIVATE_KEY="${{ secrets.STARKNET_PRIVATE_KEY }}"
STARKNET_RPC_URL="${{ secrets.STARKNET_RPC_URL }}"

AI_PROVIDER_API_KEY="${{ secrets.ANTHROPIC }}"
AI_MODEL="claude-3-5-sonnet-latest"
AI_PROVIDER="anthropic"

NODE_ENV="development"

SERVER_API_KEY="${{ secrets.SNAK_SERVER_KEY }}"
SERVER_PORT="${{ secrets.SNAK_SERVER_PORT }}"

POSTGRES_USER="${{ secrets.POSTGRES_USER }}"
POSTGRES_PASSWORD="${{ secrets.POSTGRES_PASSWORD }}"
POSTGRES_ROOT_DB="${{ secrets.POSTGRES_ROOT_DB }}"
POSTGRES_HOST="localhost"
POSTGRES_PORT="${{ secrets.POSTGRES_PORT }}"

CAIRO_UPLOAD_DIR="plugins/cairocoder/uploads/"
CAIRO_GENERATION_API_URL="http://127.0.0.1:3001/chat/completions"

EOL

- name: Cache snak node modules
uses: actions/cache@v4
with:
path: ./snak/node_modules
key: ${{ runner.os }}-snak-modules-${{ hashFiles('./snak/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-snak-modules-

- name: Install snak dependencies
run: |
cd ./snak
pnpm install --filter="@snakagent/server..."

- name: Start snak server
run: |
cd ./snak
pnpm run build --filter="@snakagent/server..." && lerna run start --scope "@snakagent/server" &

echo "Waiting for server to start..."
sleep 120

- name: Create cairo code generation test env file
run: |
cd ./packages/agents
cat > .env.test << 'EOL'

API_KEY="${{ secrets.SNAK_SERVER_KEY }}"
API_URL="http://localhost:${{ secrets.SNAK_SERVER_PORT }}"

EOL

- name: Run cairo code generation test
run: |
chmod +x ./scripts/snak-test.sh
bash scripts/snak-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') || github.sha }}
restore-keys: |
${{ runner.os }}-pnpm-store-

Expand Down Expand Up @@ -69,35 +69,43 @@ jobs:
mkdir -p packages/agents
cat > packages/agents/config.toml << 'EOL'
[API_KEYS]
OPENAI = "${{ secrets.OPENAI_API_KEY }}"
GROQ = "${{ secrets.GROQ_API_KEY }}"
ANTHROPIC = "${{ secrets.ANTHROPIC_API_KEY }}"
DEEPSEEK = "${{ secrets.DEEPSEEK_API_KEY }}"
GEMINI = "${{ secrets.GEMINI_API_KEY }}"

[API_ENDPOINTS]
OLLAMA = "${{ secrets.OLLAMA_ENDPOINT }}"
OPENAI = "${{ secrets.OPENAI }}"
ANTHROPIC = "${{ secrets.ANTHROPIC }}"
GEMINI = "${{ secrets.GEMINI }}"

[VECTOR_DB]
MONGODB_URI = "${{ secrets.MONGODB_URI }}"
DB_NAME = "${{ secrets.DB_NAME }}"
COLLECTION_NAME = "${{ secrets.COLLECTION_NAME }}"
POSTGRES_USER = "${{ secrets.POSTGRES_USER }}"
POSTGRES_HOST = "postgres"
POSTGRES_ROOT_DB = "${{ secrets.POSTGRES_ROOT_DB }}"
POSTGRES_PASSWORD = "${{ secrets.POSTGRES_PASSWORD }}"
POSTGRES_PORT = "${{ secrets.POSTGRES_PORT }}"

[GENERAL]
PORT = 3001
SIMILARITY_MEASURE = "cosine"

[HOSTED_MODE]
DEFAULT_CHAT_PROVIDER = "${{ secrets.DEFAULT_CHAT_PROVIDER }}"
DEFAULT_CHAT_MODEL = "${{ secrets.DEFAULT_CHAT_MODEL }}"
DEFAULT_FAST_CHAT_PROVIDER = "${{ secrets.DEFAULT_FAST_CHAT_PROVIDER }}"
DEFAULT_FAST_CHAT_MODEL = "${{ secrets.DEFAULT_FAST_CHAT_MODEL }}"
DEFAULT_EMBEDDING_PROVIDER = "${{ secrets.DEFAULT_EMBEDDING_PROVIDER }}"
DEFAULT_EMBEDDING_MODEL = "${{ secrets.DEFAULT_EMBEDDING_MODEL }}"
DEFAULT_CHAT_PROVIDER = "gemini"
DEFAULT_CHAT_MODEL = "Gemini Flash 2.5"
DEFAULT_FAST_CHAT_PROVIDER = "gemini"
DEFAULT_FAST_CHAT_MODEL = "Gemini Flash 2.5"
DEFAULT_EMBEDDING_PROVIDER = "openai"
DEFAULT_EMBEDDING_MODEL = "Text embedding 3 large"

[VERSIONS]
STARKNET_FOUNDRY = "${{ secrets.STARKNET_FOUNDRY_VERSION }}"
SCARB = "${{ secrets.SCARB_VERSION }}"
STARKNET_FOUNDRY = "0.37.0"
SCARB = "2.9.2"
EOL

- name: Create env file
run: |
mkdir -p packages/agents
cat > packages/agents/.env << 'EOL'
POSTGRES_USER = "${{ secrets.POSTGRES_USER }}"
POSTGRES_HOST = "localhost"
POSTGRES_ROOT_DB = "${{ secrets.POSTGRES_ROOT_DB }}"
POSTGRES_PASSWORD = "${{ secrets.POSTGRES_PASSWORD }}"
POSTGRES_PORT = "${{ secrets.POSTGRES_PORT }}"
EOL

- name: Generate embeddings
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/task-build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Create and publish a Docker image

on:
workflow_dispatch:
workflow_call:
inputs:
registry:
description: Container registry domain
required: true
type: string
image-name:
description: Name for the Docker image
required: true
type: string
image-file:
description: Dockerfile used to build the image
required: true
type: string

permissions:
contents: read
packages: write
attestations: write
id-token: write

jobs:
build-and-push-image:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Extract metadata
id: meta-backend
uses: docker/metadata-action@v5
with:
images: ${{ inputs.registry }}/${{ inputs.image-name }}/${{ inputs.image-file }}
tags: |
type=ref,event=branch
type=sha,format=short
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push Docker image
id: push-image
uses: docker/build-push-action@v6
with:
context: .
push: true
file: ./${{ inputs.image-file }}.dockerfile
tags: ${{ steps.meta-backend.outputs.tags }}
labels: ${{ steps.meta-backend.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
Loading
Loading