Fakultas Ilmu Komputer UI

Commit 3903c363 authored by Ryan Karyadiputera's avatar Ryan Karyadiputera
Browse files

test

parent c50f1cf3
Pipeline #73839 passed with stages
in 8 minutes and 5 seconds
......@@ -2,14 +2,10 @@ stages:
- test
- flake8
- build
# - sonarqube
- deploy
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
DOCKER_DRIVER: overlay2
image: python:latest
......@@ -59,36 +55,6 @@ lint:
except:
- CI-CD
# sonarqube:
# image: nuga99/sonar-scanner-python
# stage: sonarqube
# cache:
# key: sonarqube
# paths:
# - .cache/pip
# before_script:
# - python3 -V
# - pip3 install -r requirements.txt
# - echo "DJANGO_SECRET_KEY=$DJANGO_SECRET_KEY" > sip/settings/.env
# - echo "AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID" >> sip/settings/.env
# - echo "AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY" >> sip/settings/.env
# - echo "AWS_STORAGE_BUCKET_NAME=$AWS_STORAGE_BUCKET_NAME" >> sip/settings/.env
# script:
# - if [[ $CI_COMMIT_REF_NAME == staging ]]; then ENVIRON="sip.settings.staging"; else ENVIRON="sip.settings.dev"; fi
# - coverage run --omit='manage.py,**/venv/*,**/python3*/**,core/**,laporan_praktikum/error_message/**,laporan_praktikum/custom_module/**,authentication/cas_wrapper.py,/usr/**' manage.py test --settings=${ENVIRON}
# - coverage report -m
# - coverage xml -i
# - sonar-scanner
# -Dsonar.host.url=https://pmpl.cs.ui.ac.id/sonarqube
# -Dsonar.projectKey=$SONARQUBE_PROJECT_KEY
# -Dsonar.login=$SONARQUBE_TOKEN
# -Dsonar.branch.name=$CI_COMMIT_REF_NAME
# only:
# - master
# - staging
# - development
# - /^.*PBI-.*$/
heroku-deploy:
image: ruby:2.4
stage: deploy
......
FROM python:3.8
# pull official base image
FROM python:3.9.1-alpine
ENV PYTHONUNBUFFERED 1
# set work directory
WORKDIR /usr/src/app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV http_proxy=http://proxy.cs.ui.ac.id:8080/
ENV https_proxy=http://proxy.cs.ui.ac.id:8080/
ENV ftp_proxy=http://proxy.cs.ui.ac.id:8080/
RUN mkdir /app
WORKDIR /app
COPY requirements.txt /app/
RUN pip install -r requirements.txt
COPY .env .env.production
COPY . /app/
# install dependencies
RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt
# RUN chmod +x docker-entrypoint.sh
# copy project
COPY . .
# ENTRYPOINT [ "/app/docker-entrypoint.sh" ]
CMD [ "gunicorn", "sip.wsgi:application", "--bind", "0.0.0.0:8000" ]
\ No newline at end of file
......@@ -42,7 +42,10 @@ POSTGRES_DB=postgres_db_name
```
### __How To Run on Local Development__
1. Buat .env di folder sip/settings/ dengan secret key-nya
1. Buat .env di folder sip/settings/ dengan secret key-nya. Tambahin line ini di file-nya:
```bash
DJANGO_SECRET_KEY="s3cr3t_k3y_c4nn0t_h4ck3d_by_l33t_1337"
```
2. Lakukan makemigrations dan migrate
```bash
python manage.py makemigrations --settings=sip.settings.dev
......@@ -54,5 +57,6 @@ POSTGRES_DB=postgres_db_name
```
### __Pipelines and Coverage__
[![pipeline status](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/itproject-2020/group-a/praktikum-backend/badges/staging/pipeline.svg)](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/itproject-2020/group-a/praktikum-backend) [![coverage report](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/itproject-2020/group-a/praktikum-backend/badges/staging/coverage.svg)](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/itproject-2020/group-a/praktikum-backend)
[![pipeline status](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2021/BB/departemen-ilmu-kesejahteraan-sosial-ui-sistem-informasi-penilaian-dan-database-praktikum-i-dan-ii/praktikum-backend/badges/staging/pipeline.svg)](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2021/BB/departemen-ilmu-kesejahteraan-sosial-ui-sistem-informasi-penilaian-dan-database-praktikum-i-dan-ii/praktikum-backend/commits/staging/)
[![coverage report](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2021/BB/departemen-ilmu-kesejahteraan-sosial-ui-sistem-informasi-penilaian-dan-database-praktikum-i-dan-ii/praktikum-backend/badges/staging/coverage.svg)](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2021/BB/departemen-ilmu-kesejahteraan-sosial-ui-sistem-informasi-penilaian-dan-database-praktikum-i-dan-ii/praktikum-backend/commits/staging/)
This diff is collapsed.
venv
env
__pycache__/
*.pyc
.example.env.dev
.example.env.production
.example.env.staging
sip/settings/dev.py
sip/settings/production.py
\ No newline at end of file
# Created by https://www.toptal.com/developers/gitignore/api/python,django,vscode,sonarqube,sonar
# Edit at https://www.toptal.com/developers/gitignore?templates=python,django,vscode,sonarqube,sonar
### Quick Push Script
push.py
push.cmd
### Quick Coverage Check Script
coverage.cmd
### Django ###
*.log
*.pot
*.pyc
__pycache__/
local_settings.py
db.sqlite3
sip/db.sqlite3
db.sqlite3-journal
media
# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
# in your Git repository. Update and uncomment the following line accordingly.
# <django-project-name>/staticfiles/
### Django.Python Stack ###
# Byte-compiled / optimized / DLL files
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.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
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
pytestdebug.log
# Translations
*.mo
# Django stuff:
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
doc/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# 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
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
pythonenv*
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# profiling data
.prof
### Python ###
# Byte-compiled / optimized / DLL files
# C extensions
# Distribution / packaging
# 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.
# Installer logs
# Unit test / coverage reports
# Translations
# Django stuff:
# Flask stuff:
# Scrapy stuff:
# Sphinx documentation
# PyBuilder
# Jupyter Notebook
# IPython
# pyenv
# pipenv
# 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.
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
# Celery stuff
# SageMath parsed files
# Environments
# Spyder project settings
# Rope project settings
# mkdocs documentation
# mypy
# Pyre type checker
# pytype static type analyzer
# profiling data
### Sonar ###
#Sonar generated dir
/.sonar/
### SonarQube ###
# SonarQube ignore files.
#
# https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner
# Sonar Scanner working directories
.sonar/
.scannerwork/
# http://www.sonarlint.org/commandline/
# SonarLint working directories, configuration files (including credentials)
.sonarlint/
### vscode ###
.vscode/*
.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# End of https://www.toptal.com/developers/gitignore/api/python,django,vscode,sonarqube,sonar
# Data seed
data_seed/lembaga*
data_seed_v2
# Script bash
migrate.local
check-code.sh
serve.sh
credentials
**/media/
# Backend database
db_backend/
stages:
- test
- flake8
- build
# - sonarqube
- deploy
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
DOCKER_DRIVER: overlay2
image: python:latest
cache:
key: test
paths:
- .cache/pip
- venv/
before_script:
- python3 -V
- pip3 install virtualenv
- virtualenv venv
- source venv/bin/activate
- pip3 install -r requirements.txt
- echo "DJANGO_SECRET_KEY=$DJANGO_SECRET_KEY" > sip/settings/.env
- echo "AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID" >> sip/settings/.env
- echo "AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY" >> sip/settings/.env
- echo "AWS_STORAGE_BUCKET_NAME=$AWS_STORAGE_BUCKET_NAME" >> sip/settings/.env
dev-test:
stage: test
script:
- python3 manage.py collectstatic --settings=sip.settings.staging --no-input
- python3 manage.py makemigrations --settings=sip.settings.dev
- python3 manage.py migrate --settings=sip.settings.dev
- python3 manage.py test --settings=sip.settings.dev
only:
- development
- /^.*PBI-.*$/
staging-test:
stage: test
script:
- python3 manage.py collectstatic --settings=sip.settings.staging --no-input
- python3 manage.py makemigrations --settings=sip.settings.staging
- python3 manage.py migrate --settings=sip.settings.staging
- python3 manage.py test --settings=sip.settings.staging
only:
- staging
lint:
stage: flake8
script:
- flake8
allow_failure: true
except:
- CI-CD
# sonarqube:
# image: nuga99/sonar-scanner-python
# stage: sonarqube
# cache:
# key: sonarqube
# paths:
# - .cache/pip
# before_script:
# - python3 -V
# - pip3 install -r requirements.txt
# - echo "DJANGO_SECRET_KEY=$DJANGO_SECRET_KEY" > sip/settings/.env
# - echo "AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID" >> sip/settings/.env
# - echo "AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY" >> sip/settings/.env
# - echo "AWS_STORAGE_BUCKET_NAME=$AWS_STORAGE_BUCKET_NAME" >> sip/settings/.env
# script:
# - if [[ $CI_COMMIT_REF_NAME == staging ]]; then ENVIRON="sip.settings.staging"; else ENVIRON="sip.settings.dev"; fi
# - coverage run --omit='manage.py,**/venv/*,**/python3*/**,core/**,laporan_praktikum/error_message/**,laporan_praktikum/custom_module/**,authentication/cas_wrapper.py,/usr/**' manage.py test --settings=${ENVIRON}
# - coverage report -m
# - coverage xml -i
# - sonar-scanner
# -Dsonar.host.url=https://pmpl.cs.ui.ac.id/sonarqube
# -Dsonar.projectKey=$SONARQUBE_PROJECT_KEY
# -Dsonar.login=$SONARQUBE_TOKEN
# -Dsonar.branch.name=$CI_COMMIT_REF_NAME
# only:
# - master
# - staging
# - development
# - /^.*PBI-.*$/
heroku-deploy:
image: ruby:2.4
stage: deploy
cache: {}
before_script:
- gem install dpl
- wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
script:
- dpl --provider=heroku --app=$HEROKU_APPNAME --api-key=$HEROKU_APIKEY
- export HEROKU_API_KEY=$HEROKU_APIKEY
only:
- staging
- /^.*URGENT-.*$/
FROM python:3.8
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV http_proxy=http://proxy.cs.ui.ac.id:8080/
ENV https_proxy=http://proxy.cs.ui.ac.id:8080/
ENV ftp_proxy=http://proxy.cs.ui.ac.id:8080/
RUN mkdir /app
WORKDIR /app
COPY requirements.txt /app/
RUN pip install -r requirements.txt
COPY .env .env.production
COPY . /app/
# RUN chmod +x docker-entrypoint.sh
# ENTRYPOINT [ "/app/docker-entrypoint.sh" ]
web: DJANGO_SETTINGS_MODULE=sip.settings.staging gunicorn sip.wsgi --log-file -
# MKPPL-SI Penilaian dan Evaluasi Praktikum
## __Getting Started__
Pastikan **python3** dan **git** sudah terinstall pada laptop/komputer Anda.
```bash
git clone https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2020/mkppl-si-penilaian-dan-evaluasi-praktikum.git
cd mkppl-si-penilaian-dan-evaluasi-praktikum
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```
## __Setup Local__
### Settings Directory Tree
```
...
+-- sip
| +-- settings
| | +-- static (generated)
| | +-- dev.py (for local)
| | +-- production.py (for production)
| | +-- staging.py (for staging)
|
...
```
### __Environment Variables__
Contoh bentuk file `.env.dev`, ini akan di-*load* pada `settings/dev.py`
***Catatan: file ini dapat berubah menyesuaikan flow, ini hanya contoh.***
```
SECRET_KEY="sm1l3_sw33t_s1st3r_sUrpr1s3_s3rvc1c3"
DB_NAME=db_name
DB_USER=admin
DB_PASS=db_password
DB_HOST=db
DB_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres_password
POSTGRES_DB=postgres_db_name
```
### __How To Run on Local Development__
1. Buat .env di folder sip/settings/ dengan secret key-nya
2. Lakukan makemigrations dan migrate
```bash
python manage.py makemigrations --settings=sip.settings.dev
python manage.py migrate --settings=sip.settings.dev
```
3. Jalankan aplikasi menggunakan `manage.py runserver` pada port 8000, spesifikasi settings yang digunakan adalah `dev` atau local.
```bash
python manage.py runserver 8000 --settings=<path>.sip.settings.dev
```
### __Pipelines and Coverage__
[![pipeline status](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/itproject-2020/group-a/praktikum-backend/badges/staging/pipeline.svg)](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/itproject-2020/group-a/praktikum-backend) [![coverage report](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/itproject-2020/group-a/praktikum-backend/badges/staging/coverage.svg)](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/itproject-2020/group-a/praktikum-backend)
from .models import (
Mahasiswa,
SupervisorSekolah,
SupervisorLembaga,
KoordinatorKuliah,
Administrator,
User,
Periode,
Config
)
from django.contrib import admin
"""Profile model admin class."""
@admin.register(Mahasiswa)
class MahasiswaAdmin(admin.ModelAdmin):
pass
"""Profile model admin class."""
@admin.register(SupervisorSekolah)
class SupervisorSekolahAdmin(admin.ModelAdmin):
pass
"""Profile model admin class."""
@admin.register(KoordinatorKuliah)
class KoordinatorKuliahAdmin(admin.ModelAdmin):
pass
"""Profile model admin class."""
@admin.register(SupervisorLembaga)
class SupervisorLembagaAdmin(admin.ModelAdmin):
pass
"""Profile model admin class."""
@admin.register(Administrator)
class AdministratorAdmin(admin.ModelAdmin):
pass
@admin.register(Periode)
class PeriodeAdmin(admin.ModelAdmin):
pass
@admin.register(Config)
class ConfigAdmin(admin.ModelAdmin):
pass
from django.apps import AppConfig
class AuthenticationConfig(AppConfig):
name = 'authentication'
verbose_name = "Authentication"