Merge pull request #199 from netomi/fix-test-errors-with-python3.11 #596
This file contains 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
name: Build | |
on: | |
push: | |
branches: [main] | |
tags: ['v*'] | |
pull_request: | |
branches: [main] | |
workflow_dispatch: | |
env: | |
LATEST_PY_VERSION: '3.11' | |
COVERAGE_ARGS: '--cov --cov-report=term --cov-report=xml' | |
XDIST_ARGS: '--numprocesses=auto --dist=loadfile' | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
# Fix the 3.11 version due to this regression introduced in 3.11.5: | |
# https://github.com/python/cpython/issues/109538 | |
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11.4'] | |
services: | |
nginx: | |
image: kennethreitz/httpbin | |
ports: | |
- 80:80 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- uses: snok/install-poetry@v1.3 | |
with: | |
virtualenvs-in-project: true | |
version: 1.5.1 # Poetry 1.6+ isn't compatible with python 3.7 | |
# Start integration test databases | |
- uses: supercharge/mongodb-github-action@1.3.0 | |
with: | |
mongodb-version: 4.4 | |
- uses: supercharge/redis-github-action@1.4.0 | |
with: | |
redis-version: '6' | |
- uses: rrainn/dynamodb-action@v3.0.0 | |
# Cache packages per python version, and reuse until lockfile changes | |
- name: Cache python packages | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: venv-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }} | |
- name: Install dependencies | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: poetry install -v -E all | |
# Run tests with coverage report | |
- name: Run tests | |
run: | | |
source $VENV | |
pytest -rs test/unit ${{ env.XDIST_ARGS }} ${{ env.COVERAGE_ARGS }} | |
pytest -rs test/integration --cov-append ${{ env.XDIST_ARGS }} ${{ env.COVERAGE_ARGS }} | |
# 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 | |
# Run code analysis checks | |
analyze: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.LATEST_PY_VERSION }} | |
- name: Run style checks and linting via pre-commit hooks | |
uses: pre-commit/action@v3.0.0 |