Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

Commit c7ecf25

Browse files
committed
Initial commit - fastapi-mvc/fastapi-mvc#146
0 parents  commit c7ecf25

File tree

100 files changed

+6187
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+6187
-0
lines changed

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
*.egg-info/
7+
.installed.cfg
8+
*.egg
9+
10+
# Unit test / coverage reports
11+
htmlcov/
12+
.tox/
13+
.coverage
14+
.coverage.*
15+
.cache
16+
nosetests.xml
17+
coverage.xml
18+
*,cover
19+
.hypothesis/
20+
flake8_code_errors.txt
21+
pep257_violations.txt
22+
pep8_violations.txt
23+
code_complexity.txt
24+
xunit-*.xml
25+
26+
# PyCharm
27+
.idea
28+
29+
# virtual
30+
venv
31+
.venv
32+
33+
# direnv
34+
.direnv

cookiecutter.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"project_name": "{{ cookiecutter.project_name }}",
3+
"folder_name": "{{ cookiecutter.project_name|lower|replace(' ','-') }}",
4+
"repo_url": "{{ cookiecutter.repo_url }}",
5+
"package_name": "{{ cookiecutter.project_name|lower|replace(' ','_')|replace('-','_') }}",
6+
"docker_image_name": "{{ cookiecutter.project_name|lower|replace(' ','_') }}",
7+
"script_name": "{{ cookiecutter.project_name|lower|replace(' ','_') }}",
8+
"chart_name": "{{ cookiecutter.project_name|lower|replace(' ','-') }}",
9+
"author": "{{ cookiecutter.author }}",
10+
"email": "{{ cookiecutter.email }}",
11+
"project_description": "This project was generated with fastapi-mvc.",
12+
"version": "0.1.0",
13+
"redis": ["yes", "no"],
14+
"github_actions": ["yes", "no"],
15+
"aiohttp": ["yes", "no"],
16+
"helm": ["yes", "no"],
17+
"nix": ["yes", "no"],
18+
"license": [
19+
"MIT",
20+
"BSD2",
21+
"BSD3",
22+
"ISC",
23+
"Apache2.0",
24+
"LGPLv3+",
25+
"LGPLv3",
26+
"LGPLv2+",
27+
"LGPLv2",
28+
"no"
29+
],
30+
"year": "{{ cookiecutter.year }}",
31+
"fastapi_mvc_version": "{{ cookiecutter.fastapi_mvc_version }}"
32+
}

hooks/post_gen_project.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
"""Fastapi-mvc cookiecutter template post_gen_project hook."""
2+
import os
3+
import shutil
4+
5+
6+
def remove(paths):
7+
"""Remove directories and files provided in paths list.
8+
9+
Args:
10+
paths(list): List of relative paths to remove.
11+
12+
"""
13+
pwd = os.getcwd()
14+
15+
for path in paths:
16+
path = os.path.join(pwd, path)
17+
18+
if path and os.path.exists(path):
19+
if os.path.isdir(path):
20+
shutil.rmtree(path)
21+
else:
22+
os.remove(path)
23+
24+
25+
def set_gh_actions():
26+
"""Remove GitHub actions if not enabled."""
27+
if "{{ cookiecutter.github_actions }}" != "yes":
28+
remove([".github"])
29+
30+
31+
def set_aiohttp():
32+
"""Remove aiohttp utility implementation and tests if not enabled."""
33+
if "{{ cookiecutter.aiohttp }}" != "yes":
34+
remove(
35+
[
36+
"{{ cookiecutter.package_name }}/app/utils/aiohttp_client.py",
37+
"tests/unit/app/utils/test_aiohttp_client.py",
38+
]
39+
)
40+
41+
42+
def set_helm():
43+
"""Remove Helm chart if not enabled."""
44+
if "{{ cookiecutter.helm }}" != "yes":
45+
remove(
46+
[
47+
"charts",
48+
".github/workflows/integration.yml",
49+
"build/dev-env.sh",
50+
"manifests",
51+
]
52+
)
53+
54+
55+
def set_redis():
56+
"""Remove Redis utility implementation and tests if not enabled."""
57+
if "{{ cookiecutter.redis }}" != "yes":
58+
remove(
59+
[
60+
"manifests",
61+
"{{ cookiecutter.package_name }}/app/utils/redis.py",
62+
"{{ cookiecutter.package_name }}/config/redis.py",
63+
]
64+
)
65+
66+
67+
def set_nix():
68+
"""Remove Nix expression files if not enabled."""
69+
if "{{ cookiecutter.nix }}" != "yes":
70+
remove(
71+
[
72+
"shell.nix",
73+
"image.nix",
74+
"default.nix",
75+
]
76+
)
77+
78+
79+
if __name__ == "__main__":
80+
set_gh_actions()
81+
set_aiohttp()
82+
set_helm()
83+
set_redis()
84+
set_nix()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[run]
2+
omit =
3+
{{cookiecutter.package_name}}/config/gunicorn.py
4+
{{cookiecutter.package_name}}/__main__.py
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
__pycache__
2+
*.py[cod]
3+
*$py.class
4+
*.egg-info
5+
.installed.cfg
6+
*.egg
7+
htmlcov
8+
.tox/
9+
.pytest_cache
10+
.mypy_cache
11+
.coverage
12+
.coverage.*
13+
.cache
14+
nosetests.xml
15+
coverage.xml
16+
*,cover
17+
.hypothesis
18+
xunit-*.xml
19+
.idea
20+
venv
21+
.venv
22+
.vagrant
23+
.direnv
24+
site
25+
.git
26+
.github
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{%- raw %}
2+
name: Build Docs
3+
4+
on:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
build-docs:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up Python
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: 3.9
19+
- name: Load Poetry cache
20+
id: poetry-cache
21+
uses: actions/cache@v3
22+
with:
23+
path: ${{ env.POETRY_HOME }}
24+
key: ${{ runner.os }}-3.9-${{ hashFiles('./pyproject.toml') }}-${{ hashFiles('./poetry.lock') }}
25+
- name: Build documentation
26+
run: make docs
27+
- name: Archive build artifacts
28+
uses: actions/upload-artifact@v2
29+
with:
30+
name: ${{ format('docs-{0}', github.sha) }}
31+
path: site
32+
retention-days: 60
33+
- name: Deploy to GitHub Pages
34+
uses: crazy-max/[email protected]
35+
with:
36+
target_branch: gh-pages
37+
build_dir: site
38+
commit_message: "Deploy to GitHubPages"
39+
jekyll: false
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
{%- endraw %}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{% raw %}name: K8s integration
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
# This job checks if an identical workflow is being triggered by different
13+
# event and skips it. For instance there is no need to run the same pipeline
14+
# twice for pull_request and push for identical commit sha.
15+
pre_job:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
19+
steps:
20+
- id: skip_check
21+
uses: fkirc/[email protected]
22+
with:
23+
skip_after_successful_duplicate: 'true'
24+
concurrent_skipping: same_content
25+
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]'
26+
test:
27+
needs: pre_job
28+
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
29+
runs-on: macos-12
30+
31+
steps:
32+
- uses: actions/checkout@v2
33+
- name: Run vagrant up
34+
run: vagrant up
35+
- name: Bootstrap minukube cluster and Redis operator
36+
run: vagrant ssh -c "cd /syncd && make dev-env"{% endraw %}
37+
- name: Test exposed {{cookiecutter.project_name}} application
38+
run: vagrant ssh -c 'curl "http://{{cookiecutter.folder_name}}.$(minikube ip).nip.io/api/ready"'

0 commit comments

Comments
 (0)