-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (49 loc) · 1.43 KB
/
pytest-pull-request.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
# This workflow runs pytest on the service code
name: Pytest Pull Request workflow
on:
pull_request:
branches: [ master ]
#set environment variables
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
APP_NAME: async-url-shortener
IMAGE_NAME: shortener
jobs:
pytest_with_coverage:
# Run pytest, upload coverage to a githubs gist so that badge can display it
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: pass
POSTGRES_DB: postgres
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
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
run: |
pytest --cov=shortener
env:
DB_HOST: localhost
DB_PORT: ${{ job.services.postgres.ports[5432] }} # get randomly assigned published port
DB_DATABASE: postgres
DB_USER: postgres
DB_PASSWORD: pass