Skip to content

Commit 870257b

Browse files
Dmitriy Golubdagolub
authored andcommitted
Release 0.0.1
add linters flake, black, bandit and mypy add PyTest and test coverage 92% fix docker-compose add theme for frontend
1 parent a4afa5b commit 870257b

141 files changed

Lines changed: 43195 additions & 977 deletions

File tree

Some content is hidden

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

.coverage

52 KB
Binary file not shown.

.env

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
SERVER_NAME=localhost
22
HOSTNAME=d2df06456679
33
DOMAIN=localhost
4-
PROJECT_NAME="app.mongodb.tech"
5-
STACK_NAME="app.mongodb.tech"
4+
PROJECT_NAME=app.mongodb.tech
5+
STACK_NAME=app.mongodb.tech
66
SERVER_HOST=http://localhost
77

88
SECRET_KEY=99d3b1f01aa639e4a76f4fc281fc834747a543720ba4c8a8648ba755aef9be7f
99
USERS_OPEN_REGISTRATION=False
10-
FIRST_SUPERUSER="admin@app.mongodb.tech
10+
FIRST_SUPERUSER=admin@app.mongodb.tech
1111
FIRST_SUPERUSER_PASSWORD=99d3b1f01aa639e4a76f4fc281fc834747a543720ba4c8a8648ba755aef9be7f
1212

13-
14-
EMAILS_FROM_EMAIL="info@mongodb.tech"
13+
EMAIL_TEMPLATES_DIR=email-templates/build
14+
EMAILS_FROM_EMAIL=info@mongodb.tech
1515
SMTP_HOST=
1616
SMTP_USER=
1717
SMTP_PASSWORD=
@@ -27,3 +27,10 @@ DOCKER_IMAGE_CELERYWORKER=celeryworker
2727
DOCKER_IMAGE_FRONTEND=frontend
2828

2929
SENTRY_DSN=
30+
31+
32+
MONGO_USER=root
33+
MONGO_PASS=mongo
34+
MONGO_HOST=localhost
35+
MONGO_DB=mongotech
36+
MONGO_PORT=27017

