forked from adipai/PopcornPicks
-
Notifications
You must be signed in to change notification settings - Fork 7
58 lines (50 loc) · 1.9 KB
/
codecoverage.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
name: Code Coverage
on: [push]
jobs:
upload-coverage:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
# The MySQL docker container requires these environment variables to be set
# so we can create and migrate the test database.
# See: https://hub.docker.com/_/mysql
MYSQL_DATABASE: testdb
MYSQL_ROOT_PASSWORD: testrootpass
DB_HOST: 127.0.0.1
ports:
# Opens port 3306 on service container and host
# https://docs.github.com/en/actions/using-containerized-services/about-service-containers
- 3306:3306
# Before continuing, verify the mysql container is reachable from the ubuntu host
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.11 # Replace '3.x' with your desired Python version
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Create env file
run: |
cat << EOF > .env
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
DB_PASSWORD=${{ secrets.DB_PASSWORD }}
SALT=${{ secrets.SALT }}
EOF
- name: Set up DB
run: |
mysql -h 127.0.0.1 --port 3306 -u root -ptestrootpass < test/test_init.sql
- name: Test with pytest
run: pytest --tb=line
- name: Generate coverage
run: pytest --tb=line --cov-config=.coveragerc --cov --cov-report=xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}