Fakultas Ilmu Komputer UI

Commit c50f1cf3 authored by Ryan Karyadiputera's avatar Ryan Karyadiputera
Browse files

test

parent a4b8328b
Pipeline #73837 passed with stages
in 7 minutes and 37 seconds
......@@ -2,10 +2,14 @@ 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
......@@ -55,6 +59,36 @@ 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
......
# pull official base image
FROM python:3.9.1-alpine
FROM python:3.8
# set work directory
WORKDIR /usr/src/app
ENV PYTHONUNBUFFERED 1
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install dependencies
RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt
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/
# copy project
COPY . .
# RUN chmod +x docker-entrypoint.sh
CMD [ "gunicorn", "sip.wsgi:application", "--bind", "0.0.0.0:8000" ]
\ No newline at end of file
# ENTRYPOINT [ "/app/docker-entrypoint.sh" ]
......@@ -42,10 +42,7 @@ POSTGRES_DB=postgres_db_name
```
### __How To Run on Local Development__
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"
```
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
......@@ -57,6 +54,5 @@ POSTGRES_DB=postgres_db_name
```
### __Pipelines and Coverage__
[![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/)
[![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)
......@@ -112,7 +112,7 @@ class ManualLogoutView(RetrieveAPIView):
def get(self, request):
update_last_login(datetime.now(), request.user)
return HttpResponseRedirect("http://ppl-berkah.herokuapp.com/")
return HttpResponseRedirect("http://sipraktikum-frontend-2020-a.herokuapp.com")
class UserProfileMahasiswaView(RetrieveAPIView): # pragma: no cover
......
This diff is collapsed.
......@@ -6,4 +6,3 @@ admin.site.register(models.Lembaga)
admin.site.register(models.Institusi)
admin.site.register(models.Tema)
admin.site.register(models.LingkupKerja)
admin.site.register(models.ErrorMessage)
......@@ -47,9 +47,3 @@ class Lembaga(models.Model):
def __str__(self):
return self.nama
class ErrorMessage(models.Model):
""" Models for Error Messages """
def not_found(self):
return "tidak ditemukan"
from rest_framework import serializers
from lembaga.models import Lembaga, Institusi, Tema, LingkupKerja, ErrorMessage
from lembaga.models import Lembaga, Institusi, Tema, LingkupKerja
from rest_framework.exceptions import NotFound
from drf_extra_fields.fields import Base64ImageField
......@@ -51,12 +51,10 @@ class LembagaSerializer(serializers.ModelSerializer):
nama_tema = validated_data.pop('tema')['nama']
error = ErrorMessage
try:
tema = Tema.objects.get(nama=nama_tema)
except Tema.DoesNotExist:
raise NotFound(detail="Tema dengan nama " + str(nama_tema) + ErrorMessage.not_found(error))
raise NotFound(detail="Tema dengan nama " + str(nama_tema) + " tidak ditemukan")
nama_lingkup_kerja = validated_data.pop('lingkup_kerja')
final_query = []
......@@ -65,7 +63,7 @@ class LembagaSerializer(serializers.ModelSerializer):
try:
lingkup_kerja = LingkupKerja.objects.get(nama=lingkup["nama"])
except LingkupKerja.DoesNotExist:
raise NotFound(detail="Lingkup kerja dengan nama " + str(lingkup["nama"]) + ErrorMessage.not_found(error))
raise NotFound(detail="Lingkup kerja dengan nama " + str(lingkup["nama"]) + " tidak ditemukan")
final_query.append(lingkup_kerja)
......@@ -73,7 +71,7 @@ class LembagaSerializer(serializers.ModelSerializer):
try:
institusi = Institusi.objects.get(nama=nama_institusi)
except Institusi.DoesNotExist:
raise NotFound(detail="Institusi dengan nama " + str(nama_institusi) + ErrorMessage.not_found(error))
raise NotFound(detail="Institusi dengan nama " + str(nama_institusi) + " tidak ditemukan")
lembaga = Lembaga()
lembaga.nama = nama
......@@ -100,12 +98,10 @@ class LembagaSerializer(serializers.ModelSerializer):
alamat = validated_data.pop('alamat')
nama_tema = validated_data.pop('tema')['nama']
error = ErrorMessage
try:
tema = Tema.objects.get(nama=nama_tema)
except Tema.DoesNotExist:
raise NotFound(detail="Tema dengan nama " + str(nama_tema) + ErrorMessage.not_found(error))
raise NotFound(detail="Tema dengan nama " + str(nama_tema) + " tidak ditemukan")
nama_lingkup_kerja = validated_data.pop('lingkup_kerja')
final_query = []
......@@ -114,7 +110,7 @@ class LembagaSerializer(serializers.ModelSerializer):
try:
lingkup_kerja = LingkupKerja.objects.get(nama=lingkup["nama"])
except LingkupKerja.DoesNotExist:
raise NotFound(detail="Lingkup kerja dengan nama " + str(lingkup["nama"]) + ErrorMessage.not_found(error))
raise NotFound(detail="Lingkup kerja dengan nama " + str(lingkup["nama"]) + " tidak ditemukan")
final_query.append(lingkup_kerja)
......@@ -122,7 +118,7 @@ class LembagaSerializer(serializers.ModelSerializer):
try:
institusi = Institusi.objects.get(nama=nama_institusi)
except Institusi.DoesNotExist:
raise NotFound(detail="Institusi dengan nama " + str(nama_institusi) + ErrorMessage.not_found(error))
raise NotFound(detail="Institusi dengan nama " + str(nama_institusi) + " tidak ditemukan")
lembaga.nama = nama
lembaga.jenis_pelayanan = jenis_pelayanan
......
......@@ -5,10 +5,7 @@ stages:
- deploy
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
DOCKER_DRIVER: overlay2
image: python:latest
......
# pull official base image
FROM python:3.9.1-alpine
# set work directory
WORKDIR /usr/src/app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install dependencies
RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt
# copy project
COPY . .
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/)
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