-
Notifications
You must be signed in to change notification settings - Fork 1
82 lines (80 loc) · 2.7 KB
/
python-test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Python Test
on:
# Triggers the workflow on push to master and any PRs to master
push:
branches:
- master
pull_request:
branches:
- master
jobs:
python-test:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11"]
poetry-version: [1.4.1]
# The type of runner that the job will run on
runs-on: ubuntu-latest
services:
# Setup postgres service
postgres:
image: postgres:11.9
env:
POSTGRES_USER: postgres
POSTGRES_HOST_AUTH_METHOD: trust
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
# Setup MySQL service
mysql:
image: mysql:8.3.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
# Set health checks to wait until mysql has started
options:
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 3306 on service container to the host
- 3306:3306
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Run image
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}
# - name: Start MySQL service
# # MySQL needs to be started manually (https://github.blog/changelog/2020-02-21-github-actions-breaking-change-ubuntu-virtual-environments-will-no-longer-start-the-mysql-service-automatically/)
# run: |
# sudo /etc/init.d/mysql start
# mysql --host 127.0.0.1 --port 3306 -uroot -proot -e "GRANT ALL ON *.* TO 'root'@'localhost'; FLUSH PRIVILEGES;"
- name: Install package
run: |
poetry config virtualenvs.create false && poetry install -E mysql
env:
PIP_DEFAULT_TIMEOUT: "60"
- name: Run Test and generate coverage report
run: poetry run pytest --cov=./ --cov-report=xml
env:
TEST_MYSQL_URL: mysql+pymysql://root@localhost:3306/mysql
- name: Upload Coverage to CodeCov
uses: codecov/codecov-action@v4
with:
file: coverage.xml
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true