Skip to content

docs: add CLI command example with input/output file parameters #23

docs: add CLI command example with input/output file parameters

docs: add CLI command example with input/output file parameters #23

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
release:
types: [published]
env:
PYTHON_VERSION: "3.11"
NODE_VERSION: "18"
UV_VERSION: "latest"
jobs:
# ===============================
# CODE QUALITY & SECURITY
# ===============================
code-quality:
name: Code Quality & Security
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
- name: Install dependencies
run: ./scripts/install.sh
- name: Run code quality checks
run: ./scripts/test.sh --lint
- name: Security scan with bandit
run: |
uv pip install bandit[toml]
bandit -r packages/*/src/ -f json -o bandit-report.json || true
- name: Upload security scan results
uses: actions/upload-artifact@v4
if: always()
with:
name: security-scan-results
path: bandit-report.json
# ===============================
# TESTING
# ===============================
test-core:
name: Test Core Package
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
- name: Install dependencies
run: ./scripts/install.sh
- name: Run core tests
run: ./scripts/test.sh --package core --coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: packages/core/coverage.xml
flags: core
name: core-coverage
test-cli:
name: Test CLI Package
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
- name: Install dependencies
run: ./scripts/install.sh
- name: Run CLI tests
run: ./scripts/test.sh --package cli --coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: packages/cli/coverage.xml
flags: cli
name: cli-coverage
test-api:
name: Test API Package
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: analyzer_test_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis:7-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
- name: Install dependencies
run: ./scripts/install.sh
- name: Set up test environment
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/analyzer_test_db
REDIS_URL: redis://localhost:6379/1
GOOGLE_API_KEY: test_key
JWT_SECRET: test_secret
run: |
cd packages/api
alembic upgrade head
- name: Run API tests
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/analyzer_test_db
REDIS_URL: redis://localhost:6379/1
GOOGLE_API_KEY: test_key
JWT_SECRET: test_secret
run: ./scripts/test.sh --package api --coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: packages/api/coverage.xml
flags: api
name: api-coverage
test-frontend:
name: Test Frontend Package
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
cache-dependency-path: packages/frontend/package-lock.json
- name: Install frontend dependencies
run: |
cd packages/frontend
npm ci
- name: Run frontend tests
run: ./scripts/test.sh --package frontend --coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: packages/frontend/coverage/lcov.info
flags: frontend
name: frontend-coverage
# ===============================
# INTEGRATION TESTS
# ===============================
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
needs: [test-core, test-cli, test-api, test-frontend]
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: analyzer_integration_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis:7-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
- name: Install dependencies
run: ./scripts/install.sh
- name: Run integration tests
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/analyzer_integration_db
REDIS_URL: redis://localhost:6379/2
GOOGLE_API_KEY: test_key
JWT_SECRET: test_secret
run: ./scripts/test.sh --integration
# ===============================
# BUILD & PACKAGE
# ===============================
build:
name: Build Packages
runs-on: ubuntu-latest
needs: [code-quality, test-core, test-cli, test-api, test-frontend]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
cache-dependency-path: packages/frontend/package-lock.json
- name: Install dependencies
run: ./scripts/install.sh
- name: Build all packages
run: ./scripts/build.sh --clean
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
packages/*/dist/
packages/frontend/dist/
retention-days: 7
# ===============================
# DOCKER BUILD
# ===============================
docker-build:
name: Build Docker Images
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
your-docker-registry/ai-project-analyzer-api
your-docker-registry/ai-project-analyzer-frontend
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push API image
uses: docker/build-push-action@v5
with:
context: .
file: docker/api/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push Frontend image
uses: docker/build-push-action@v5
with:
context: .
file: docker/frontend/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# ===============================
# DEPLOYMENT
# ===============================
deploy-staging:
name: Deploy to Staging
runs-on: ubuntu-latest
needs: [integration-tests, docker-build]
if: github.ref == 'refs/heads/develop'
environment: staging
steps:
- name: Deploy to staging
run: |
echo "🚀 Deploying to staging environment"
# Add your staging deployment commands here
deploy-production:
name: Deploy to Production
runs-on: ubuntu-latest
needs: [integration-tests, docker-build]
if: github.ref == 'refs/heads/main'
environment: production
steps:
- name: Deploy to production
run: |
echo "🚀 Deploying to production environment"
# Add your production deployment commands here