name: Run Tests on: push: branches: ['**'] pull_request: branches: [main] jobs: backend-tests: runs-on: ubuntu-latest strategy: matrix: 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 }} - name: Cache pip packages uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }} restore-keys: | ${{ runner.os }}-pip- - name: Install dependencies working-directory: ./backend run: | python -m pip install --upgrade pip pip install -r requirements.txt pip install -r requirements-dev.txt - name: Run pytest with coverage working-directory: ./backend run: | pytest --cov=. --cov-report=xml --cov-report=term-missing -v - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: file: ./backend/coverage.xml flags: backend name: backend-coverage fail_ci_if_error: false - name: Check test coverage threshold working-directory: ./backend run: | coverage report --fail-under=70 frontend-tests: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' cache-dependency-path: frontend/package-lock.json - name: Install dependencies working-directory: ./frontend run: npm ci - name: Run linting working-directory: ./frontend run: npm run lint || echo "Linting not configured yet" - name: Build frontend working-directory: ./frontend run: npm run build docker-build-test: runs-on: ubuntu-latest needs: [backend-tests, frontend-tests] steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build backend Docker image uses: docker/build-push-action@v5 with: context: ./backend file: ./backend/Dockerfile push: false tags: backend:test cache-from: type=gha cache-to: type=gha,mode=max - name: Build frontend Docker image uses: docker/build-push-action@v5 with: context: ./frontend file: ./frontend/Dockerfile push: false tags: frontend:test cache-from: type=gha cache-to: type=gha,mode=max build-args: | NEXT_PUBLIC_API_URL=http://backend:5000