-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement CI in github actions (#645)
- Loading branch information
1 parent
45d241e
commit e5af7f5
Showing
12 changed files
with
327 additions
and
244 deletions.
There are no files selected for viewing
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
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 |
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
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 |
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
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
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
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
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 |
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
Oops, something went wrong.