Skip to content

Merge pull request #134 from YLaxmikanth/issue-123-faq-page #250

Merge pull request #134 from YLaxmikanth/issue-123-faq-page

Merge pull request #134 from YLaxmikanth/issue-123-faq-page #250

Workflow file for this run

name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
frontend-lint:
name: Frontend Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npm run lint
frontend-build:
name: Frontend Build
runs-on: ubuntu-latest
needs: frontend-lint
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
env:
VITE_API_URL: https://karansingh12-freshscan-api.hf.space
VITE_DEV_MODE: false
backend-lint-and-test:
name: Backend Lint and Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
- name: Install dependencies
run: pip install -r requirements-ci.txt
- name: Lint with Ruff
run: ruff check . --config ruff.toml
- name: Run tests
run: python -m pytest tests/test_ci.py -v
env:
DEV_BYPASS_AUTH: "false"
DEV_BYPASS_TOKEN: ci-test-token
SUPABASE_URL: ""
SUPABASE_KEY: ""
SUPABASE_SERVICE_KEY: ""
FRONTEND_URL: http://localhost:5173
API_BASE_URL: http://localhost:8000
check-backend-changes:
name: Check Backend Changes
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
outputs:
backend: ${{ steps.filter.outputs.backend }}
steps:
- uses: actions/checkout@v6
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
backend:
- 'backend/**'
deploy-backend-to-hf-spaces:
name: Deploy Backend → HF Spaces
# Only deploy on push to main if backend files changed
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.check-backend-changes.outputs.backend == 'true'
needs: [backend-lint-and-test, check-backend-changes]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # full history needed for subtree push
lfs: true
- name: Configure git
run: |
git config user.email "ci@freshscan.ai"
git config user.name "FreshScan CI"
- name: Push backend/ → HF Spaces
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
# Check if HF_TOKEN is set
if [ -z "${HF_TOKEN}" ]; then
echo "ERROR: HF_TOKEN secret is missing!"
echo "Please add your Hugging Face Access Token as a Repository Secret named 'HF_TOKEN' in GitHub."
exit 1
fi
# Since HF Spaces might have auto-generated files (like README.md)
# that aren't in this repo, a normal push gets rejected.
# We need to split the backend directory into its own commit history
# and FORCE push it to HF Spaces, making GitHub the single source of truth.
COMMIT_HASH=$(git subtree split --prefix backend main)
git push https://karansingh12:${HF_TOKEN}@huggingface.co/spaces/karansingh12/freshscan-api ${COMMIT_HASH}:main --force