Skip to content

Test refactoring

Test refactoring #294

Workflow file for this run

name: Python package
on:
push:
branches:
- master
pull_request:
branches:
- master
env:
LATEST_PY_VERSION: '3.10'
REDIS: 'redis://localhost:6379'
jobs:
check:
runs-on: ubuntu-latest
services:
pyrate_redis:
image: bitnami/redis:latest
env:
ALLOW_EMPTY_PASSWORD: yes
ports:
- 6379:6379
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
pyrate_postgres:
image: bitnami/postgresql
env:
ALLOW_EMPTY_PASSWORD: yes
POSTGRESQL_PASSWORD: postgres
POSTGRESQL_MAX_CONNECTIONS: 1000
ports:
- 5432:5432
strategy:
fail-fast: true
matrix:
python-version: ["3.8", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- uses: snok/install-poetry@v1.3
with:
virtualenvs-in-project: true
# Cache packages per python version, and reuse until lockfile changes
# TODO: For some strange reason, virtualenvs restored from the cache will sometimes be
# missing a python interpreter. Just disabling the cache for now.
# - name: Cache python packages
# id: cache
# uses: actions/cache@v3
# with:
# path: .venv
# key: venv-${{ matrix.python-version }}-latest-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
# if: steps.cache.outputs.cache-hit != 'true'
run: poetry install -v -E all
# Run linting, tests, and coverage
- name: Lint
run: |
source $VENV
nox -e lint
- name: Test and Coverage
run: |
source $VENV
nox -e cover
# Latest python version: send coverage report to codecov
- name: "Upload coverage report to Codecov"
if: ${{ matrix.python-version == env.LATEST_PY_VERSION }}
uses: codecov/codecov-action@v2
publish:
needs: check
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ env.LATEST_PY_VERSION }}
uses: actions/setup-python@v3
with:
python-version: ${{ env.LATEST_PY_VERSION }}
- uses: snok/install-poetry@v1.3
with:
virtualenvs-in-project: true
- name: Install dependencies
run: poetry install -v -E all
- name: Publish
run: |
poetry config http-basic.pypi ${{ secrets.PYPI_USERNAME }} ${{ secrets.PYPI_PASSWORD }}
poetry build
poetry publish