Skip to content

Commit

Permalink
Implement CI in github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Nothing4You committed Jan 2, 2022
1 parent 45d241e commit 3f8227e
Show file tree
Hide file tree
Showing 6 changed files with 254 additions and 162 deletions.
123 changes: 123 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: CI

on:
push:
branches:
- 'master'
- '[0-9].[0-9]+' # matches to backport branches, e.g. 3.6
tags: [ 'v*' ]
pull_request:
branches:
- 'master'
- '[0-9].[0-9]+'
schedule:
- cron: '0 6 * * *' # Daily 6AM UTC build

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
py:
# - '3.5'
# - '3.6'
# - '3.7'
- '3.8'
# - '3.9'
#- '3.10'
# - '3.11'
db:
- "mysql:5.7"
- "mysql:8.0"
- "mariadb:10.2"
- "mariadb:10.3"
- "mariadb:10.5"
#asynciodebug:
# -
# - 1

fail-fast: false
runs-on: ${{ matrix.os }}-latest

services:
mysql:
image: "${{ matrix.db }}"
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: rootpw
options: "--name=mysqld"
#volumes:
# - "${{ github.workspace }}/tests/ssl_resources/ssl:/etc/mysql/ssl:ro"
# - "${{ github.workspace }}/tests/ssl_resources/tls.cnf:/etc/mysql/conf.d/tls.cnf:ro"

steps:
- name: Checkout
uses: actions/checkout@v2.4.0

- 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/cache@v2.1.7
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: |
pyroma -d .
- name: Run tests
run: |
export DB="${MATRIX_DB%%:*}"
export DBTAG="${MATRIX_DB##*:}"
py.test --capture=no --verbose 4 --cov-report term --cov-report html --cov aiomysql ./tests
env:
PYTEST_ADDOPTS: --color=yes
MYSQL_ROOT_PASSWORD: rootpw
MATRIX_DB: "${{ matrix.db }}"

- name: Generate coverage xml
run: |
python -m coverage xml
- name: Upload coverage
uses: codecov/codecov-action@v2.1.0
with:
file: ./coverage.xml
flags: unit
fail_ci_if_error: false
#if: matrix.os == 'ubuntu' && matrix.py == '3.10' && matrix.db == 'mariadb:10.5'
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:
test:
name: Test
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2.4.0

- 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/cache@v2.1.7
with:
key: pip-lint
path: ${{ steps.pip-cache.outputs.dir }}

- name: flake8 Lint
uses: py-actions/flake8@v2.0.0
with:
flake8-version: 3.7.9
path: aiomysql
args: tests examples
17 changes: 0 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,6 @@ matrix:
- 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 +49,3 @@ deploy:
repo: aio-libs/aiomysql
all_branches: true
python: 3.6

script:
- make cov

after_success:
- codecov
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pytest>=3.9.1,<=5.4.1
pytest-cov>=2.6.0,<=2.8.1
pytest-sugar>=0.9.1,<=0.9.3
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
Expand Down
Loading

0 comments on commit 3f8227e

Please sign in to comment.