@@ -2,94 +2,94 @@ name: Run tests
22
33on :
44 push :
5- pull_request :
65
76jobs :
87 build :
98 runs-on : ubuntu-20.04
10- strategy :
11- matrix :
12- python-version : ["3.9", "3.10"]
13-
149 services :
1510 postgres :
1611 image : postgres
1712 env :
18- POSTGRES_DB : test
19- POSTGRES_USER : test
20- POSTGRES_PASSWORD : test
13+ POSTGRES_PASSWORD : postgres
2114 options : >-
2215 --health-cmd pg_isready
2316 --health-interval 10s
2417 --health-timeout 5s
2518 --health-retries 5
2619 ports :
27- - 30000 :5432
20+ - 5432 :5432
2821 steps :
2922 - uses : actions/checkout@v2
3023
3124 - name : Set up Python
3225 uses : actions/setup-python@v2
3326 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
4332 run : |
44- python -m venv .venv1
45- source .venv1/bin/activate
46- pip install -r {{cookiecutter.project_name}}/template_minimal/requirements-dev.txt
4733 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
5047 uses : actions/cache@v2
5148 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'
6854 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
7465 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
8269
83- pytest minimal_project
70+ # ## template fastapi users ###
8471
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'
8681 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
9484
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