Skip to content

Implement updates for better performance #90

Implement updates for better performance

Implement updates for better performance #90

Workflow file for this run

name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
jobs:
code_quality:
name: Code Quality Checks
runs-on: ubuntu-latest
env:
BACKEND_DIR: code/backend
WEB_FRONTEND_DIR: web-frontend
MOBILE_FRONTEND_DIR: mobile-frontend
INFRASTRUCTURE_DIR: infrastructure
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: code/backend/requirements.txt
- name: Install Python formatters
run: |
python -m pip install --upgrade pip
python -m pip install autoflake black==25.11.0
- name: Check backend Python formatting
shell: bash
run: |
set -euo pipefail
if [ ! -d "${BACKEND_DIR}" ]; then
echo "Backend directory '${BACKEND_DIR}' not found — skipping Python formatting."
exit 0
fi
echo "=== Preparing temporary copy of backend for autoflake ==="
TMP_COPY="$(mktemp -d)"
cp -a "${BACKEND_DIR}/." "$TMP_COPY/"
echo "=== Running autoflake on temp copy ==="
autoflake \
--remove-all-unused-imports \
--remove-unused-variables \
--recursive \
--ignore-init-module-imports \
--in-place \
"$TMP_COPY"
echo "=== Comparing backend with autoflake-modified copy ==="
if ! diff -r "${BACKEND_DIR}" "$TMP_COPY" > /dev/null; then
echo "autoflake found unused imports or variables in backend."
echo "Run: autoflake --remove-all-unused-imports --remove-unused-variables --recursive --ignore-init-module-imports --in-place ${BACKEND_DIR}"
rm -rf "$TMP_COPY"
exit 1
fi
rm -rf "$TMP_COPY"
echo "=== Running black check ==="
black "${BACKEND_DIR}" --check
- name: Set up Node.js 20
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: tools/package-lock.json
- name: Install Node dependencies
working-directory: tools
run: npm ci
- name: Check web frontend formatting
shell: bash
run: |
set -euo pipefail
if [ -d "${WEB_FRONTEND_DIR}" ]; then
echo "=== Running Prettier (web frontend) ==="
npx --prefix tools prettier --check "${WEB_FRONTEND_DIR}/**/*.{js,jsx,ts,tsx,json,html,css,md}" --ignore-path tools/.prettierrc
else
echo "Web frontend directory not found — skipping."
fi
- name: Check mobile frontend formatting
shell: bash
run: |
set -euo pipefail
if [ -d "${MOBILE_FRONTEND_DIR}" ]; then
echo "=== Running Prettier (mobile frontend) ==="
npx --prefix tools prettier --check "${MOBILE_FRONTEND_DIR}/**/*.{js,jsx,ts,tsx,json,html,css,md}" --ignore-path tools/.prettierrc
else
echo "Mobile frontend directory not found — skipping."
fi
- name: Check markdown formatting
shell: bash
run: |
set -euo pipefail
echo "=== Running Prettier (all markdown files) ==="
npx --prefix tools prettier --check "**/*.md" --ignore-path tools/.prettierrc
- name: Check infrastructure YAML formatting
shell: bash
run: |
set -euo pipefail
if [ -d "${INFRASTRUCTURE_DIR}" ]; then
echo "=== Running Prettier (infrastructure YAML/YML) ==="
npx --prefix tools prettier --check "${INFRASTRUCTURE_DIR}/**/*.{yml,yaml}" --ignore-path tools/.prettierrc
else
echo "Infrastructure directory not found — skipping."
fi
- name: Quality checks complete
run: echo "All formatting checks completed successfully."
backend_tests:
name: Backend Tests
runs-on: ubuntu-latest
needs: code_quality
env:
BACKEND_DIR: code/backend
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: code/backend/requirements.txt
- name: Install backend dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
if [ -f "${BACKEND_DIR}/requirements.txt" ]; then
python -m pip install -r "${BACKEND_DIR}/requirements.txt"
fi
python -m pip install pytest pytest-cov pytest-asyncio
- name: Run backend test suite
working-directory: ${{ env.BACKEND_DIR }}
run: |
set -euo pipefail
echo "=== Running backend tests ==="
pytest tests/ \
--tb=short \
--strict-markers \
-v \
--cov=. \
--cov-report=term-missing \
--cov-report=xml:coverage.xml \
--junitxml=test-results.xml
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: backend-test-results
path: backend/test-results.xml
retention-days: 30
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: backend-coverage-report
path: backend/coverage.xml
retention-days: 30
- name: Backend tests complete
run: echo "All backend tests completed successfully."