-
Notifications
You must be signed in to change notification settings - Fork 1.3k
104 lines (99 loc) · 3.49 KB
/
tests.yml
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Run tests
on:
push:
branches: [ master, 1.0.x, 1.1.x ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master, 1.0.x, 1.1.x ]
jobs:
build:
runs-on: ubuntu-latest
services:
redis:
image: redis
ports:
- 6379/tcp
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=5
mariadb:
image: mariadb:latest
ports:
- 3306/tcp
env:
MARIADB_USER: graphite
MARIADB_PASSWORD: graphite
MARIADB_DATABASE: test_graphite
MARIADB_ROOT_PASSWORD: root
options: --health-cmd="/usr/local/bin/healthcheck.sh --su-mysql --connect --innodb_initialized" --health-interval=5s --health-timeout=2s --health-retries=3
postgres:
image: postgres
ports:
- 5432/tcp
env:
POSTGRES_PASSWORD: postgres
options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=5
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Install global dependencies
run: |
sudo apt-get -y install libcairo2-dev librrd-dev libboost-python-dev redis-tools
- name: Verify Redis connection
env:
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
run: |
redis-cli -h "127.0.0.1" -p "${REDIS_PORT}" ping
- name: Verify MariaDB connection
env:
MYSQL_PORT: ${{ job.services.mariadb.ports[3306] }}
run: |
mysql -h"127.0.0.1" -P"${MYSQL_PORT}" -uroot -proot -e "GRANT ALL ON test_graphite.* TO 'graphite'@'localhost' IDENTIFIED BY 'graphite';"
- name: Verify PostgreSQL connection
env:
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
run: |
PGPASSWORD=postgres psql -h"127.0.0.1" -p"${POSTGRES_PORT}" -U postgres -c "CREATE USER graphite WITH CREATEDB PASSWORD 'graphite';"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip 'setuptools<58' --force-reinstall
pip install 'tox<4' tox-gh-actions flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with tox
env:
TEST_REDIS_HOST: localhost
TEST_REDIS_PORT: ${{ job.services.redis.ports[6379] }}
TEST_MYSQL_HOST: localhost
TEST_MYSQL_PORT: ${{ job.services.mariadb.ports[3306] }}
TEST_MYSQL_PASSWORD: graphite
TEST_POSTGRES_HOST: localhost
TEST_POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
TEST_POSTGRESQL_PASSWORD: graphite
run: |
tox
- name: Linting
if: ${{ matrix.python-version==3.12 }}
env:
TOXENV: lint
run: |
tox
- name: Testing documentation
if: ${{ matrix.python-version==3.12 }}
env:
TOXENV: docs
run: |
tox
- name: Run Codecov
if: ${{ matrix.python-version==3.12 }}
env:
TOXENV: lint
run: |
pip install codecov
codecov
- name: Upload coverage to Codecov
if: ${{ matrix.python-version==3.12 }}
uses: codecov/codecov-action@v3