-
Notifications
You must be signed in to change notification settings - Fork 13
88 lines (82 loc) · 2.64 KB
/
pytest.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
name: Pytest
on:
push:
branches: ['main']
pull_request:
branches: ['main']
paths:
- '**.py'
- '**.js'
- '**.jinja2'
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
services:
redis:
image: redis
ports:
- 6379:6379
options: --entrypoint redis-server
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install project
run: |
pip install -e .
pip install -r test_requirements.txt
- name: Install pytest-github-actions-annotate-failures
run: pip install pytest-github-actions-annotate-failures
- name: Create PostgreSQL databases
run: |
sudo apt-get install postgresql-client -y
echo "Granting database privileges to user $(whoami)"
psql -h localhost -U postgres -c "create user $(whoami);"
psql -h localhost -U postgres -c "create database coaster_test;"
psql -h localhost -U postgres -c "grant all privileges on database coaster_test to $(whoami);"
psql -h localhost -U postgres coaster_test -c "grant all privileges on schema public to $(whoami); grant all privileges on all tables in schema public to $(whoami); grant all privileges on all sequences in schema public to $(whoami);"
- name: Test with pytest
run: |
pytest --showlocals --cov=coaster
- name: Prepare coverage report
run: |
mkdir -p coverage
coverage lcov -o coverage/coaster.lcov
- name: Upload coverage report to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: ./coverage/coaster.lcov
flag-name: python-${{ matrix.python-version }}
parallel: true
finish:
needs: test
runs-on: ubuntu-latest
steps:
- name: Publish to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: ./coverage/coaster.lcov
parallel-finished: true