Skip to content

Commit 60e2b10

Browse files
richdawe-cioclaude
andauthored
Modernize Python CI and packaging (#7)
* Dependabot * Modernise GH workflows * Switch to pyproject.toml * Switch to core unittest.mock * Remove support for Python 3.8 * Try to avoid Bugbot drip on code reviews * Read runtime version from package metadata instead of hardcoding * Upgrade flake8 to fix Python 3.14 compatibility flake8 3.7.9's pyflakes dependency uses ast.Str, which was removed in Python 3.14, causing "module 'ast' has no attribute 'Str'" in CI. --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent dccaa90 commit 60e2b10

13 files changed

Lines changed: 173 additions & 85 deletions

File tree

.cursor/BUGBOT.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Bugbot Review Rules
2+
3+
## Core Principle: Comprehensive First-Pass Reviews
4+
5+
**CRITICAL INSTRUCTION**: You must perform a complete, exhaustive analysis on the FIRST review of any changeset. Do NOT hold back observations or defer issues to later reviews. All feedback must be provided upfront.
6+
7+
## Expected Behavior
8+
9+
Your first review should be comprehensive enough that subsequent reviews only need to address newly changed code. The goal is to eliminate "surprise" feedback on code that was part of the initial changeset but somehow escaped earlier review.
10+

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: "/"
5+
schedule:
6+
interval: weekly
7+
8+
- package-ecosystem: pip
9+
directory: "/"
10+
schedule:
11+
interval: weekly

.github/workflows/build.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
package:
15+
name: Build distribution
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v7
19+
with:
20+
fetch-depth: 0
21+
- name: Set up Python
22+
uses: actions/setup-python@v6
23+
with:
24+
python-version: "3.14"
25+
cache: pip
26+
cache-dependency-path: pyproject.toml
27+
- name: Install build tools
28+
run: |
29+
python -m pip install --upgrade pip
30+
python -m pip install -e ".[dev]"
31+
- name: Build and verify package
32+
run: |
33+
python -m build
34+
python -m twine check dist/*

.github/workflows/lint.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
name: Lint
22

3-
on: [push]
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
412

513
jobs:
614
lint:
15+
name: Lint
16+
717
runs-on: ubuntu-latest
818

919
steps:
1020
- uses: actions/checkout@v6
1121

1222
- uses: actions/setup-python@v6
1323
with:
14-
python-version: "3.10"
24+
python-version: "3.14"
1525
cache: 'pip'
16-
cache-dependency-path: setup.py
26+
cache-dependency-path: pyproject.toml
1727

18-
- run: pip3 install -e '.[test]'
19-
- run: make lint-ci
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
python -m pip install -e ".[dev]"
32+
- name: Run lint
33+
run: make lint-ci

.github/workflows/test.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
name: Test
22

3-
on: [push]
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
412

513
jobs:
614
test:
15+
name: Test Python ${{ matrix.python-version }}
16+
717
runs-on: ubuntu-latest
818

919
strategy:
1020
fail-fast: false
1121
matrix:
12-
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" ]
22+
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" ]
1323

1424
steps:
1525
- uses: actions/checkout@v6
@@ -18,7 +28,11 @@ jobs:
1828
with:
1929
python-version: ${{ matrix.python-version }}
2030
cache: 'pip'
21-
cache-dependency-path: setup.py
31+
cache-dependency-path: pyproject.toml
2232

23-
- run: pip3 install -e '.[test]'
24-
- run: make test
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
python -m pip install -e .
37+
- name: Run tests
38+
run: make test

Makefile

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
1+
PYTHON ?= python3
2+
13
install:
2-
pip install --edit .[test]
4+
$(PYTHON) -m pip install -e ".[dev]"
5+
6+
build:
7+
rm -rf build
8+
$(PYTHON) -m build
39

410
test:
5-
python -m unittest customerio/analytics/test/*.py -v
11+
$(PYTHON) -m unittest customerio/analytics/test/*.py -v
612

713
lint:
8-
pylint --rcfile=.pylintrc --reports=y --exit-zero customerio/analytics
9-
flake8 --max-complexity=10 --statistics --exit-zero customerio/analytics
14+
$(PYTHON) -m pylint --rcfile=.pylintrc --reports=y --exit-zero customerio/analytics
15+
$(PYTHON) -m flake8 --max-complexity=10 --statistics --exit-zero customerio/analytics
1016

1117
lint-ci:
12-
pylint --rcfile=.pylintrc --exit-zero --fail-on=E customerio/analytics
13-
flake8 --max-complexity=10 --max-line-length=100 --statistics customerio/analytics
18+
$(PYTHON) -m pylint --rcfile=.pylintrc --exit-zero --fail-on=E customerio/analytics
19+
$(PYTHON) -m flake8 --max-complexity=10 --max-line-length=100 --statistics customerio/analytics
1420

1521
clean:
22+
rm -rf MANIFEST build dist customerio.egg-info
23+
24+
clean-venv:
1625
rm -rf .venv
1726
mise deps
1827

19-
.PHONY: install test lint lint-ci clean
28+
.PHONY: install build test lint lint-ci clean clean-venv

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ analytics.track(user_id=4, event='order_complete')
2525

2626
## Other Regions
2727

28-
If you're using a [different data center](https://customer.io/docs/accounts-and-workspaces/data-centers/) such as our EU region, you can specify an alternate endpoint:
28+
If you're using a [different data center](https://docs.customer.io/accounts/settings/data-centers/) such as our EU region, you can specify an alternate endpoint:
2929

3030
```python
3131
from customerio import analytics

customerio/analytics/test/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from datetime import date, datetime
22
import unittest
3+
import unittest.mock as mock
34
import time
4-
import mock
55

66
from customerio.analytics.version import VERSION
77
from customerio.analytics.client import Client

customerio/analytics/test/consumer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import json
22
import time
33
import unittest
4-
5-
import mock
4+
import unittest.mock as mock
65

76
try:
87
from queue import Queue

customerio/analytics/version.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
VERSION = '1.0.0'
1+
from importlib.metadata import version
2+
3+
VERSION = version("customerio_cdp_analytics")

0 commit comments

Comments
 (0)