Skip to content

Add comprehensive documentation, E2E tests, and CI/CD workflow #23

Add comprehensive documentation, E2E tests, and CI/CD workflow

Add comprehensive documentation, E2E tests, and CI/CD workflow #23

Workflow file for this run

name: CI
on:
push:
branches: [ main, docs/* ]
pull_request:
branches: [ main ]
jobs:
test:
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e '.[dev]'
- name: Build UI
run: npm install && npm run build
- name: Start Artifacta server (Unix)
if: runner.os != 'Windows'
run: |
mkdir -p data
nohup artifacta ui --port 8000 > server.log 2>&1 &
echo $! > server.pid
# Wait for server to be ready
echo "Waiting for server to start..."
SERVER_READY=false
for i in {1..30}; do
if curl -s http://localhost:8000/health > /dev/null 2>&1; then
echo "✓ Server is ready"
SERVER_READY=true
break
fi
echo "Waiting for server... ($i/30)"
sleep 1
done
# Fail if server never started
if [ "$SERVER_READY" = "false" ]; then
echo "✗ Server failed to start after 30 seconds"
echo "Server log:"
cat server.log
exit 1
fi
- name: Start Artifacta server (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path data
# Start server as background job
$job = Start-Job -ScriptBlock {
Set-Location $using:PWD
artifacta ui --port 8000 2>&1 | Tee-Object -FilePath server.log
}
$job.Id | Out-File -FilePath server.job.id
Write-Host "Started server job ID: $($job.Id)"
# Wait for server to be ready
Write-Host "Waiting for server to start..."
$serverReady = $false
for ($i = 1; $i -le 30; $i++) {
# Check if job is still running
$jobState = (Get-Job -Id $job.Id).State
if ($jobState -eq 'Failed' -or $jobState -eq 'Stopped') {
Write-Host "Server job failed or stopped"
Write-Host "Job output:"
Receive-Job -Id $job.Id
exit 1
}
try {
$response = Invoke-WebRequest -Uri http://127.0.0.1:8000/health -UseBasicParsing -TimeoutSec 1 -ErrorAction Stop
if ($response.StatusCode -eq 200) {
Write-Host "Server is ready (Job ID: $($job.Id))"
$serverReady = $true
break
}
} catch {
Write-Host "Waiting for server... ($i/30)"
Start-Sleep -Seconds 1
}
}
# Fail if server never started
if (-not $serverReady) {
Write-Host "Server failed to start after 30 seconds"
Write-Host "Job state: $((Get-Job -Id $job.Id).State)"
Write-Host "Job output:"
Receive-Job -Id $job.Id
exit 1
}
- name: Run pytest
run: pytest tests/ -v --tb=short
env:
TRACKING_SERVER_HOST: ${{ runner.os == 'Windows' && '127.0.0.1' || 'localhost' }}
- name: Stop Artifacta server (Unix)
if: always() && runner.os != 'Windows'
run: |
if [ -f server.pid ]; then
kill $(cat server.pid) || true
rm server.pid
fi
- name: Stop Artifacta server (Windows)
if: always() && runner.os == 'Windows'
shell: pwsh
run: |
if (Test-Path server.job.id) {
$jobId = Get-Content server.job.id
Stop-Job -Id $jobId -ErrorAction SilentlyContinue
Remove-Job -Id $jobId -ErrorAction SilentlyContinue
Write-Host "Stopped server job ID: $jobId"
}
# Also kill any remaining artifacta processes
Get-Process | Where-Object {$_.ProcessName -eq "artifacta"} | Stop-Process -Force -ErrorAction SilentlyContinue
e2e:
name: E2E Tests on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -e '.[dev]'
- name: Install Node dependencies and build UI
run: npm install && npm run build
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Run E2E tests
run: npm run test:e2e
env:
ARTIFACTA_URL: ${{ runner.os == 'Windows' && 'http://127.0.0.1:8000' || 'http://localhost:8000' }}
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e '.[dev]'
- name: Run ruff
run: ruff check . --fix
- name: Run mypy
run: mypy --ignore-missing-imports tracking-server
build:
name: Build Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/