Skip to content

Commit

Permalink
Convert packaging config to Poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
JWCook committed May 11, 2021
1 parent 3da5530 commit e3359dc
Show file tree
Hide file tree
Showing 8 changed files with 2,277 additions and 125 deletions.
85 changes: 44 additions & 41 deletions .github/workflows/build.yml
Expand Up @@ -2,13 +2,14 @@ name: Build

on:
push:
branches: [main, dev]
branches: [main, dev, pre-release]
tags: ['v*']
pull_request:
branches: [main, dev]
workflow_dispatch:
env:
LATEST_PY_VERSION: '3.9'
COVERAGE_ARGS: '--cov --cov-report=term --cov-report=html'

jobs:
test:
Expand All @@ -27,6 +28,9 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: snok/install-poetry@v1.1.4
with:
virtualenvs-in-project: true

# Start integration test databases
- uses: supercharge/mongodb-github-action@1.3.0
Expand All @@ -37,33 +41,34 @@ jobs:
redis-version: '6'
- uses: rrainn/dynamodb-action@v2.0.0

# Cache packages per python version, and reuse until setup.py changes
- name: Cache pip packages
# Cache packages per python version, and reuse until lockfile changes
- name: Cache python packages
id: cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
restore-keys: ${{ runner.os }}-pip-${{ matrix.python-version }}
path: .venv
key: venv-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: pip install ".[dev]"
if: steps.cache.outputs.cache-hit != 'true'
run: poetry install -v -E backends

# Latest python version: Run unit tests with coverage and send to coveralls
- name: Run unit tests with code coverage report
if: ${{ matrix.python-version == env.LATEST_PY_VERSION }}
# Run unit tests first to fail quickly if there are issues
run: |
pytest test/unit --cov --cov-report=term --cov-report=html
pytest test/integration --cov --cov-report=term --cov-report=html --cov-append
- name: Send code coverage report to Coveralls
if: ${{ matrix.python-version == env.LATEST_PY_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: coveralls --service=github
run: |
source $VENV
pytest test/unit ${{ env.COVERAGE_ARGS }}
pytest test/integration ${{ env.COVERAGE_ARGS }} --cov-append
pip install coveralls
coveralls --service=github
# All other python versions: just run unit tests
- name: Run unit tests
if: ${{ matrix.python-version != env.LATEST_PY_VERSION }}
run: |
source $VENV
pytest test/unit
pytest test/integration
Expand All @@ -75,49 +80,47 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: ${{ env.LATEST_PY_VERSION }}
- uses: snok/install-poetry@v1.1.4
with:
virtualenvs-in-project: true

# Cache packages for the latest python version, and reuse until setup.py changes
- name: Cache pip packages
# Cache packages and reuse until lockfile changes
- name: Cache python packages
id: cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ env.LATEST_PY_VERSION }}-${{ hashFiles('setup.py') }}
restore-keys: ${{ runner.os }}-pip-${{ env.LATEST_PY_VERSION }}
path: .venv
key: venv-${{ env.LATEST_PY_VERSION }}-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: pip install ".[dev]"
if: steps.cache.outputs.cache-hit != 'true'
run: poetry install -v -E backends

- name: Run style checks
- name: Run style checks, type checks, and linting
run: |
source $VENV
black --check --diff .
isort --check --diff .
- name: Run type checks
run: mypy .
- name: Run linter
run: flake8 aiohttp_client_cache
- name: Test Sphinx documentation build
run: make -C docs all
- name: Test package build
run: |
python setup.py sdist bdist_wheel
twine check dist/*
flake8 aiohttp_client_cache test
mypy .
# Deploy on tags only
release:
needs: [test, analyze]
if: startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/tags/v') || endsWith(github.ref, '/pre-release')
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ env.LATEST_PY_VERSION }}
- uses: snok/install-poetry@v1.1.4
with:
virtualenvs-in-project: true

- name: Install dependencies
run: pip install -U ".[build]"
- name: Build wheel
run: python setup.py sdist bdist_wheel
- name: Deploy to pypi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload dist/*
- name: Set pre-release version number
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run: poetry version $(poetry version -s).dev${GITHUB_RUN_NUMBER}
- name: Build and publish to pypi
run: |
poetry build
poetry publish -u __token__ -p ${{ secrets.PYPI_TOKEN }}
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
@@ -1,12 +1,12 @@
# Contributing Guide

## Dev Installation
To set up for local development:
To set up for local development (requires [poetry](https://python-poetry.org/docs/#installation)):

```bash
$ git clone https://github.com/JWCook/aiohttp-client-cache
$ cd aiohttp-client-cache
$ pip install -Ue ".[dev]"
$ poetry install -E backends -E docs
```

## Pre-commit hooks
Expand Down
5 changes: 3 additions & 2 deletions HISTORY.md
@@ -1,6 +1,6 @@
# History

## 0.4.0 (2021-TBD)
## 0.4.0 (2021-05-TBD)
* Add optional support for the following **request** headers:
* `Cache-Control: max-age`
* `Cache-Control: no-cache`
Expand All @@ -10,7 +10,8 @@
* `Cache-Control: no-store`
* `Expires`
* Add support for HTTP timestamps (RFC 5322) in ``expire_after`` parameters

* Packaging is now handled with Poetry. For users, installation still works the same. For developers,
see [Contributing Guide](https://aiohttp-client-cache.readthedocs.io/en/latest/contributing.html) for details

## 0.3.0 (2021-04-09)
[See all issues & PRs for v0.3](https://github.com/JWCook/aiohttp-client-cache/milestone/2?closed=1)
Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide.rst
Expand Up @@ -192,7 +192,7 @@ revalidate the cache with the new expiration time:

Expiration Precedence
~~~~~~~~~~~~~~~~~~~~~
Expiration can also be set on a per-session, per-URL or per-request basis, in addition to cache
Expiration can be set on a per-session, per-URL, or per-request basis, in addition to cache
headers. When there are multiple values provided for a given request, the following order of
precedence is used:

Expand Down

0 comments on commit e3359dc

Please sign in to comment.