Skip to content

Update the ci pipeline #157

Update the ci pipeline

Update the ci pipeline #157

Workflow file for this run

name: AtaraxAI CI/CD
on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]
jobs:
test_and_lint_backend:
name: Test & Lint Backend
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Free up disk space
run: |
echo "Initial disk space:"
df -h
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/swift
sudo rm -rf /opt/hostedtoolcache/CodeQL
echo "Disk space after cleanup:"
df -h
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential cmake libgomp1 libcurl4-openssl-dev \
ccache portaudio19-dev python3-pyaudio ninja-build
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv
run: pip install uv
- name: Cache uv dependencies
uses: actions/cache@v4
with:
path: ~/.cache/uv
key: ${{ runner.os }}-uv-${{ hashFiles('**/pyproject.toml', '**/uv.lock') }}
restore-keys: |
${{ runner.os }}-uv-
- name: Cache CMake build
uses: actions/cache@v4
with:
path: build
key: ${{ runner.os }}-cmake-${{ hashFiles('CMakeLists.txt', '**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-cmake-
- name: Build C++ extension and install Python dependencies
run: |
chmod +x install.sh
./install.sh --clean
uv venv -p 3.12
source .venv/bin/activate
uv pip install -e ".[dev]"
- name: Download test models
run: |
mkdir -p test_assets
wget -q -O test_assets/tinyllama.gguf \
"https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/tinyllama-1.1b-chat-v1.0.Q2_K.gguf"
wget -q -O test_assets/ggml-tiny.en.bin \
"https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.en.bin"
- name: Run C++ Unit Tests
run: |
cd build/ataraxai/hegemonikon/
ctest --output-on-failure --verbose
- name: Run Python Unit Tests
run: |
source .venv/bin/activate
pytest -m unit --cov=ataraxai --cov-report=term-missing --cov-report=xml
- name: Run Python Integration Tests
if: (github.event_name == 'pull_request' && github.base_ref == 'main') || github.ref == 'refs/heads/main'
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
source .venv/bin/activate
pytest -m integration --cov=ataraxai --cov-report=term-missing --cov-report=xml
- name: Upload coverage reports
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
- name: Lint with Ruff
run: |
source .venv/bin/activate
ruff check ataraxai
- name: Type Check with MyPy
run: |
source .venv/bin/activate
mypy ataraxai || true
build_desktop_release:
name: Build Desktop App on ${{ matrix.platform.os }}
needs: test_and_lint_backend
if: (github.event_name == 'pull_request' && github.base_ref == 'main') || github.ref == 'refs/heads/main'
strategy:
fail-fast: false
matrix:
platform:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
build_script: ./build_backend.sh
artifact_pattern: |
ataraxai-ui/src-tauri/target/release/bundle/**/*.AppImage
ataraxai-ui/src-tauri/target/release/bundle/**/*.deb
- os: macos-latest
target: x86_64-apple-darwin
build_script: ./build_backend.sh
artifact_pattern: |
ataraxai-ui/src-tauri/target/release/bundle/**/*.dmg
- os: windows-latest
target: x86_664-pc-windows-msvc
build_script: .\build_backend.ps1
artifact_pattern: |
ataraxai-ui/src-tauri/target/release/bundle/**/*.msi
ataraxai-ui/src-tauri/target/release/bundle/**/*.exe
runs-on: ${{ matrix.platform.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Free up disk space (Linux only)
if: matrix.platform.os == 'ubuntu-latest'
run: |
echo "Initial disk space:"
df -h
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/swift
sudo rm -rf /opt/hostedtoolcache/CodeQL
echo "Disk space after cleanup:"
df -h
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: ataraxai-ui/package-lock.json
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv
run: pip install uv
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install Tauri CLI
run: npm install -g @tauri-apps/cli
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
ataraxai-ui/src-tauri/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Linux system dependencies
if: matrix.platform.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libwebkit2gtk-4.1-dev build-essential curl wget \
libssl-dev libgtk-3-dev libayatana-appindicator3-dev \
librsvg2-dev libcurl4-openssl-dev cmake ninja-build
- name: Install macOS system dependencies
if: matrix.platform.os == 'macos-latest'
run: |
brew install cmake ninja bash
- name: Make build script executable (Unix)
if: matrix.platform.os != 'windows-latest'
run: chmod +x build_backend.sh
- name: Install frontend dependencies
working-directory: ./ataraxai-ui
run: npm ci
- name: Build backend artifact (Unix)
if: matrix.platform.os != 'windows-latest'
run: ${{ matrix.platform.build_script }}
shell: /usr/local/bin/bash
- name: Build backend artifact (Windows)
if: matrix.platform.os == 'windows-latest'
shell: pwsh
run: ${{ matrix.platform.build_script }}
- name: Build Tauri application
working-directory: ./ataraxai-ui
run: npm run tauri build
- name: List build artifacts (Debug)
if: always()
shell: bash
run: |
echo "=== Listing build artifacts ==="
if [ -d "ataraxai-ui/src-tauri/target/release/bundle" ]; then
find ataraxai-ui/src-tauri/target/release/bundle -type f
else
echo "Bundle directory not found"
fi
- name: Upload Desktop App Artifact
uses: actions/upload-artifact@v4
with:
name: AtaraxAI-${{ matrix.platform.os }}-${{ github.sha }}
path: ${{ matrix.platform.artifact_pattern }}
if-no-files-found: error
retention-days: 30
# build_docker:
# name: Build and Push Docker Image
# needs: test_and_lint_backend
# if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev')
# runs-on: ubuntu-latest
# permissions:
# contents: read
# packages: write
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Extract metadata
# id: meta
# uses: docker/metadata-action@v5
# with:
# images: ataraxai/ataraxai
# tags: |
# type=ref,event=branch
# type=sha,prefix={{branch}}-
# type=raw,value=latest,enable={{is_default_branch}}
# - name: Build and push CPU image
# uses: docker/build-push-action@v5
# with:
# context: .
# file: ./docker/Dockerfile.cpu
# push: true
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}
# cache-from: type=registry,ref=ataraxai/ataraxai:buildcache
# cache-to: type=registry,ref=ataraxai/ataraxai:buildcache,mode=max
# platforms: linux/amd64,linux/arm64
# - name: Build and push GPU image (optional)
# if: github.ref == 'refs/heads/main'
# uses: docker/build-push-action@v5
# with:
# context: .
# file: ./docker/Dockerfile.gpu
# push: true
# tags: ataraxai/ataraxai:latest-gpu,ataraxai/ataraxai:${{ github.sha }}-gpu
# labels: ${{ steps.meta.outputs.labels }}
# cache-from: type=registry,ref=ataraxai/ataraxai:buildcache-gpu
# cache-to: type=registry,ref=ataraxai/ataraxai:buildcache-gpu,mode=max
# platforms: linux/amd64
# create_release:
# name: Create GitHub Release
# needs: [build_desktop_release, build_docker]
# if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# runs-on: ubuntu-latest
# permissions:
# contents: write
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - name: Download all artifacts
# uses: actions/download-artifact@v4
# with:
# path: artifacts/
# - name: Generate changelog
# id: changelog
# run: |
# echo "## What's Changed" > CHANGELOG.md
# git log --pretty=format:"- %s (%h)" $(git describe --tags --abbrev=0)..HEAD >> CHANGELOG.md || echo "- Initial release" >> CHANGELOG.md
# - name: Create Release
# uses: softprops/action-gh-release@v1
# with:
# tag_name: v${{ github.run_number }}
# name: Release v${{ github.run_number }}
# body_path: CHANGELOG.md
# files: artifacts/**/*
# draft: false
# prerelease: false
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}