|
6 | 6 | pull_request: |
7 | 7 | branches: ["main", "master"] |
8 | 8 |
|
9 | | -# Restrict default GITHUB_TOKEN permissions to read-only |
10 | 9 | permissions: |
11 | 10 | contents: read |
12 | 11 |
|
13 | 12 | jobs: |
14 | | - lint-and-test: |
| 13 | + lint: |
15 | 14 | runs-on: ubuntu-latest |
16 | | - permissions: |
17 | | - contents: read |
18 | 15 |
|
19 | 16 | steps: |
20 | 17 | - uses: actions/checkout@v4 |
21 | 18 |
|
22 | | - - name: Set up Python |
| 19 | + - name: Set up Python 3.12 |
23 | 20 | uses: actions/setup-python@v5 |
24 | 21 | with: |
25 | 22 | 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" |
26 | 49 |
|
27 | 50 | - name: Install dependencies |
28 | 51 | run: | |
29 | 52 | python -m pip install --upgrade pip |
30 | 53 | pip install -r requirements.txt |
31 | 54 |
|
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 |
39 | 59 |
|
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 |
42 | 65 |
|
43 | 66 | docker-build: |
| 67 | + needs: test |
44 | 68 | runs-on: ubuntu-latest |
45 | | - needs: lint-and-test |
46 | | - permissions: |
47 | | - contents: read |
48 | 69 |
|
49 | 70 | steps: |
50 | 71 | - uses: actions/checkout@v4 |
|
0 commit comments