add tests #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [ main, development ] | |
pull_request: | |
branches: [ main, development ] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Copy environment file | |
run: cp .env.development .env | |
- name: Build and test | |
run: | | |
docker compose version | |
mkdir -p tests | |
cp -r docker/backend/tests/* tests/ | |
docker compose -f docker-compose.dev.yml build | |
docker compose -f docker-compose.dev.yml up -d | |
docker compose -f docker-compose.dev.yml exec -T reproschema-server pip install pytest pytest-asyncio pytest-cov | |
docker compose -f docker-compose.dev.yml exec -T reproschema-server python -m pytest tests/ | |
docker compose -f docker-compose.dev.yml down | |
env: | |
# Core settings | |
NODE_ENV: development | |
CONTAINER_NAME: reproschema-server | |
# Schema configuration | |
SCHEMA_SOURCE: https://raw.githubusercontent.com/ReproNim/demo-protocol/main/DemoProtocol/DemoProtocol_schema | |
SCHEMA_PATH: ./schemas | |
# Data paths | |
DATA_PATH: ./data | |
# Project configuration | |
PROJECT_NAME: development # Match development environment | |
# Development settings | |
DEV_MODE: 1 | |
ADMIN_MODE: true | |
DEBUG_MODE: true | |
docker: | |
needs: test | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker images | |
env: | |
NODE_ENV: production # Ensure production build | |
PROJECT_NAME: reproschema # Use production name | |
run: | | |
docker compose -f docker-compose.yml build | |
docker compose -f docker-compose.yml push |