Skip to content

Commit

Permalink
feat: Add ability to send transactional Push Notifications (#15)
Browse files Browse the repository at this point in the history
* feat: Add ability to send transactional Push Notifications
  • Loading branch information
akalex authored Dec 6, 2023
1 parent ba4ba9c commit 41cb7d6
Show file tree
Hide file tree
Showing 8 changed files with 235 additions and 74 deletions.
41 changes: 19 additions & 22 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
POETRY_VERSION: 1.5.1

jobs:
create-virtualenv:
runs-on: ubuntu-latest
Expand All @@ -20,29 +23,26 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4

- name: virtualenv cache
uses: syphar/[email protected]
id: cache-virtualenv
- name: Install Poetry
uses: snok/install-poetry@v1
with:
custom_cache_key_element: v1.2
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true

- name: pip cache
uses: syphar/restore-pip-download-cache@v1
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install Python dependencies
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
env:
POETRY_VERSION: 1.2.2
run: |
pip install pip==22.3 setuptools==65.5.0
curl -sSL https://install.python-poetry.org | python3 -
export VENV="$(poetry env info -p)"
source ${VENV}/bin/activate
poetry install --no-interaction
- name: Install Dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction -vv

- name: Log currently installed packages and versions
run: pip list
run: poetry show

release:
needs: create-virtualenv
Expand All @@ -60,11 +60,8 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
POETRY_VERSION: 1.2.2
POETRY_VERSION: ${{ env.POETRY_VERSION }}
run: |
pip install pip==22.3 setuptools==65.5.0
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
poetry build
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish
116 changes: 78 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
POETRY_VERSION: 1.5.1

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
create-virtualenv:
Expand All @@ -30,34 +33,31 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: virtualenv cache
uses: syphar/[email protected]
id: cache-virtualenv
- name: Install Poetry
uses: snok/install-poetry@v1
with:
custom_cache_key_element: v1.2
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true

- name: pip cache
uses: syphar/restore-pip-download-cache@v1
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install Python dependencies
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
env:
POETRY_VERSION: 1.2.2
run: |
pip install pip==22.3 setuptools==65.5.0
curl -sSL https://install.python-poetry.org | python3 -
export VENV="$(poetry env info -p)"
source ${VENV}/bin/activate
poetry install --no-interaction -vv
- name: Install Dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction -vv

- name: Log currently installed packages and versions
run: pip list
run: poetry show

linters-black:
needs: create-virtualenv
Expand All @@ -67,16 +67,30 @@ jobs:
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: virtualenv cache
uses: syphar/[email protected]
id: cache-virtualenv
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
custom_cache_key_element: v1.2
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Check code style
run: black --check --line-length=120 --diff async_customerio
run: poetry run black --check --line-length=120 --diff async_customerio

linters-mypy:
needs: create-virtualenv
Expand All @@ -86,18 +100,32 @@ jobs:
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: virtualenv cache
uses: syphar/[email protected]
id: cache-virtualenv
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
custom_cache_key_element: v1.2
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Static type checker
run: |
python -m pip install types-setuptools
mypy --install-types --no-error-summary --hide-error-codes --follow-imports=skip async_customerio
poetry run mypy --install-types --no-error-summary --hide-error-codes --follow-imports=skip async_customerio
test:
needs: [ linters-black, linters-mypy ]
Expand All @@ -110,18 +138,30 @@ jobs:
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: virtualenv cache
uses: syphar/[email protected]
id: cache-virtualenv
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
custom_cache_key_element: v1.2
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Run pytest
run: pytest tests/
run: poetry run pytest tests/

- name: Submit coverage report
if: github.ref == 'refs/heads/master'
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog

## 1.2.0
- Added support of sending transactional push notifications. More details of how to send Push Notifications via CustomerIO https://customer.io/docs/journeys/transactional-api/#transactional-push-notifications

## 1.1.0
- Added helper function for validation of request origin using X-CIO-Signature and X-CIO-Timestamps
Expand Down
2 changes: 1 addition & 1 deletion async_customerio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from async_customerio.api import AsyncAPIClient, SendEmailRequest # noqa
from async_customerio.api import AsyncAPIClient, SendEmailRequest, SendPushRequest # noqa
from async_customerio.errors import AsyncCustomerIOError # noqa
from async_customerio.regions import Regions # noqa
from async_customerio.request_validator import validate_signature # noqa
Expand Down
Loading

0 comments on commit 41cb7d6

Please sign in to comment.