Skip to content

Commit

Permalink
Update for Python 3.9 (#22)
Browse files Browse the repository at this point in the history
* ci: Update for Python 3.9
* feat(server): Apply PidfdChildWatcher if available (this will be revisited in a separate PR)
* feat: A new `fork` module for pidfd-based race-free async `fork()`
  - Note: PID file descriptors are only available on Python 3.9+ and Linux kernel 5.4+
  - Now the test suite for the `fork` module works with the GitHub Actions CI environment with `os.setpgrp()` to confine signals to the spawned child processes.
  • Loading branch information
achimnol committed Jan 10, 2021
1 parent 13eaec4 commit e664a71
Show file tree
Hide file tree
Showing 11 changed files with 565 additions and 128 deletions.
137 changes: 137 additions & 0 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: default

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Cache pip packages
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: lint-flake8-${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.cfg') }}
restore-keys: |
lint-flake8-${{ runner.os }}-pip-${{ matrix.python-version }}
lint-flake8-${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install -U pip setuptools
python -m pip install -U -r requirements/lint.txt
- name: Lint with flake8
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$GITHUB_HEAD_REF" ]; then
echo "(skipping matchers for pull request from local branches)"
else
echo "::add-matcher::.github/workflows/flake8-matcher.json"
fi
python -m flake8 src/aiotools tests
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Cache pip packages
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: typecheck-mypy-${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.cfg') }}
restore-keys: |
typecheck-mypy-${{ runner.os }}-pip-${{ matrix.python-version }}
typecheck-mypy-${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install -U pip setuptools
python -m pip install -U -r requirements/typecheck.txt
- name: Type check with mypy
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$GITHUB_HEAD_REF" ]; then
echo "(skipping matchers for pull request from local branches)"
else
echo "::add-matcher::.github/workflows/mypy-matcher.json"
fi
python -m mypy --no-color-output src/aiotools tests
test:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip packages
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: typecheck-mypy-${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.cfg') }}
restore-keys: |
typecheck-mypy-${{ runner.os }}-pip-${{ matrix.python-version }}
typecheck-mypy-${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install -U pip setuptools
python -m pip install -U -r requirements/test.txt
- name: Prepare testing
run: |
mkdir -p /tmp/etcd
docker run -d -p 2379:2379 -p 2380:2380 \
-v /tmp/etcd:/etcd-data \
--name backendai-etcd \
quay.io/coreos/etcd:v3.4.1 \
/usr/local/bin/etcd \
--name backendai-etcd \
--data-dir /etcd-data \
--listen-client-urls http://0.0.0.0:2379 \
--advertise-client-urls http://0.0.0.0:2379 \
--listen-peer-urls http://0.0.0.0:2380 \
--initial-advertise-peer-urls http://0.0.0.0:2380 \
--initial-cluster backendai-etcd=http://0.0.0.0:2380 \
--initial-cluster-token backendai-etcd-token \
--initial-cluster-state new \
--auto-compaction-retention 1
- name: Test with pytest
timeout-minutes: 1
run: |
python -m pytest -v --cov=src tests
- name: Send code coverage report
uses: codecov/codecov-action@v1
with:
env_vars: GHA_OS,GHA_PYTHON

deploy-to-pypi:
needs: [lint, typecheck, test]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
env:
REQUIREMENTS_FILE: build
run: |
python -m pip install -U pip setuptools
pip install -U wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
26 changes: 0 additions & 26 deletions .github/workflows/deploy-pypi.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/lint-flake8.yml

This file was deleted.

43 changes: 0 additions & 43 deletions .github/workflows/test-pytest.yml

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/timeline-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: timeline-check

on: [pull_request]

jobs:
towncrier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Cache pip packages
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: lint-towncrier-${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.cfg') }}
restore-keys: |
lint-towncrier-${{ runner.os }}-pip-${{ matrix.python-version }}
lint-towncrier-${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install -U pip setuptools
python -m pip install -U towncrier
- name: Check existence of news fragment
run: |
git fetch --no-tags origin +refs/heads/${BASE_BRANCH}:refs/remotes/origin/${BASE_BRANCH}
python -m towncrier.check --compare-with=origin/${BASE_BRANCH}
env:
BASE_BRANCH: ${{ github.base_ref }}
27 changes: 0 additions & 27 deletions .github/workflows/typecheck-mypy.yml

This file was deleted.

2 changes: 2 additions & 0 deletions changes/22.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Now the primary target is Python 3.9
Add a new module `fork` to support PID file descriptors in Linux 5.4+ and a POSIX-compatible fallback to asynchornously fork the Python process without signal/PID races.

0 comments on commit e664a71

Please sign in to comment.