forked from rafsaf/minimal-fastapi-postgres-template
-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (82 loc) · 2.82 KB
/
Copy pathtests.yml
File metadata and controls
95 lines (82 loc) · 2.82 KB
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
89
90
91
92
93
94
95
name: Run tests
on:
push:
jobs:
build:
runs-on: ubuntu-22.04
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Generate projects from templates using cookiecutter
# fastapi_users_project folder
# minimal_project folder
run: |
pip install cookiecutter
python tests/create_minimal_project.py
python tests/create_fastapi_users_project.py
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
### template minimal ###
- name: Load cached venv-1
id: cached-poetry-dependencies-template-1
uses: actions/cache@v2
with:
path: minimal_project/.venv
key: venv-${{ runner.os }}-${{ hashFiles('minimal_project/poetry.lock') }}
- name: Install template minimal dependencies
if: steps.cached-poetry-dependencies-template-1.outputs.cache-hit != 'true'
run: |
cd minimal_project
poetry install --no-interaction --no-root
- name: Run template minimal flake8 and then tests
env:
TEST_DATABASE_HOSTNAME: localhost
TEST_DATABASE_PASSWORD: postgres
TEST_DATABASE_PORT: 5432
TEST_DATABASE_USER: postgres
TEST_DATABASE_DB: postgres
run: |
cd minimal_project
poetry run flake8 app --count --exit-zero --statistics
poetry run coverage run -m pytest
### template fastapi users ###
- name: Load cached venv-2
id: cached-poetry-dependencies-template-2
uses: actions/cache@v2
with:
path: fastapi_users_project/.venv
key: venv-${{ runner.os }}-${{ hashFiles('fastapi_users_project/poetry.lock') }}
- name: Install template fastapi users dependencies
if: steps.cached-poetry-dependencies-template-1.outputs.cache-hit != 'true'
run: |
cd fastapi_users_project
poetry install --no-interaction --no-root
- name: Run template fastapi users flake8 and then tests
env:
TEST_DATABASE_HOSTNAME: localhost
TEST_DATABASE_PASSWORD: postgres
TEST_DATABASE_PORT: 5432
TEST_DATABASE_USER: postgres
TEST_DATABASE_DB: postgres
run: |
cd fastapi_users_project
poetry run flake8 app --count --exit-zero --statistics
poetry run coverage run -m pytest