-
Notifications
You must be signed in to change notification settings - Fork 1
77 lines (73 loc) · 2.29 KB
/
unit-test-and-code-coverage.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
name: Run Tests and Generate Code Coverage
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
env:
FLASK_APP: "/home/runner/work/RP_IVR_ANALYTICS/RP_IVR_ANALYTICS/manage.py"
TEST_DB_USER: "postgres"
TEST_DB_PASSWORD: "postgres"
TEST_DB_DATABASE: "dost_test"
TEST_DB_HOST: 127.0.0.1
TEST_DB_POST: 5432
admin_server: 127.0.0.1
FLASK_ENV: "testing"
TESTING: True
DEBUG: True
SECRET_KEY: ""
RETRY_LOGS_BATCH_LIMIT: 1000
MAX_RETRY_ATTEMPTS_FOR_LOGS: 3%
SQLALCHEMY_DATABASE_URI_GITHUB_ACTION: "postgresql://postgres:[email protected]:5432/dost_test"
jobs:
test:
name: Run tests & display coverage
runs-on: ubuntu-latest
permissions:
# Gives the action the necessary permissions for publishing new
# comments in pull requests.
pull-requests: write
# Gives the action the necessary permissions for pushing data to the
# python-coverage-comment-action branch, and for editing existing
# comments (to avoid publishing multiple comments in the same PR)
contents: write
services:
postgres:
image: postgres:13
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: dost_test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Install PostgreSQL client
run: |
sudo apt-get update
sudo apt-get install --yes postgresql-client
- uses: actions/checkout@v3
- name: Install Python 3
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Copy .env
run: cp .env.example .env
- name: Install dependencies
run: pip install -r requirements.txt
- name: Upgrade db
run: python -m flask db upgrade
- name: Launch tests & generate report
run: python -m pytest --junitxml=pytest.xml --cov > pytest-coverage.txt
- name: Print Coverage report
run: cat pytest-coverage.txt
- name: Pytest coverage comment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: pytest-coverage.txt
junitxml-path: pytest.xml
hide-report: true