Skip to content

Commit

Permalink
Implement CI in github actions (#645)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nothing4You authored Jan 10, 2022
1 parent 45d241e commit e5af7f5
Show file tree
Hide file tree
Showing 12 changed files with 327 additions and 244 deletions.
149 changes: 149 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: CI

on:
push:
branches:
- 'master'
tags:
- 'v*'
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true


jobs:
test:
name: Test
strategy:
matrix:
# service containers are only supported on ubuntu currently
os:
- ubuntu-latest
py:
- '3.7'
- '3.8'
- '3.9'
# - '3.10'
# - '3.11.0-alpha.3'
db:
- 'mysql:5.7'
- 'mysql:8.0'
- 'mariadb:10.2'
- 'mariadb:10.3'
- 'mariadb:10.4'
- 'mariadb:10.5'
- 'mariadb:10.6'
- 'mariadb:10.7'

fail-fast: false
runs-on: ${{ matrix.os }}
timeout-minutes: 15

env:
MYSQL_ROOT_PASSWORD: rootpw

services:
mysql:
image: '${{ matrix.db }}'
ports:
- 3306:3306
options: '--name=mysqld'
env:
MYSQL_ROOT_PASSWORD: rootpw

steps:
- name: Checkout
uses: actions/[email protected]

- name: Setup Python ${{ matrix.py }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.py }}

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)" # - name: Cache
- name: Cache PyPI
uses: actions/[email protected]
with:
key: pip-ci-${{ runner.os }}-${{ matrix.py }}
path: ${{ steps.pip-cache.outputs.dir }}

- name: Update pip, wheel, setuptools, build, twine, codecov
run: |
python -m pip install -U pip wheel setuptools build twine codecov
- name: Install dependencies
run: |
python -m pip install --upgrade --requirement requirements-dev.txt
- name: Install aiomysql
run: |
python -m pip install .
- name: Check rst
run: |
python setup.py check --restructuredtext
- name: Run pyroma
run: |
python -m pyroma -d .
# this ensures our database is ready. typically by the time the preparations have completed its first start logic.
# unfortunately we need this hacky workaround as GitHub Actions service containers can't reference data from our repo.
- name: Prepare mysql
run: |
# ensure server is started up
while :
do
sleep 1
mysql -h127.0.0.1 -uroot "-p$MYSQL_ROOT_PASSWORD" -e 'select version()' && break
done
# inject tls configuration
docker container stop mysqld
docker container cp "${{ github.workspace }}/tests/ssl_resources/ssl" mysqld:/etc/mysql/ssl
docker container cp "${{ github.workspace }}/tests/ssl_resources/tls.cnf" mysqld:/etc/mysql/conf.d/aiomysql-tls.cnf
docker container start mysqld
# ensure server is started up
while :
do
sleep 1
mysql -h127.0.0.1 -uroot "-p$MYSQL_ROOT_PASSWORD" -e 'select version()' && break
done
mysql -h127.0.0.1 -uroot "-p$MYSQL_ROOT_PASSWORD" -e "SET GLOBAL local_infile=on"
- name: Run tests
run: |
export DB="${MATRIX_DB%%:*}"
export DBTAG="${MATRIX_DB##*:}"
# timeout ensures a more or less clean stop by sending a KeyboardInterrupt which will still provide useful logs
timeout --preserve-status --signal=INT --verbose 5m \
pytest --color=yes --capture=no --verbosity 2 --cov-report term --cov-report xml --cov aiomysql ./tests
env:
PYTHONUNBUFFERED: 1
MATRIX_DB: '${{ matrix.db }}'
timeout-minutes: 6

- name: Build coverage flag
run: |
COVERAGE_FLAG="${MATRIX_OS}_${MATRIX_PY}_${MATRIX_DB//:/-}"
echo "COVERAGE_FLAG=$COVERAGE_FLAG" | tee -a "$GITHUB_ENV"
env:
MATRIX_OS: '${{ matrix.os }}'
MATRIX_PY: '${{ matrix.py }}'
MATRIX_DB: '${{ matrix.db }}'

- name: Upload coverage
uses: codecov/[email protected]
with:
file: ./coverage.xml
flags: "${{ env.COVERAGE_FLAG }}"
fail_ci_if_error: true
41 changes: 41 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: lint

on:
push:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/[email protected]

- name: Setup Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)" # - name: Cache
- name: Cache PyPI
uses: actions/[email protected]
with:
key: pip-lint
path: ${{ steps.pip-cache.outputs.dir }}

- name: flake8 Lint
uses: py-actions/[email protected]
with:
flake8-version: 4.0.1
path: aiomysql
args: tests examples
50 changes: 0 additions & 50 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,10 @@
language: python

