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