-
Notifications
You must be signed in to change notification settings - Fork 14
75 lines (60 loc) · 1.94 KB
/
python-package.yml
File metadata and controls
75 lines (60 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Python package
permissions:
contents: read
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
# Simplified to single Python version (per project requirements)
# Can expand to matrix testing later: strategy.matrix.python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 black build diff-cover
python -m pip install -e .[dev]
- name: Check format with black
run: |
black src tests examples --check
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings, matching Agents-for-python approach
flake8 . --count --exit-zero --show-source --statistics
- name: Build package
run: |
python -m build
- name: Install wheel
run: |
python -m pip install dist/*.whl
- name: Test with pytest
run: |
PYTHONPATH=src pytest --junitxml=test-results.xml --cov --cov-report=xml
- name: Diff coverage (90% for new changes)
run: |
git fetch origin ${{ github.base_ref }}
diff-cover coverage.xml --compare-branch=origin/${{ github.base_ref }} --fail-under=90
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: test-results.xml
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.xml