Skip to content

Commit 07b711c

Browse files
committed
ci: add GitHub Actions workflows for CI/CD
- Add CI workflow for testing across Python 3.8-3.12 - Include linting, type checking, and test coverage - Add release workflow for PyPI publishing - Configure Dependabot for dependency updates - Set up caching for faster builds
1 parent d4c4343 commit 07b711c

File tree

3 files changed

+138
-0
lines changed

3 files changed

+138
-0
lines changed

.github/dependabot.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
open-pull-requests-limit: 10
8+
reviewers:
9+
- "jdrhyne"
10+
labels:
11+
- "dependencies"
12+
- "python"
13+
14+
- package-ecosystem: "github-actions"
15+
directory: "/"
16+
schedule:
17+
interval: "weekly"
18+
open-pull-requests-limit: 10
19+
reviewers:
20+
- "jdrhyne"
21+
labels:
22+
- "dependencies"
23+
- "github-actions"

.github/workflows/ci.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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/

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Set up Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.11'
18+
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install build twine
23+
24+
- name: Build package
25+
run: python -m build
26+
27+
- name: Publish to PyPI
28+
env:
29+
TWINE_USERNAME: __token__
30+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
31+
run: twine upload dist/*

0 commit comments

Comments
 (0)