Skip to content

Commit 7c0bdb2

Browse files
committed
ci: add GitHub Actions workflows
- ci.yml: Tests on Python 3.9-3.12, Linux/Windows/macOS - ci.yml: Linting with Ruff, Black, MyPy - ci.yml: Build and package verification - publish.yml: Auto-publish to PyPI on release
1 parent 9feabad commit 7c0bdb2

2 files changed

Lines changed: 125 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-latest, windows-latest, macos-latest]
16+
python-version: ["3.9", "3.10", "3.11", "3.12"]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install -e ".[dev]"
30+
31+
- name: Run tests
32+
run: pytest --tb=short -q
33+
34+
- name: Run tests with coverage
35+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
36+
run: pytest --cov=trueentropy --cov-report=xml
37+
38+
- name: Upload coverage
39+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
40+
uses: codecov/codecov-action@v3
41+
with:
42+
file: ./coverage.xml
43+
fail_ci_if_error: false
44+
45+
lint:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
50+
- name: Set up Python
51+
uses: actions/setup-python@v5
52+
with:
53+
python-version: "3.11"
54+
55+
- name: Install dependencies
56+
run: |
57+
python -m pip install --upgrade pip
58+
pip install ruff black mypy
59+
60+
- name: Run Ruff
61+
run: ruff check src/
62+
63+
- name: Run Black
64+
run: black --check src/
65+
66+
- name: Install for type checking
67+
run: pip install -e ".[dev]"
68+
69+
- name: Run MyPy
70+
run: mypy src/trueentropy --ignore-missing-imports
71+
continue-on-error: true
72+
73+
build:
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/checkout@v4
77+
78+
- name: Set up Python
79+
uses: actions/setup-python@v5
80+
with:
81+
python-version: "3.11"
82+
83+
- name: Install build tools
84+
run: pip install build twine
85+
86+
- name: Build package
87+
run: python -m build
88+
89+
- name: Check package
90+
run: twine check dist/*
91+
92+
- name: Upload artifacts
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: dist
96+
path: dist/

.github/workflows/publish.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
environment: pypi
11+
permissions:
12+
id-token: write
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.11"
21+
22+
- name: Install build tools
23+
run: pip install build
24+
25+
- name: Build package
26+
run: python -m build
27+
28+
- name: Publish to PyPI
29+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)