Skip to content

Commit 0502a4e

Browse files
committed
fix workflow
1 parent 6fb12ed commit 0502a4e

2 files changed

Lines changed: 115 additions & 9 deletions

File tree

.github/workflows/test.yml

Lines changed: 110 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,127 @@ jobs:
6666
DB_HOST: localhost
6767
DB_USER: gino
6868
run: |
69-
$HOME/.poetry/bin/poetry run pytest --cov=src --cov-fail-under=95 --cov-report xml
69+
$HOME/.poetry/bin/poetry run pytest tests/
70+
test-mysql:
71+
runs-on: ubuntu-latest
72+
strategy:
73+
matrix:
74+
python-version: [ '3.5', '3.6', '3.7', '3.8' ]
75+
deps-version: [ 'lowest', 'highest' ]
76+
services:
77+
mysql:
78+
image: mysql:5
79+
env:
80+
MYSQL_ALLOW_EMPTY_PASSWORD: 1
81+
ports:
82+
- 3306:3306
83+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
84+
steps:
85+
- name: Checkout source code
86+
uses: actions/checkout@v1
87+
- name: Set up Python
88+
uses: actions/setup-python@v1
89+
with:
90+
python-version: ${{ matrix.python-version }}
91+
- name: virtualenv cache
92+
uses: actions/cache@preview
93+
with:
94+
path: ~/.cache/pypoetry/virtualenvs
95+
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.deps-version }}-venv-${{ hashFiles(format('{0}{1}', github.workspace, '/poetry.lock')) }}
96+
restore-keys: |
97+
${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.deps-version }}-venv-
98+
- name: Poetry cache
99+
uses: actions/cache@preview
100+
with:
101+
path: ~/.poetry
102+
key: ${{ runner.os }}-${{ matrix.python-version }}-dotpoetry
103+
restore-keys: |
104+
${{ runner.os }}-${{ matrix.python-version }}-dotpoetry-
105+
- name: Install Python dependencies
106+
run: |
107+
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
108+
$HOME/.poetry/bin/poetry install --no-interaction
109+
- name: Use lowest dependencies versions
110+
if: matrix.deps-version == 'lowest'
111+
run: |
112+
$HOME/.poetry/bin/poetry run pip install asyncpg==0.18 SQLAlchemy==1.3
113+
- name: List installed packages
114+
run: |
115+
$HOME/.poetry/bin/poetry run pip list
116+
- name: Test with pytest
117+
env:
118+
MYSQL_DB_HOST: 127.0.0.1
119+
MYSQL_DB_USER: root
120+
run: |
121+
$HOME/.poetry/bin/poetry run pytest mysql_tests/
122+
summary:
123+
runs-on: ubuntu-latest
124+
services:
125+
postgres:
126+
image: fantix/postgres-ssl:12.1
127+
env:
128+
POSTGRES_USER: gino
129+
ports:
130+
- 5432:5432
131+
# needed because the postgres container does not provide a healthcheck
132+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
133+
mysql:
134+
image: mysql:5
135+
env:
136+
MYSQL_ALLOW_EMPTY_PASSWORD: 1
137+
ports:
138+
- 3306:3306
139+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
140+
steps:
141+
- name: Checkout source code
142+
uses: actions/checkout@v1
143+
- name: Set up Python
144+
uses: actions/setup-python@v1
145+
with:
146+
python-version: 3.8
147+
- name: virtualenv cache
148+
uses: actions/cache@preview
149+
with:
150+
path: ~/.cache/pypoetry/virtualenvs
151+
key: ${{ runner.os }}-3.8-highest-venv-${{ hashFiles(format('{0}{1}', github.workspace, '/poetry.lock')) }}
152+
restore-keys: |
153+
${{ runner.os }}-3.8-highest-venv-
154+
- name: Poetry cache
155+
uses: actions/cache@preview
156+
with:
157+
path: ~/.poetry
158+
key: ${{ runner.os }}-3.8-dotpoetry
159+
restore-keys: |
160+
${{ runner.os }}-3.8-dotpoetry-
161+
- name: Install Python dependencies
162+
run: |
163+
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
164+
$HOME/.poetry/bin/poetry install --no-interaction
165+
- name: List installed packages
166+
run: |
167+
$HOME/.poetry/bin/poetry run pip list
168+
- name: Test with pytest
169+
env:
170+
DB_HOST: localhost
171+
DB_USER: gino
172+
MYSQL_DB_HOST: 127.0.0.1
173+
MYSQL_DB_USER: root
174+
run: |
175+
$HOME/.poetry/bin/poetry run pytest --cov=src --cov-fail-under=95 --cov-report xml tests/ mysql_tests/
70176
- name: Check code format with black
71-
if: matrix.python-version >= '3.6'
72177
run: |
73178
$HOME/.poetry/bin/poetry run black --check src
74179
- name: Submit coverage report
75-
if: matrix.python-version == '3.8' && matrix.postgres-version == '12.1' && matrix.deps-version == 'highest' && github.ref == 'refs/heads/master'
180+
if: github.ref == 'refs/heads/master'
76181
env:
77182
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_TOKEN }}
78183
run: |
79184
pip install codacy-coverage
80185
python-codacy-coverage -r coverage.xml
186+
81187
release:
82188
runs-on: ubuntu-latest
83-
needs: test
189+
needs: summary
84190
strategy:
85191
matrix:
86192
python-version: [ '3.8' ]

mysql_tests/models.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
from gino.dialects.aiomysql import JSON
1313

1414
DB_ARGS = dict(
15-
host=os.getenv("DB_HOST", "localhost"),
16-
port=os.getenv("DB_PORT", 3306),
17-
user=os.getenv("DB_USER", "root"),
18-
password=os.getenv("DB_PASS", ""),
19-
db=os.getenv("DB_NAME", "mysql"),
15+
host=os.getenv("MYSQL_DB_HOST", "localhost"),
16+
port=os.getenv("MYSQL_DB_PORT", 3306),
17+
user=os.getenv("MYSQL_DB_USER", "root"),
18+
password=os.getenv("MYSQL_DB_PASS", ""),
19+
db=os.getenv("MYSQL_DB_NAME", "mysql"),
2020
)
2121
MYSQL_URL = "mysql://{user}:{password}@{host}:{port}/{db}".format(**DB_ARGS)
2222
db = Gino()

0 commit comments

Comments
 (0)