Skip to content
Merged
Changes from all commits
Commits
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
184 changes: 161 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,187 @@
name: CI
on: [push, pull_request]

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

env:
PYTHON_VERSION: "3.12"
NODE_VERSION: "20"

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run lint

- name: Setup Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
cache-dependency-path: |
backend/requirements.txt
analytics/requirements.txt

- name: Setup Node ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: frontend/package-lock.json

- name: Install Python deps
run: |
# Python lint
pip install -r backend/requirements.txt
pip install -r analytics/requirements.txt
pip install ruff
ruff check backend/
# JS lint
npm install eslint
npm run lint --prefix frontend/

test:

- name: Frontend npm install
run: if (Test-Path package-lock.json) { npm ci } else { npm install }
working-directory: frontend
shell: pwsh

- name: Lint Python
run: ruff check backend/ analytics/

- name: Lint Frontend
run: npm run lint
working-directory: frontend

- name: Type Check Frontend
run: npm run typecheck
working-directory: frontend

test-backend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4

- name: Setup Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
cache-dependency-path: backend/requirements.txt

- name: Install deps
run: pip install -r requirements.txt

- name: Run tests
run: |
# Backend tests
pip install pytest pytest-cov
pytest backend/tests/ --cov=backend/app --cov-report=xml
# Frontend tests
npm test --prefix frontend/ -- --coverage

build:
pytest tests/ \
--cov=app \
--cov-report=xml:../coverage.xml \
--cov-report=term-missing \
-v

- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage-backend
path: coverage.xml

- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage-backend
path: coverage.xml

test-analytics:
runs-on: ubuntu-latest
needs: [lint, test]
defaults:
run:
working-directory: analytics
steps:
- uses: actions/checkout@v4
- name: Build Docker images

- name: Setup Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
cache-dependency-path: analytics/requirements.txt

- name: Install deps
run: pip install -r requirements.txt

- name: Run tests
run: |
docker build -t agentloop-api ./backend
docker build -t agentloop-analytics ./analytics
docker build -t agentloop-frontend ./frontend
pytest tests/ \
--cov=app \
--cov-report=xml:../coverage.xml \
--cov-report=term-missing \
-v

- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage-analytics
path: coverage.xml

- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage-analytics
path: coverage.xml

build:
runs-on: ubuntu-latest
needs: [lint, test-backend, test-analytics]
steps:
- uses: actions/checkout@v4

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

- name: Build API image
uses: docker/build-push-action@v5
with:
context: backend
push: false
tags: agentloop-api:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build Analytics image
uses: docker/build-push-action@v5
with:
context: analytics
push: false
tags: agentloop-analytics:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build Frontend image
uses: docker/build-push-action@v5
with:
context: frontend
push: false
tags: agentloop-frontend:latest
cache-from: type=gha
cache-to: type=gha,mode=max

release:
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4

- name: Build release artifacts
run: |
mkdir -p dist
cp README.md dist/
cp CHANGELOG.md dist/

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
files: dist/*
files: dist/*
generate_release_notes: true

Loading