Skip to content

feat(ci): Setup CI workflow with code generation test suite #7

feat(ci): Setup CI workflow with code generation test suite

feat(ci): Setup CI workflow with code generation test suite #7

Workflow file for this run

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') }}
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 = "anthropic"
DEFAULT_CHAT_MODEL = "Claude 3.5 Sonnet"
DEFAULT_FAST_CHAT_PROVIDER = "anthropic"
DEFAULT_FAST_CHAT_MODEL = "Claude 3.5 Sonnet"
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: |
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: Run unit tests
run: turbo test
- name: Build docker image
run: docker build -t cairo-coder-backend:${{ github.sha }} -f backend.dockerfile .
- name: Run 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: Push docker image
# run: docker push ${{ github.repository }}:${{ github.sha }}