Skip to content

Commit 750767c

Browse files
authored
Create pytest github action
1 parent 8a7e34b commit 750767c

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/pytest.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Python application
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build:
17+
18+
runs-on: ubuntu-latest
19+
20+
# Service containers to run with `container-job`
21+
services:
22+
# Label used to access the service container
23+
postgres:
24+
# Docker Hub image
25+
image: postgres
26+
# Provide the password for postgres
27+
env:
28+
POSTGRES_PASSWORD: password
29+
# Set health checks to wait until postgres has started
30+
options: >-
31+
--health-cmd pg_isready
32+
--health-interval 10s
33+
--health-timeout 5s
34+
--health-retries 5
35+
36+
steps:
37+
- uses: actions/checkout@v3
38+
- name: Set up Python 3.10
39+
uses: actions/setup-python@v3
40+
with:
41+
python-version: "3.10"
42+
- uses: Gr1N/setup-poetry@v7
43+
# - name: Install dependencies
44+
# run: |
45+
# python -m pip install --upgrade pip
46+
# pip install flake8 pytest
47+
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
48+
- name: Install dependencies
49+
run: poetry install
50+
- name: Lint with flake8
51+
run: |
52+
# stop the build if there are Python syntax errors or undefined names
53+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
54+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
55+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
56+
- name: Test with pytest
57+
run: |
58+
pytest src
59+
env:
60+
# The hostname used to communicate with the PostgreSQL service container
61+
DATABASE_URL: postgresql://postgres:password@postgres:5432/postgres

0 commit comments

Comments
 (0)