Skip to content
Open
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# DebugAI Environment Variables
# Copy this file to .env and fill in your values

# Required: Gemini API Key
# Get yours at: https://makersuite.google.com/app/apikey
GEMINI_API_KEY=your_api_key_here

# Optional: Model selection
# Options: gemini-1.5-flash (default), gemini-1.5-pro
DEBUGAI_MODEL=gemini-1.5-flash

# Optional: Output format
# Options: rich (default), json, markdown, plain
DEBUGAI_FORMAT=rich
221 changes: 221 additions & 0 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
name: Bump Version and Release

on:
workflow_dispatch:
inputs:
version_type:
description: 'Version bump type'
required: true
type: choice
options:
- major
- minor
- patch
default: 'patch'

permissions:
contents: write
id-token: write

jobs:
bump-version:
name: Bump Version
runs-on: ubuntu-latest

outputs:
new_version: ${{ steps.bump.outputs.new_version }}
old_version: ${{ steps.get_version.outputs.current_version }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Get current version
id: get_version
run: |
CURRENT_VERSION=$(grep -oP '(?<=version = ")[^"]*' debugai/pyproject.toml)
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "Current version: $CURRENT_VERSION"

- name: Bump version
id: bump
run: |
CURRENT_VERSION="${{ steps.get_version.outputs.current_version }}"
VERSION_TYPE="${{ github.event.inputs.version_type }}"

# Split version into parts
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"

# Bump based on type
case $VERSION_TYPE in
major)
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
;;
minor)
MINOR=$((MINOR + 1))
PATCH=0
;;
patch)
PATCH=$((PATCH + 1))
;;
esac

NEW_VERSION="$MAJOR.$MINOR.$PATCH"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "New version: $NEW_VERSION"

- name: Update pyproject.toml
run: |
sed -i 's/version = "${{ steps.get_version.outputs.current_version }}"/version = "${{ steps.bump.outputs.new_version }}"/' debugai/pyproject.toml

- name: Update CHANGELOG.md
run: |
NEW_VERSION="${{ steps.bump.outputs.new_version }}"
TODAY=$(date +%Y-%m-%d)
VERSION_TYPE="${{ github.event.inputs.version_type }}"

# Create changelog entry
cat > /tmp/changelog_entry.md << EOF
## [$NEW_VERSION] - $TODAY

### Changed
- Version bump: $VERSION_TYPE release

EOF

# Insert after [Unreleased] section
sed -i "/## \[Unreleased\]/r /tmp/changelog_entry.md" debugai/CHANGELOG.md

- name: Commit version bump
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add debugai/pyproject.toml debugai/CHANGELOG.md
git commit -m "Bump version to ${{ steps.bump.outputs.new_version }}"
git push origin ${{ github.ref_name }}

- name: Create and push tag
run: |
git tag -a "v${{ steps.bump.outputs.new_version }}" -m "Release v${{ steps.bump.outputs.new_version }}"
git push origin "v${{ steps.bump.outputs.new_version }}"

# Trigger the release workflow by creating the tag
create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: bump-version

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: v${{ needs.bump-version.outputs.new_version }}
fetch-depth: 0

- name: Extract changelog for this version
id: changelog
run: |
VERSION=${{ needs.bump-version.outputs.new_version }}
CHANGELOG=$(sed -n "/## \[$VERSION\]/,/## \[/p" debugai/CHANGELOG.md | sed '$d')
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.bump-version.outputs.new_version }}
name: Release v${{ needs.bump-version.outputs.new_version }}
body: |
## What's Changed

${{ steps.changelog.outputs.CHANGELOG }}

**Full Changelog**: https://github.com/${{ github.repository }}/compare/v${{ needs.bump-version.outputs.old_version }}...v${{ needs.bump-version.outputs.new_version }}
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Build and publish to PyPI
publish-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [bump-version, create-release]

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: v${{ needs.bump-version.outputs.new_version }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine hatchling

- name: Build package
run: |
cd debugai
python -m build

- name: Check distribution
run: |
cd debugai
twine check dist/*

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: debugai/dist/
skip-existing: true

# Build and publish documentation
publish-docs:
name: Publish Documentation
runs-on: ubuntu-latest
needs: [bump-version, create-release]

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: v${{ needs.bump-version.outputs.new_version }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
cd debugai
pip install -e ".[docs]"

- name: Build documentation
run: |
cd debugai
mkdocs build

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: debugai/site
99 changes: 99 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: CI

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

jobs:
test:
name: Test on Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.11', '3.12']

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

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Run tests
run: |
pytest tests/ -v --cov=debugai --cov-report=xml --cov-report=term

- name: Upload coverage
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-${{ matrix.os }}-py${{ matrix.python-version }}

lint:
name: Lint and Format Check
runs-on: ubuntu-latest

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

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
pip install ruff black mypy

- name: Run Ruff
run: ruff check .

- name: Run Black
run: black --check .

- name: Run MyPy
run: mypy src/debugai --ignore-missing-imports

stress-test:
name: Run Stress Tests
runs-on: ubuntu-latest

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

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
pip install -e ".[dev]"

- name: Run stress tests
run: |
python tests/stress_test.py

- name: Upload stress test results
uses: actions/upload-artifact@v3
if: always()
with:
name: stress-test-results
path: |
stress-test-*.log
stress-test-*.json
Loading
Loading