.flake8

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[flake8]
2+
ignore = E226,E302,E41
3+
max-line-length = 160
4+
exclude = tests/*
5+
max-complexity = 10

.github/workflows/bandit.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: bandit
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
name: Bandit
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python-version: ["3.9"]
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: jpetrucciani/bandit-check@master
15+
with:
16+
path: "./backend/app/app"
17+
bandit_flags: '-x ./backend/app/app/tests'

.github/workflows/black.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: black
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
name: Black
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python-version: [ "3.9" ]
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: rickstaa/action-black@v1
15+
with:
16+
black_args: ". --check"

.github/workflows/flake8.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: flake8
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: ["3.9"]
11+
name: Flake8
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Checkout PyTorch
15+
uses: actions/checkout@master
16+
- name: Install flake8
17+
run: pip install flake8
18+
- name: Run flake8
19+
uses: suo/flake8-github-action@releases/v1

.github/workflows/mypy.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: mypy
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: [ "3.9" ]
11+
name: MyPy
12+
steps:
13+
- uses: actions/checkout@v1
14+
- name: Install Dependencies and run MyPy
15+
run: |
16+
python -m venv venv
17+
source ./venv/bin/activate
18+
pip install poetry
19+
pip install --upgrade pip
20+
cd backend/app
21+
poetry install
22+
../../venv/bin/mypy ./

.github/workflows/pytest.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: PyTest
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
name: "PyTest"
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Set up Python 3.9
12+
uses: actions/setup-python@v2
13+
with:
14+
python-version: 3.9
15+
- name: Install dependencies
16+
run: |
17+
python -m venv venv
18+
source ./venv/bin/activate
19+
pip install --upgrade pip
20+
pip install poetry
21+
cd backend/app
22+
poetry install
23+
- name: Build coverage percentage
24+
run: |
25+
echo COVERAGE=$(export $(cat .env|xargs);cd backend/app/app;../../../venv/bin/pytest --cache-clear --cov --cov-report term | grep "TOTAL" | awk '{print $4}') >> $GITHUB_ENV
26+
- name: Create coverage Badge
27+
uses: schneegans/dynamic-badges-action@v1.4.0
28+
with:
29+
auth: ${{ secrets.GIST_SECRET }}
30+
gistID: 730cda43e9bff219b52954a6390b1c24
31+
filename: mongotech.json
32+
label: PyTest
33+
message: ${{ env.COVERAGE }}
34+
color: success

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ venv
33
.vscode
44
.mypy_cache
55
docker-stack.yml
6+
frontent/node_modules

.gitlab-ci.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
stages:
2+
- test
3+
4+
before_script:
5+
- mkdir ~/.ssh
6+
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
7+
- chmod 600 ~/.ssh/id_rsa
8+
- ssh-keyscan -H mongodb.tech >> ~/.ssh/known_hosts
9+
10+
black:
11+
stage: test
12+
image: tiangolo/uvicorn-gunicorn-fastapi:python3.9
13+
script:
14+
- pip install black
15+
- black backend/app/app
16+
after_script:
17+
- ./get-updated-badge.sh black
18+
- scp black-badges.json ubuntu@mongodb.tech:mongodb/badges/black.json
19+
bandit:
20+
stage: test
21+
image: tiangolo/uvicorn-gunicorn-fastapi:python3.9
22+
script:
23+
- pip install bandit
24+
- bandit backend/app/app
25+
after_script:
26+
- ./get-updated-badge.sh bandit
27+
- scp bandit-badges.json ubuntu@mongodb.tech:mongodb/badges/bandit.json
28+
29+
isort:
30+
stage: test
31+
image: tiangolo/uvicorn-gunicorn-fastapi:python3.9
32+
script:
33+
- pip install isort
34+
- isort backend/app/app
35+
after_script:
36+
- ./get-updated-badge.sh isort
37+
- scp isort-badges.json ubuntu@mongodb.tech:mongodb/badges/isort.json
38+
39+
flake8:
40+
stage: test
41+
image: tiangolo/uvicorn-gunicorn-fastapi:python3.9
42+
script:
43+
- pip install flake8
44+
- flake8 backend/app/app
45+
after_script:
46+
- ./get-updated-badge.sh flake8
47+
- scp flake8-badges.json ubuntu@mongodb.tech:mongodb/badges/flake8.json
48+
49+
mypy:
50+
stage: test
51+
image: tiangolo/uvicorn-gunicorn-fastapi:python3.9
52+
script:
53+
- pip install mypy
54+
- mypy backend/app/app
55+
after_script:
56+
- ./get-updated-badge.sh mypy
57+
- scp mypy-badges.json ubuntu@mongodb.tech:mongodb/badges/mypy.json
58+
59+
pytest:
60+
stage: test
61+
image: tiangolo/uvicorn-gunicorn-fastapi:python3.9
62+
variables:
63+
PROJECT_NAME: "app.mongodb.tech"
64+
SERVER_NAME: localhost
65+
SERVER_HOST: "http://localhost"
66+
FIRST_SUPERUSER: "admin@app.mongodb.tech"
67+
FIRST_SUPERUSER_PASSWORD: 99d3b1f01aa639e4a76f4fc281fc834747a543720ba4c8a8648ba755aef9be7f
68+
EMAIL_TEMPLATES_DIR: "email-templates/build"
69+
before_script:
70+
- cd ./backend/app
71+
- python3.9 -m venv venv
72+
- source ./venv/bin/activate
73+
script:
74+
- pip install pytest pytest-cov poetry
75+
- poetry install
76+
- cd ./app
77+
- rm backend_pre_start.py
78+
- rm tests_pre_start.py
79+
- rm celeryworker_pre_start.py
80+
- rm core/celery_app.py
81+
- rm db/base.py
82+
- rm db/init_db.py
83+
- rm helpers.py
84+
- rm initial_data.py
85+
- rm worker.py
86+
- python3.9 -m pytest --cov=app --cov-report=term --cov-report=html tests .
87+
- coverage report
88+
- coverage html
89+
coverage: '/^TOTAL.+?(\d+\%)$/'
90+
artifacts:
91+
when: always
92+
paths:
93+
- ./backend/app/app/htmlcov
94+
expire_in: 14 days

0 commit comments

Comments
 (0)