python:
- 3.6
- 3.7
- 3.8

env:
matrix:
- PYTHONASYNCIODEBUG=1
- PYTHONASYNCIODEBUG=

services:
- docker

matrix:
include:
- python: 3.6
env:
- PYTHONASYNCIODEBUG=
- DB=mariadb
- DBTAG=5.5
- python: 3.6
env:
- PYTHONASYNCIODEBUG=1
- DB=mariadb
- DBTAG=10.0
addons:
mariadb: '10.0'
- python: 3.6
env:
- PYTHONASYNCIODEBUG=
- DB=mariadb
- DBTAG=10.5
- python: 3.6
env:
- PYTHONASYNCIODEBUG=
- DB=mysql
- DBTAG=5.7


#before_script:
# - "mysql -e 'SELECT VERSION()'"
# - "mysql -e 'DROP DATABASE IF EXISTS test_pymysql; create database test_pymysql DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'"
# - "mysql -e 'DROP DATABASE IF EXISTS test_pymysql2; create database test_pymysql2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'"

install:
- pip install -Ur requirements-dev.txt
- pip install .
- pip install codecov

deploy:
provider: pypi
user: aio-libs-bot
Expand All @@ -60,9 +16,3 @@ deploy:
repo: aio-libs/aiomysql
all_branches: true
python: 3.6

script:
- make cov

after_success:
- codecov
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
aiomysql
========
.. image:: https://travis-ci.com/aio-libs/aiomysql.svg?branch=master
:target: https://travis-ci.com/aio-libs/aiomysql
.. image:: https://github.com/aio-libs/aiomysql/actions/workflows/ci.yml/badge.svg?branch=master
:target: https://github.com/aio-libs/aiomysql/actions/workflows/ci.yml
.. image:: https://codecov.io/gh/aio-libs/aiomysql/branch/master/graph/badge.svg
:target: https://codecov.io/gh/aio-libs/aiomysql
:alt: Code coverage
Expand Down Expand Up @@ -104,7 +104,7 @@ for aiopg_ user.:
Requirements
------------

* Python_ 3.5.3+
* Python_ 3.7+
* PyMySQL_


Expand Down
8 changes: 4 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ Please feel free to file an issue on `bug tracker
<https://github.com/aio-libs/aiomysql/issues>`_ if you have found a bug
or have some suggestion for library improvement.

The library uses `Travis <https://travis-ci.org/aio-libs/aiomysql>`_ for
Continious Integration and `Coveralls
<https://coveralls.io/r/aio-libs/aiomysql?branch=master>`_ for
The library uses `GitHub Actions
<https://github.com/aio-libs/aiomysql/actions>`_ for Continuous Integration
and `Codecov <https://app.codecov.io/gh/aio-libs/aiomysql/branch/master>`_ for
coverage reports.


Dependencies
------------

- Python 3.5.3+
- Python 3.7+
- :term:`PyMySQL`
- aiomysql.sa requires :term:`sqlalchemy`.

Expand Down
18 changes: 8 additions & 10 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
coverage>=4.5.1,<=5.1
flake8>=3.5.0,<=3.7.9
ipdb>=0.11,<=0.13.2
ipython>=7.0.1,<=7.13.0
pytest>=3.9.1,<=5.4.1
pytest-cov>=2.6.0,<=2.8.1
pytest-sugar>=0.9.1,<=0.9.3
coverage==6.2
flake8==4.0.1
ipdb==0.13.9
pytest==6.2.5
pytest-cov==3.0.0
pytest-sugar==0.9.4
PyMySQL>=0.9,<=0.9.3
docker>=3.5.1,<=4.2.0
sphinx>=1.8.1, <=3.0.3
sphinxcontrib-asyncio==0.2.0
sqlalchemy>1.2.12,<=1.3.16
uvloop>=0.11.2,<=0.14.0; python_version >= '3.5'
pyroma==2.6
uvloop==0.16.0
pyroma==3.2
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
PY_VER = sys.version_info


if not PY_VER >= (3, 5, 3):
raise RuntimeError("aiomysql doesn't support Python earlier than 3.5.3")
if not PY_VER >= (3, 7, 0):
raise RuntimeError("aiomysql doesn't support Python earlier than 3.7.0")


def read(f):
Expand All @@ -37,8 +37,9 @@ def read_version():
'License :: OSI Approved :: MIT License',
'Intended Audience :: Developers',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Operating System :: POSIX',
'Environment :: Web Environment',
'Development Status :: 3 - Alpha',
Expand Down
Loading

0 comments on commit e5af7f5

Please sign in to comment.