1+ name : CI
2+
3+ on :
4+ push :
5+ branches : [ main, develop ]
6+ pull_request :
7+ branches : [ main, develop ]
8+
9+ jobs :
10+ test :
11+ runs-on : ubuntu-latest
12+ strategy :
13+ matrix :
14+ python-version : ['3.8', '3.9', '3.10', '3.11', '3.12']
15+
16+ steps :
17+ - uses : actions/checkout@v4
18+
19+ - name : Set up Python ${{ matrix.python-version }}
20+ uses : actions/setup-python@v5
21+ with :
22+ python-version : ${{ matrix.python-version }}
23+
24+ - name : Cache pip dependencies
25+ uses : actions/cache@v4
26+ with :
27+ path : ~/.cache/pip
28+ key : ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
29+ restore-keys : |
30+ ${{ runner.os }}-pip-
31+
32+ - name : Install dependencies
33+ run : |
34+ python -m pip install --upgrade pip
35+ pip install -e ".[dev]"
36+
37+ - name : Run linting with ruff
38+ run : |
39+ ruff check .
40+ ruff format --check .
41+
42+ - name : Run type checking with mypy
43+ run : mypy src tests
44+
45+ - name : Run tests with pytest
46+ run : pytest -v --cov=nutrient --cov-report=xml --cov-report=term
47+
48+ - name : Upload coverage to Codecov
49+ uses : codecov/codecov-action@v4
50+ with :
51+ token : ${{ secrets.CODECOV_TOKEN }}
52+ file : ./coverage.xml
53+ flags : unittests
54+ name : codecov-umbrella
55+ fail_ci_if_error : false
56+
57+ build :
58+ runs-on : ubuntu-latest
59+ needs : test
60+
61+ steps :
62+ - uses : actions/checkout@v4
63+
64+ - name : Set up Python
65+ uses : actions/setup-python@v5
66+ with :
67+ python-version : ' 3.11'
68+
69+ - name : Install build dependencies
70+ run : |
71+ python -m pip install --upgrade pip
72+ pip install build twine
73+
74+ - name : Build package
75+ run : python -m build
76+
77+ - name : Check package with twine
78+ run : twine check dist/*
79+
80+ - name : Upload artifacts
81+ uses : actions/upload-artifact@v4
82+ with :
83+ name : dist
84+ path : dist/
0 commit comments