-
Notifications
You must be signed in to change notification settings - Fork 42
Modernize Python CI and packaging #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9107693
fix ci
hownowstephen b07e0d1
whoop
hownowstephen 50dbd1e
Modernize Python CI and packaging
hownowstephen a253be4
Merge remote-tracking branch 'origin/main' into ci-fixes
hownowstephen c57a670
Exclude tests from source distribution
hownowstephen 17f3960
Avoid duplicate PR CI runs
hownowstephen 8db8bec
Merge branch 'main' into ci-fixes
hownowstephen c77bd64
Bump Ruff and fix merge markers
hownowstephen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: github-actions | ||
| directory: "/" | ||
| schedule: | ||
| interval: weekly | ||
|
|
||
| - package-ecosystem: pip | ||
| directory: "/" | ||
| schedule: | ||
| interval: weekly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,78 @@ | ||
| name: build | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build: | ||
| lint: | ||
| name: Lint and format | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.14" | ||
| cache: pip | ||
| cache-dependency-path: pyproject.toml | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install -e ".[dev]" | ||
| - name: Run ruff | ||
| run: | | ||
| python -m ruff check . | ||
| python -m ruff format --check . | ||
|
|
||
| test: | ||
| name: Test Python ${{ matrix.python-version }} | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| python: [ '3.9', '3.10', '3.11', '3.12', '3.13' ] | ||
| python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| cache: pip | ||
| cache-dependency-path: pyproject.toml | ||
| - name: Install package | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install -e . | ||
| - name: Run tests | ||
| run: make test | ||
|
|
||
| package: | ||
| name: Build distribution | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5.6.0 | ||
| with: | ||
| python-version: ${{ matrix.python }} | ||
| - name: install dependencies for the minor version | ||
| run: | | ||
| python -m venv venv | ||
| . venv/bin/activate | ||
| pip install -r requirements.txt | ||
| - name: run tests | ||
| run: | | ||
| . venv/bin/activate | ||
| make test | ||
| deactivate | ||
| - name: reinstall to the latest version | ||
| run: | | ||
| python -m venv venv | ||
| . venv/bin/activate | ||
| pip install --upgrade requests | ||
| - name: run tests again | ||
| run: | | ||
| . venv/bin/activate | ||
| make test | ||
| - uses: actions/checkout@v6 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.14" | ||
| cache: pip | ||
| cache-dependency-path: pyproject.toml | ||
| - name: Install build tools | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install -e ".[dev]" | ||
| - name: Build and verify package | ||
| run: | | ||
| python -m build | ||
| python -m twine check dist/* | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| *.pyc | ||
| *.pyo | ||
| .venv/ | ||
| .coverage | ||
| .ruff_cache/ | ||
| .pytest_cache/ | ||
| tests/server.pem | ||
| dist | ||
| customerio.egg-info | ||
| .DS_Store | ||
| MANIFEST | ||
| build/ | ||
| setup.cfg | ||
| setup.cfg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| prune tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,37 @@ | ||
| PYTHON ?= python3 | ||
| OPENSSL ?= openssl | ||
| SERVER_CERT := tests/server.pem | ||
|
|
||
| all: | ||
| $(PYTHON) setup.py sdist | ||
| all: build | ||
| $(PYTHON) -m doctest ./customerio/__init__.py | ||
|
|
||
| install: | ||
| $(PYTHON) setup.py install | ||
| $(PYTHON) -m pip install . | ||
|
|
||
| clean: | ||
| $(PYTHON) setup.py clean | ||
| rm -rf MANIFEST build dist | ||
| rm -rf MANIFEST build dist customerio.egg-info .ruff_cache | ||
|
|
||
| dev: clean all | ||
| if ! pip uninstall customerio; then echo "customerio not installed, installing it for the first time" ; fi | ||
| pip install dist/* | ||
| $(PYTHON) -i -c "from customerio import *" | ||
|
|
||
| upload: | ||
| $(PYTHON) setup.py register | ||
| echo "*** Now upload the binary to PyPi *** (one second)" && sleep 3 && open dist & open "http://pypi.python.org/pypi?%3Aaction=pkg_edit&name=customerio" # python setup.py upload | ||
| $(PYTHON) -m twine upload dist/* | ||
|
|
||
| test: | ||
| openssl req -new -newkey rsa:2048 -days 10 -nodes -x509 -subj "/C=CA/ST=Ontario/L=Toronto/O=Test/CN=127.0.0.1" -keyout ./tests/server.pem -out ./tests/server.pem | ||
| build: | ||
| $(PYTHON) -m build | ||
|
|
||
| lint: | ||
| $(PYTHON) -m ruff check . | ||
| $(PYTHON) -m ruff format --check . | ||
|
|
||
| format: | ||
| $(PYTHON) -m ruff check --fix . | ||
| $(PYTHON) -m ruff format . | ||
|
|
||
| test: $(SERVER_CERT) | ||
| $(PYTHON) -m unittest discover -v | ||
|
|
||
| $(SERVER_CERT): | ||
| $(OPENSSL) req -new -newkey rsa:2048 -days 10 -nodes -x509 -subj "/C=CA/ST=Ontario/L=Toronto/O=Test/CN=127.0.0.1" -keyout $(SERVER_CERT) -out $(SERVER_CERT) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,23 @@ | ||
| import warnings | ||
|
|
||
| from customerio.api import ( | ||
| APIClient, | ||
| SendEmailRequest, | ||
| SendInAppRequest, | ||
| SendInboxMessageRequest, | ||
| SendPushRequest, | ||
| SendSMSRequest, | ||
| ) | ||
| from customerio.client_base import CustomerIOException | ||
| from customerio.track import CustomerIO | ||
| from customerio.api import APIClient, SendEmailRequest, SendPushRequest, SendSMSRequest, SendInboxMessageRequest, SendInAppRequest | ||
| from customerio.regions import Regions | ||
| from customerio.track import CustomerIO | ||
|
|
||
| __all__ = [ | ||
| "APIClient", | ||
| "CustomerIO", | ||
| "CustomerIOException", | ||
| "Regions", | ||
| "SendEmailRequest", | ||
| "SendInAppRequest", | ||
| "SendInboxMessageRequest", | ||
| "SendPushRequest", | ||
| "SendSMSRequest", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1 @@ | ||
| VERSION = (2, 4, 0, 'final', 0) | ||
|
|
||
| def get_version(): | ||
| version = '%s.%s' % (VERSION[0], VERSION[1]) | ||
| if VERSION[2]: | ||
| version = '%s.%s' % (version, VERSION[2]) | ||
| if VERSION[3:] == ('alpha', 0): | ||
| version = '%s-pre-alpha' % version | ||
| else: | ||
| if VERSION[3] != 'final': | ||
| version = '%s-%s-%s' % (version, VERSION[3], VERSION[4]) | ||
| return version | ||
|
|
||
| __version__=get_version() | ||
| __version__ = "2.4.0" | ||
|
hownowstephen marked this conversation as resolved.
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.