@@ -2,94 +2,94 @@ name: Run tests
2
2
3
3
on :
4
4
push :
5
- pull_request :
6
5
7
6
jobs :
8
7
build :
9
8
runs-on : ubuntu-20.04
10
- strategy :
11
- matrix :
12
- python-version : ["3.9", "3.10"]
13
-
14
9
services :
15
10
postgres :
16
11
image : postgres
17
12
env :
18
- POSTGRES_DB : test
19
- POSTGRES_USER : test
20
- POSTGRES_PASSWORD : test
13
+ POSTGRES_PASSWORD : postgres
21
14
options : >-
22
15
--health-cmd pg_isready
23
16
--health-interval 10s
24
17
--health-timeout 5s
25
18
--health-retries 5
26
19
ports :
27
- - 30000 :5432
20
+ - 5432 :5432
28
21
steps :
29
22
- uses : actions/checkout@v2
30
23
31
24
- name : Set up Python
32
25
uses : actions/setup-python@v2
33
26
with :
34
- python-version : ${{ matrix.python-version }}
35
- - name : Load cached venv1
36
- id : cached-poetry-dependencies1
37
- uses : actions/cache@v2
38
- with :
39
- path : .venv1
40
- key : venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('{{cookiecutter.project_name}}/template_minimal/poetry.lock') }}
41
- - name : Install dependencies and actiavte virtualenv
42
- if : steps.cached-poetry-dependencies1.outputs.cache-hit != 'true'
27
+ python-version : " 3.10"
28
+
29
+ - name : Generate projects from templates using cookiecutter
30
+ # fastapi_users_project folder
31
+ # minimal_project folder
43
32
run : |
44
- python -m venv .venv1
45
- source .venv1/bin/activate
46
- pip install -r {{cookiecutter.project_name}}/template_minimal/requirements-dev.txt
47
33
pip install cookiecutter
48
- - name : Load cached venv2
49
- id : cached-poetry-dependencies2
34
+ python tests/create_minimal_project.py
35
+ python tests/create_fastapi_users_project.py
36
+
37
+ - name : Install Poetry
38
+ uses : snok/install-poetry@v1
39
+ with :
40
+ virtualenvs-create : true
41
+ virtualenvs-in-project : true
42
+
43
+ # ## template minimal ###
44
+
45
+ - name : Load cached venv-1
46
+ id : cached-poetry-dependencies-template-1
50
47
uses : actions/cache@v2
51
48
with :
52
- path : .venv2
53
- key : venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('{{cookiecutter.project_name}}/template_fastapi_users/poetry.lock') }}
54
- - name : Install dependencies and actiavte virtualenv
55
- if : steps.cached-poetry-dependencies2.outputs.cache-hit != 'true'
56
- run : |
57
- python -m venv .venv2
58
- source .venv2/bin/activate
59
- pip install -r {{cookiecutter.project_name}}/template_fastapi_users/requirements-dev.txt
60
- pip install cookiecutter
61
- - name : Lint with flake8 minimal project
62
- run : |
63
- source .venv1/bin/activate
64
- # stop the build if there are Python syntax errors or undefined names
65
- cd \{\{cookiecutter.project_name\}\}/template_minimal
66
- flake8 app --count --exit-zero --statistics
67
- - name : Lint with flake8 fastapi_users project
49
+ path : minimal_project/.venv
50
+ key : venv-${{ runner.os }}-${{ hashFiles('minimal_project/poetry.lock') }}
51
+
52
+ - name : Install template minimal dependencies
53
+ if : steps.cached-poetry-dependencies-template-1.outputs.cache-hit != 'true'
68
54
run : |
69
- source .venv2/bin/activate
70
- # stop the build if there are Python syntax errors or undefined names
71
- cd \{\{cookiecutter.project_name\}\}/template_fastapi_users
72
- flake8 app --count --exit-zero --statistics
73
- - name : Test minimal project is passing pytest test
55
+ cd minimal_project
56
+ poetry install --no-interaction --no-root
57
+
58
+ - name : Run template minimal flake8 and then tests
59
+ env :
60
+ TEST_DATABASE_HOSTNAME : localhost
61
+ TEST_DATABASE_PASSWORD : postgres
62
+ TEST_DATABASE_PORT : 5432
63
+ TEST_DATABASE_USER : postgres
64
+ TEST_DATABASE_DB : postgres
74
65
run : |
75
- source .venv1/bin/activate
76
- python tests/create_minimal_project.py
77
- export TEST_DATABASE_HOSTNAME=localhost
78
- export TEST_DATABASE_USER=test
79
- export TEST_DATABASE_PASSWORD=test
80
- export TEST_DATABASE_PORT=30000
81
- export TEST_DATABASE_DB=test
66
+ cd minimal_project
67
+ poetry run flake8 app --count --exit-zero --statistics
68
+ poetry run coverage run -m pytest
82
69
83
- pytest minimal_project
70
+ # ## template fastapi users ###
84
71
85
- - name : Test fastapi_users project is passing pytest test
72
+ - name : Load cached venv-2
73
+ id : cached-poetry-dependencies-template-2
74
+ uses : actions/cache@v2
75
+ with :
76
+ path : fastapi_users_project/.venv
77
+ key : venv-${{ runner.os }}-${{ hashFiles('fastapi_users_project/poetry.lock') }}
78
+
79
+ - name : Install template fastapi users dependencies
80
+ if : steps.cached-poetry-dependencies-template-1.outputs.cache-hit != 'true'
86
81
run : |
87
- source .venv2/bin/activate
88
- python tests/create_fastapi_users_project.py
89
- export TEST_DATABASE_HOSTNAME=localhost
90
- export TEST_DATABASE_USER=test
91
- export TEST_DATABASE_PASSWORD=test
92
- export TEST_DATABASE_PORT=30000
93
- export TEST_DATABASE_DB=test
82
+ cd fastapi_users_project
83
+ poetry install --no-interaction --no-root
94
84
95
- pytest fastapi_users_project
85
+ - name : Run template fastapi users flake8 and then tests
86
+ env :
87
+ TEST_DATABASE_HOSTNAME : localhost
88
+ TEST_DATABASE_PASSWORD : postgres
89
+ TEST_DATABASE_PORT : 5432
90
+ TEST_DATABASE_USER : postgres
91
+ TEST_DATABASE_DB : postgres
92
+ run : |
93
+ cd fastapi_users_project
94
+ poetry run flake8 app --count --exit-zero --statistics
95
+ poetry run coverage run -m pytest
0 commit comments