Skip to content

Commit 61c172f

Browse files
added githu actions CI
1 parent fb44c7f commit 61c172f

File tree

3 files changed

+108
-3
lines changed

3 files changed

+108
-3
lines changed

.github/workflows/tests.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
branches: [ "**" ]
6+
pull_request:
7+
8+
# optional: cancel older runs on the same branch
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
pytest:
15+
name: Pytest (Linux, Py${{ matrix.python-version }})
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
python-version: ["3.9", "3.10", "3.11", "3.12"]
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
cache: pip
31+
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install -e ".[dev]"
36+
37+
- name: Run tests (with coverage)
38+
run: |
39+
python -m pytest -q --cov=example_lib --cov-report=term --cov-report=html
40+
41+
- name: Upload HTML coverage
42+
if: always()
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: htmlcov-${{ matrix.python-version }}
46+
path: htmlcov
47+
if-no-files-found: ignore
48+
49+
lint:
50+
name: Pre-commit
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v4
54+
- name: Set up Python
55+
uses: actions/setup-python@v5
56+
with:
57+
python-version: "3.11"
58+
cache: pip
59+
- name: Install pre-commit
60+
run: |
61+
python -m pip install --upgrade pip
62+
pip install pre-commit
63+
- name: Run pre-commit
64+
run: |
65+
pre-commit run --all-files || true

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,12 @@ docs/_build/
7373
# Ignore build artifacts created by editable installs
7474
*.egg-link
7575

76+
# Ruff
77+
.ruff_cache/
78+
7679
# Keep track of any project-specific ignores below
7780
# e.g. experiments/data/, notebooks/data/, etc.
81+
82+
83+
# Pytest coverage test report dir
84+
htmlcov

pyproject.toml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ build-backend = "setuptools.build_meta"
55
[project]
66
name = "example-lib"
77
version = "0.1.0"
8-
description = "Mini calculator library"
8+
description = "Mini calculator library showcasing clean code, testing, and packaging."
99
readme = "README.md"
1010
requires-python = ">=3.8"
11-
authors = [{ name = "Andrea" }]
11+
authors = [{ name = "Andrea Scaglioni", email = "[email protected]" }]
12+
keywords = ["example", "template", "project-template", "pytest", "sphinx", "CI/CD"]
1213
license = { text = "MIT" }
1314
dependencies = []
1415

@@ -18,9 +19,41 @@ classifiers = [
1819
"Operating System :: OS Independent",
1920
]
2021

22+
23+
# --- PyTest Options
24+
[tool.pytest.ini_options]
25+
testpaths = ["tests"]
26+
addopts = "
27+
-q
28+
--strict-markers
29+
--disable-warnings
30+
--cov=src
31+
--cov-report=term-missing
32+
--cov-fail-under=85
33+
"
34+
markers = [
35+
"integration: marks integration tests (deselect with '-m \"not integration\"')",
36+
"slow: marks slow tests",
37+
]
38+
39+
40+
# --- Optional dependencies for development, docs, etc.
2141
[project.optional-dependencies]
22-
dev = ["pytest", "pytest-cov"]
42+
dev = [
43+
"pytest",
44+
"pytest-cov",
45+
"pre-commit",
46+
"black",
47+
"ruff",
48+
"mypy",
49+
]
50+
51+
docs = [
52+
"sphinx>=7.0"
53+
]
54+
2355

56+
# --- SetUpTool options
2457
[tool.setuptools]
2558
package-dir = {"" = "src"}
2659

0 commit comments

Comments
 (0)