Skip to content

Commit f37219c

Browse files
Merge pull request #4 from joshuvavinith/copilot/fix-flake8-f824-error
Fix flake8 F824 CI blocker and upgrade CI pipeline
2 parents 87a9ddc + bc16032 commit f37219c

3 files changed

Lines changed: 39 additions & 19 deletions

File tree

.github/workflows/ci.yml

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,66 @@ on:
66
pull_request:
77
branches: ["main", "master"]
88

9-
# Restrict default GITHUB_TOKEN permissions to read-only
109
permissions:
1110
contents: read
1211

1312
jobs:
14-
lint-and-test:
13+
lint:
1514
runs-on: ubuntu-latest
16-
permissions:
17-
contents: read
1815

1916
steps:
2017
- uses: actions/checkout@v4
2118

22-
- name: Set up Python
19+
- name: Set up Python 3.12
2320
uses: actions/setup-python@v5
2421
with:
2522
python-version: "3.12"
23+
cache: "pip"
24+
25+
- name: Install flake8
26+
run: pip install flake8
27+
28+
- name: Lint — blocking (syntax errors / undefined names)
29+
run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
30+
31+
- name: Lint — style warnings (non-blocking)
32+
run: flake8 . --count --exit-zero --max-line-length=100 --statistics
33+
34+
test:
35+
needs: lint
36+
runs-on: ubuntu-latest
37+
strategy:
38+
matrix:
39+
python-version: ["3.10", "3.11", "3.12"]
40+
41+
steps:
42+
- uses: actions/checkout@v4
43+
44+
- name: Set up Python ${{ matrix.python-version }}
45+
uses: actions/setup-python@v5
46+
with:
47+
python-version: ${{ matrix.python-version }}
48+
cache: "pip"
2649

2750
- name: Install dependencies
2851
run: |
2952
python -m pip install --upgrade pip
3053
pip install -r requirements.txt
3154
32-
- name: Lint with flake8
33-
run: |
34-
pip install flake8
35-
# Stop the build if there are Python syntax errors or undefined names
36-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
37-
# Treat all other issues as warnings (non-blocking)
38-
flake8 . --count --exit-zero --max-line-length=100 --statistics
55+
- name: Run tests with coverage
56+
env:
57+
OPENAI_API_KEY: "offline-mode-no-key-required"
58+
run: pytest test_chatbot.py -v --tb=short --cov=. --cov-report=xml
3959

40-
- name: Run tests
41-
run: pytest test_chatbot.py -v
60+
- name: Upload coverage report
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: coverage-${{ matrix.python-version }}
64+
path: coverage.xml
4265

4366
docker-build:
67+
needs: test
4468
runs-on: ubuntu-latest
45-
needs: lint-and-test
46-
permissions:
47-
contents: read
4869

4970
steps:
5071
- uses: actions/checkout@v4

api.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ def clear_all_sessions() -> None:
5454

5555
def _get_or_create_session(session_id: Optional[str]) -> tuple[str, ChatBot]:
5656
"""Return (session_id, ChatBot) for the given session; create if missing."""
57-
global _default_bot
58-
5957
if session_id is None:
6058
# Create a new session
6159
session_id = str(uuid.uuid4())

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ uvicorn[standard]>=0.23.0
1414

1515
# Testing
1616
pytest>=7.4.0
17+
pytest-cov>=4.0.0
1718
httpx>=0.25.0

0 commit comments

Comments
 (0)