Fix flake8 F824 in api.py; add FastAPI backend, Streamlit UI, tests, and CI #27
This file contains hidden or 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", "master", "copilot/**"] | |
| pull_request: | |
| branches: ["main", "master"] | |
| permissions: | |
| contents: read | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| cache: "pip" | |
| - name: Install flake8 | |
| run: pip install flake8 | |
| - name: Lint — blocking (syntax errors / undefined names) | |
| run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
| - name: Lint — style warnings (non-blocking) | |
| run: flake8 . --count --exit-zero --max-line-length=100 --statistics | |
| test: | |
| needs: lint | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: "pip" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run tests with coverage | |
| env: | |
| OPENAI_API_KEY: "offline-mode-no-key-required" | |
| run: pytest test_chatbot.py -v --tb=short --cov=. --cov-report=xml | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-${{ matrix.python-version }} | |
| path: coverage.xml | |
| docker-build: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build Docker image (web mode) | |
| run: docker build --build-arg MODE=web -t ai-chatbot:web . | |
| - name: Build Docker image (api mode) | |
| run: docker build --build-arg MODE=api -t ai-chatbot:api . |