Skip to content

Commit bf66198

Browse files
authored
Merge pull request #37 from RafaelJohn9/ci
CI updates
2 parents b5d6eec + 8f5cfa8 commit bf66198

8 files changed

Lines changed: 101 additions & 21 deletions

File tree

.github/workflows/code-quality.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
run: uv pip install -e '.[dev]'
3737

3838
- name: Run Ruff
39-
run: uv run ruff check mpesa_sdk
39+
run: uv run ruff check mpesa_sdk && uv run ruff check tests
4040

4141
mypy:
4242
runs-on: ubuntu-latest

.github/workflows/publish.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Publish Python Package
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*" # publish only on version tags like v0.1.0
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.12"
20+
21+
- name: Install Hatch
22+
run: pip install hatch
23+
24+
- name: Build package
25+
run: hatch build
26+
27+
- name: Publish to PyPI
28+
env:
29+
HATCH_INDEX_USER: __token__
30+
HATCH_INDEX_AUTH: ${{ secrets.PYPI_API_TOKEN }}
31+
run: hatch publish

.github/workflows/tests.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Run Unit Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
workflow_dispatch: # Allows manual triggering of the workflow
8+
9+
jobs:
10+
unit-tests:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.12'
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install ".[dev,test]"
26+
pip install pytest
27+
pip install -e .
28+
29+
- name: Run unit tests
30+
run: |
31+
pytest tests/unit

pyproject.toml

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dynamic = ["version"]
88
description = "A Python SDK for integrating with M-Pesa APIs"
99
readme = "README.md"
1010
license = { text = "APACHE-2.0" }
11-
requires-python = ">=3.10"
11+
requires-python = ">=3.12"
1212
authors = [
1313
{ name = "John Kagunda", email = "johnmkagunda@gmail.com" }
1414
]
@@ -19,43 +19,59 @@ classifiers = [
1919
"Development Status :: 4 - Beta",
2020
"Intended Audience :: Developers",
2121
"License :: OSI Approved :: Apache Software License",
22-
"Programming Language :: Python :: 3.10",
23-
"Programming Language :: Python :: 3.11",
2422
"Programming Language :: Python :: 3.12",
2523
"Operating System :: OS Independent",
2624
"Topic :: Software Development :: Libraries :: Python Modules",
2725
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
2826
"Typing :: Typed"
2927
]
30-
keywords = ["mpesa", "sdk", "payment", "africa", "flask", "django", "fastapi", "rest", "api"]
31-
urls = { Homepage = "https://github.com/rafaeljohn9/mpesa-daraja-sdk", Repository = "https://github.com/rafaeljohn9/mpesa-daraja-sdk" }
28+
keywords = [
29+
"mpesa",
30+
"sdk",
31+
"payment",
32+
"africa",
33+
"flask",
34+
"django",
35+
"fastapi",
36+
"rest",
37+
"api",
38+
"mobile money",
39+
"payments",
40+
]
41+
42+
dependencies = [
43+
"pydantic >=2.10.6,<3.0.0",
44+
"pydantic[email] >=2.10.6,<3.0.0",
45+
"requests >=2.32.3,<3.0.0",
46+
"typing_extensions >= 4.12.2,<5.0.0"
47+
]
48+
49+
[project.urls]
50+
Homepage = "https://github.com/rafaeljohn9/mpesa-sdk"
51+
Repository = "https://github.com/rafaeljohn9/mpesa-sdk"
52+
Issues = "https://github.com/rafaeljohn9/mpesa-sdk/issues"
53+
3254

3355
[project.optional-dependencies]
3456
dev = [
35-
"bandit",
3657
"build",
3758
"coverage",
3859
"hatch",
3960
"hatch-vcs",
4061
"hatchling",
4162
"mypy",
42-
"pydantic",
63+
"bandit",
4364
"pytest",
4465
"pytest-cov",
45-
"requests",
4666
"ruff",
4767
"types-requests"
4868
]
49-
install = [
50-
"pydantic",
51-
"requests"
52-
]
5369
test = [
70+
"bandit",
71+
"mypy",
5472
"pyngrok",
5573
"pytest",
5674
"pytest-cov",
57-
"requests",
58-
"pydantic",
5975
"types-requests"
6076
]
6177

@@ -71,13 +87,18 @@ include = [
7187
[tool.hatch.build.targets.wheel]
7288
packages = ["mpesa_sdk"]
7389

74-
# Ruff configuration
90+
# Ruff configuration-sdk/is
7591
[tool.ruff]
7692
target-version = "py312"
7793
fix = true
7894

7995
[tool.ruff.lint]
80-
select = ["D", "E", "W", "F"] # Enable docstring checks, pycodestyle errors, and warnings
96+
select = [
97+
"D", # pydocstyle
98+
"E", # pycodestyle errors
99+
"W", # pycodestyle warnings
100+
"F" # pyflakes
101+
]
81102
ignore = [
82103
"D104", # Missing docstring in public package
83104
"D105", # Missing docstring in magic method

tests/integration/auth/test_token_manager_e2e.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ def test_force_refresh_token(valid_credentials, http_client):
7070
consumer_secret=valid_credentials["consumer_secret"],
7171
http_client=http_client,
7272
)
73-
token1 = tm.get_token()
7473
token2 = tm.get_token(force_refresh=True)
7574
assert isinstance(token2, str)
7675
# Token may or may not change, but should be valid

tests/integration/bill_manager/test_bill_integration_e2e.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ def test_bill_manager_opt_in_e2e(bill_manager_service):
3939
print("🔗 Starting E2E Test: Bill Manager Opt-In")
4040

4141
shortcode = os.getenv("MPESA_BILL_MANAGER_SHORTCODE", "600999")
42-
organization_name = os.getenv("MPESA_BILL_MANAGER_ORG_NAME", "TestOrg")
43-
contact_person = os.getenv("MPESA_BILL_MANAGER_CONTACT_PERSON", "John Doe")
4442
contact_email = os.getenv("MPESA_BILL_MANAGER_CONTACT_EMAIL", "john@example.com")
4543
contact_phone = os.getenv("MPESA_BILL_MANAGER_CONTACT_PHONE", "254700000000")
4644
callbackurl = os.getenv(

tests/unit/B2C/test_B2C.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ def test_b2c_request_occasion_too_long_raises():
225225

226226

227227
def make_result_parameters(params):
228+
"""Helper to create list of B2CResultParameter from dict."""
228229
return [B2CResultParameter(Key=k, Value=v) for k, v in params.items()]
229230

230231

tests/unit/services/test_ratiba_service.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from mpesa_sdk.auth import TokenManager
77
from mpesa_sdk.http_client import HttpClient
88
from mpesa_sdk.mpesa_ratiba import (
9-
StandingOrderRequest,
109
StandingOrderResponse,
1110
TransactionTypeEnum,
1211
ReceiverPartyIdentifierTypeEnum,

0 commit comments

Comments
 (0)