Skip to content

Add user-drawn bounding box annotations, collections, and review workflow #275

Add user-drawn bounding box annotations, collections, and review workflow

Add user-drawn bounding box annotations, collections, and review workflow #275

Workflow file for this run

name: CI/CD Pipeline
# Define variables at the top
env:
REGISTRY: ghcr.io
IMAGE_NAME: sandialabs/vista
PYTHON_VERSION: "3.11"
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
checks: write
security-events: write
packages: write
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Set up Node.js
uses: actions/setup-node@v5
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libpq-dev which
- name: Build frontend
run: |
cd frontend
npm ci --legacy-peer-deps
npm run build
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Install Python dependencies with uv
run: uv sync --frozen
- name: Set up test environment
run: |
cp .env.example backend/.env || echo "No .env.example found, using defaults"
- name: Run tests
run: uv run bash test/run_tests.sh
env:
DATABASE_URL: postgresql+asyncpg://postgres:postgres@localhost:5432/postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
POSTGRES_SERVER: localhost
POSTGRES_PORT: 5432
DEBUG: true
SKIP_HEADER_CHECK: true
MOCK_USER_EMAIL: test@example.com
JUNIT_XML_PATH: ${{ github.workspace }}/test-results/backend.xml
- name: Publish test results
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Backend Test Results
path: test-results/backend.xml
reporter: java-junit
build:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test container
run: |
# Start the container (install dev deps for aiosqlite SQLite driver)
docker run -d --name test-container \
-e DATABASE_URL="sqlite+aiosqlite:///./test.db" \
-e FAST_TEST_MODE=true \
-e DEBUG=true \
-e SKIP_HEADER_CHECK=true \
-e ENV=development \
-e VISTA_AUTH_BACKEND=demo \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=postgres \
-e POSTGRES_SERVER=localhost \
-p 8000:8000 \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
bash -c "uv sync --frozen && uvicorn main:app --host 0.0.0.0 --port 8000"
# Wait for container to start and implement health checking with retry
echo "Waiting for container to become healthy..."
for i in {1..30}; do
if curl -f http://localhost:8000/api/health > /dev/null 2>&1; then
echo "Container is healthy after ${i} attempts"
break
fi
if [ $i -eq 30 ]; then
echo "Container failed to become healthy after 30 attempts"
docker logs test-container
exit 1
fi
echo "Attempt $i failed, waiting 2 seconds..."
sleep 2
done
# Test health endpoint one more time to be sure
curl -f http://localhost:8000/api/health || exit 1
# Stop container
docker stop test-container
docker rm test-container
- name: Run tests in container
run: |
docker run --rm \
-e DATABASE_URL="sqlite+aiosqlite:///./test.db" \
-e FAST_TEST_MODE=true \
-e DEBUG=true \
-e SKIP_HEADER_CHECK=true \
-e ENV=development \
-e VISTA_AUTH_BACKEND=demo \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=postgres \
-e POSTGRES_SERVER=localhost \
--workdir /app \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
bash -c "uv sync --frozen && bash test/run_tests.sh --backend"
- name: Push Docker image
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max