Fakultas Ilmu Komputer UI

Commit 08bb2dee authored by Ryan Karyadiputera's avatar Ryan Karyadiputera
Browse files

test3

parent 0da601e4
Pipeline #81493 failed with stages
in 8 minutes and 45 seconds
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
......@@ -25,6 +30,65 @@ before_script:
- 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
......
# 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" ]
web: DJANGO_SETTINGS_MODULE=sip.settings.staging gunicorn sip.wsgi --log-file -
release: chmod 777 migrate.sh && ./migrate.sh
\ No newline at end of file
......@@ -60,6 +60,7 @@ pdfkit==0.6.1
Pillow==8.0.1
pipenv==2018.11.26
pluggy==0.13.1
psycopg2==2.8.6
psycopg2-binary==2.8.6
py==1.8.1
pycodestyle==2.6.0
......
......@@ -2,9 +2,3 @@ DJANGO_SECRET_KEY
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_STORAGE_BUCKET_NAME
SQL_ENGINE
SQL_DATABASE
SQL_USER
SQL_PASSWORD
SQL_HOST
SQL_PORT
\ No newline at end of file
DJANGO_SECRET_KEY
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_STORAGE_BUCKET_NAME
SQL_ENGINE
SQL_DATABASE
SQL_USER
SQL_PASSWORD
SQL_HOST
SQL_PORT
\ No newline at end of file
DJANGO_SECRET_KEY="s3cr3t_k3y_c4nn0t_h4ck3d_by_l33t_1337"
AWS_ACCESS_KEY_ID="AKIAZQWXBKG5M6KKHZSP"
AWS_SECRET_ACCESS_KEY="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"
AWS_STORAGE_BUCKET_NAME="sipraktikum-storage"
\ No newline at end of file
......@@ -14,8 +14,6 @@ import environ
import os
import dj_database_url
from datetime import timedelta
import mimetypes
mimetypes.add_type("text/css", ".css", True)
# Environ Setup
......@@ -104,7 +102,6 @@ REST_FRAMEWORK = {
'TEST_REQUEST_DEFAULT_FORMAT': 'json',
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
),
}
......
......@@ -97,7 +97,6 @@ REST_FRAMEWORK = {
'TEST_REQUEST_DEFAULT_FORMAT': 'json',
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
),
}
......@@ -106,13 +105,9 @@ REST_FRAMEWORK = {
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": env("SQL_ENGINE"),
"NAME": env("SQL_DATABASE"),
"USER": env("SQL_USER"),
"PASSWORD": env("SQL_PASSWORD"),
"HOST": env("SQL_HOST"),
"PORT": env("SQL_PORT"),
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
......@@ -224,10 +219,10 @@ JWT_AUTH = {
'JWT_AUTH_COOKIE': None,
}
SUCCESS_SSO_AUTH_REDIRECT = "http://ppl-berkah.herokuapp.com/"
SUCCESS_SSO_AUTH_REDIRECT = "http://sipraktikum-frontend-2020-a.herokuapp.com/"
CORS_ORIGIN_WHITELIST = [
"http://ppl-berkah.herokuapp.com/",
"http://sipraktikum-frontend-2020-a.herokuapp.com",
"http://localhost:8000",
"http://127.0.0.1:8000",
]
......
......@@ -15,11 +15,7 @@ import os
# import sys
import dj_database_url
from datetime import timedelta
import mimetypes
mimetypes.add_type("text/css", ".css", True)
#env = environ.Env()
#environ.Env.read_env() # Reading .env file
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
......@@ -28,10 +24,10 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv('DJANGO_SECRET_KEY', "s3cr3t_k3y_c4nn0t_h4ck3d_by_l33t_1337")
SECRET_KEY = os.environ.get("DJANGO_SECRET_KEY")
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = False
# HOST_URL = os.getenv('HOST_URL')
......@@ -101,7 +97,6 @@ REST_FRAMEWORK = {
'TEST_REQUEST_DEFAULT_FORMAT': 'json',
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
),
}
......@@ -177,7 +172,7 @@ AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
AWS_LOCATION = 'static'
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
STATICFILES_DIRS = [
'static/',
os.path.join(BASE_DIR, "static"),
......@@ -236,7 +231,7 @@ JWT_AUTH = {
'JWT_AUTH_COOKIE': None,
}
SUCCESS_SSO_AUTH_REDIRECT = "http://ppl-berkah.herokuapp.com/"
SUCCESS_SSO_AUTH_REDIRECT = "http://sipraktikum-frontend-2020-a.herokuapp.com/"
CORS_ORIGIN_ALLOW_ALL = True
# CORS_ORIGIN_WHITELIST = [
......
......@@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sip.settings.production')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sip.settings')
application = get_wsgi_application()
Markdown is supported
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