Fakultas Ilmu Komputer UI

Commit 10b4f6e4 authored by addffa's avatar addffa
Browse files

Merge branch 'testing' of...

Merge branch 'testing' of https://gitlab.cs.ui.ac.id/sizakat/5.0/sizakat-backend into PBI-15-pencatatan_mustahik
parents 3376c467 630d488d
plugins:
pep8:
enabled: true
pylint:
enabled: true
plugins:
- django
isort:
enabled: true
radon:
enabled: true
sonar-python:
enabled: true
# https://editorconfig.org/
root = true
[*]
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
charset = utf-8
# Docstrings and comments use max_line_length = 79
[*.py]
max_line_length = 119
# The JSON files contain newlines inconsistently
[*.json]
indent_size = 2
insert_final_newline = ignore
# Makefiles always use tabs for indentation
[Makefile]
indent_style = tab
# https://git-scm.com/docs/gitattributes/#_end_of_line_conversion
* text=auto
# Django #
# Created by https://www.toptal.com/developers/gitignore/api/django
# Edit at https://www.toptal.com/developers/gitignore?templates=django
### Django ###
*.log *.log
*.pot *.pot
*.pyc *.pyc
__pycache__ __pycache__/
local_settings.py
db.sqlite3 db.sqlite3
db.sqlite3-journal
media media
# Backup files # # If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
*.bak # in your Git repository. Update and uncomment the following line accordingly.
# <django-project-name>/staticfiles/
# If you are using PyCharm #
.idea/**/workspace.xml ### Django.Python Stack ###
.idea/**/tasks.xml # Byte-compiled / optimized / DLL files
.idea/dictionaries
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/gradle.xml
.idea/**/libraries
*.iws /out/
# Python #
*.py[cod] *.py[cod]
*$py.class *$py.class
# C extensions
*.so
# Distribution / packaging # Distribution / packaging
.Python build/ .Python
build/
develop-eggs/ develop-eggs/
dist/ dist/
downloads/ downloads/
...@@ -41,9 +38,16 @@ parts/ ...@@ -41,9 +38,16 @@ parts/
sdist/ sdist/
var/ var/
wheels/ wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/ *.egg-info/
.installed.cfg .installed.cfg
*.egg *.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest *.manifest
*.spec *.spec
...@@ -54,33 +58,64 @@ pip-delete-this-directory.txt ...@@ -54,33 +58,64 @@ pip-delete-this-directory.txt
# Unit test / coverage reports # Unit test / coverage reports
htmlcov/ htmlcov/
.tox/ .tox/
.nox/
.coverage .coverage
.coverage.* .coverage.*
.cache .cache
.pytest_cache/
nosetests.xml nosetests.xml
coverage.xml coverage.xml
*.cover *.cover
*.py,cover
.hypothesis/ .hypothesis/
.pytest_cache/
# Translations
*.mo
# Django stuff:
# Flask stuff:
instance/
.webassets-cache
# staticfiles # Scrapy stuff:
staticfiles/ .scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook # Jupyter Notebook
.ipynb_checkpoints .ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv # pyenv
.python-version .python-version
# celery # pipenv
celerybeat-schedule.* # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files # SageMath parsed files
*.sage.py *.sage.py
# Environments # Environments
.env *.env
.db.env
.venv .venv
env/ env/
venv/ venv/
...@@ -88,36 +123,25 @@ ENV/ ...@@ -88,36 +123,25 @@ ENV/
env.bak/ env.bak/
venv.bak/ venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation # mkdocs documentation
/site /site
# mypy # mypy
.mypy_cache/ .mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Sublime Text # # End of https://www.toptal.com/developers/gitignore/api/django
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
*.sublime-workspace
*.sublime-project
# sftp configuration file
sftp-config.json
# Package control specific files Package
Control.last-run
Control.ca-list
Control.ca-bundle
Control.system-ca-bundle
GitHub.sublime-settings
# Visual Studio Code #
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history
# misc
.DS_Store
include:
- template: Code-Quality.gitlab-ci.yml
- template: SAST.gitlab-ci.yml
- template: Secret-Detection.gitlab-ci.yml
- template: Dependency-Scanning.gitlab-ci.yml
- template: License-Scanning.gitlab-ci.yml
stages:
- test
- deploy
code_quality:
tags:
- docker
artifacts:
paths: [gl-code-quality-report.json]
sast:
tags:
- docker
artifacts:
paths: [gl-sast-report.json]
django-test:
image: python:3.8.3
stage: test
variables:
SECRET_KEY: "2c4=+s-cv(@z%vs_zkw*(+juf=)0&j1(0yn^ekap)s+z2jsqt3"
ALLOWED_HOSTS: "*"
DEBUG: 1
before_script:
- pip install -r requirements.txt
- python manage.py migrate
script:
- coverage run --include='sizakat/*' manage.py test
- coverage report -m
when: on_success
deploy-development:
image:
name: alpine/git:latest
entrypoint: [""]
stage: deploy
environment: development
variables:
GIT_URL: git@$REMOTE_SERVER:sizakat-5.0-backend.git
before_script:
- mkdir ~/.ssh
- cat "$SSH_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- mv "$KNOWN_HOSTS" ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- git config remote.development.url >&- || git remote add development $GIT_URL
- git checkout $CI_COMMIT_TAG
- git push --force development $CI_COMMIT_TAG 2>&1 | tee git-push.log
- "$(grep -E 'remote: Return with exit [0-9]+' git-push.log | grep -oE 'exit [0-9]+')"
rules:
- if: '$CI_COMMIT_TAG =~ /^development-\d+$/'
deploy-testing:
image:
name: alpine/git:latest
entrypoint: [""]
stage: deploy
environment: testing
variables:
GIT_URL: git@$REMOTE_SERVER:sizakat-5.0-backend.git
before_script:
- mkdir ~/.ssh
- cat "$SSH_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- mv "$KNOWN_HOSTS" ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- git config remote.testing.url >&- || git remote add testing $GIT_URL
- git checkout $CI_COMMIT_BRANCH
- git push testing $CI_COMMIT_BRANCH 2>&1 | tee git-push.log
- "$(grep -E 'remote: Return with exit [0-9]+' git-push.log | grep -oE 'exit [0-9]+')"
rules:
- if: '$CI_COMMIT_BRANCH == "testing"'
## Pipeline status and coverage report
[![pipeline status](https://gitlab.cs.ui.ac.id/sizakat/5.0/sizakat-backend/badges/master/pipeline.svg)](https://gitlab.cs.ui.ac.id/sizakat/5.0/sizakat-backend/-/commits/master)
[![coverage report](https://gitlab.cs.ui.ac.id/sizakat/5.0/sizakat-backend/badges/master/coverage.svg)](https://gitlab.cs.ui.ac.id/sizakat/5.0/sizakat-backend/-/commits/master)
# SiZakat 5.0
## Environment
### Backend environment
File `.env`:
```
SECRET_KEY=foobarbarfoo
ALLOWED_HOSTS=*
DEBUG=1
SQL_DATABASE=sizakat
SQL_USER=postgres
SQL_PASSWORD=postgres
SQL_HOST=db
SQL_PORT=5432
BACKEND_PORT=8000
```
- `SECRET_KEY`
https://docs.djangoproject.com/en/3.0/ref/settings/#std:setting-SECRET_KEY
- `ALLOWED_HOSTS`
https://docs.djangoproject.com/en/3.0/ref/settings/#std:setting-ALLOWED_HOSTS
- `DEBUG`
https://docs.djangoproject.com/en/3.0/ref/settings/#debug
- `SQL_*`
Pengaturan untuk database
- `BACKEND_PORT`
Port untuk service backend. Digunakan dalam `docker-compose`
### Database environment
File `.db.env`
```
POSTGRES_DB=sizakat
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
```
https://github.com/docker-library/docs/tree/master/postgres#environment-variables
...@@ -4,11 +4,11 @@ services: ...@@ -4,11 +4,11 @@ services:
backend: backend:
build: build:
context: ./ context: ./
command: python manage.py runserver 0.0.0.0:8000 command: gunicorn sizakat.wsgi --bind 0.0.0.0:8000 --log-file -
volumes: volumes:
- ./:/app/backend/ - ./:/app/backend/
ports: ports:
- 8000:8000 - ${BACKEND_PORT:-8000}:8000
env_file: env_file:
- .env - .env
depends_on: depends_on:
......
File mode changed from 100644 to 100755
[pep8]
max-line-length = 119
[isort]
combine_as_imports = true
default_section = THIRDPARTY
include_trailing_comma = true
known_first_party = sizakat
line_length = 79
multi_line_output = 5
...@@ -80,11 +80,18 @@ TEMPLATES = [ ...@@ -80,11 +80,18 @@ TEMPLATES = [
WSGI_APPLICATION = 'sizakat.wsgi.application' WSGI_APPLICATION = 'sizakat.wsgi.application'
# Database # Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases # https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = { DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
if 'SQL_DATABASE' in os.environ:
DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.postgresql', 'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('SQL_DATABASE'), 'NAME': os.environ.get('SQL_DATABASE'),
...@@ -93,8 +100,7 @@ DATABASES = { ...@@ -93,8 +100,7 @@ DATABASES = {
'HOST': os.environ.get('SQL_HOST'), 'HOST': os.environ.get('SQL_HOST'),
'PORT': os.environ.get('SQL_PORT'), 'PORT': os.environ.get('SQL_PORT'),
} }
} }
# Password validation # Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment