Fakultas Ilmu Komputer UI

Commit 735b1115 authored by Muhammad Ilham Peruzzi's avatar Muhammad Ilham Peruzzi
Browse files

add config for deploy

parent 428c5c52
migrate: bash deployment.sh
web: gunicorn superlists.wsgi --log-file -
\ No newline at end of file
#!/bin/bash
python manage.py makemigrations
python manage.py migrate
\ No newline at end of file
from selenium import webdriver
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import time
import unittest
import environ
root = environ.Path(__file__)
env = environ.Env(DEBUG=(bool, False), )
environ.Env.read_env('.env')
HEROKU_APP_HOST = env("HEROKU_APP_HOST")
print("HEROKU_APP_HOST is", HEROKU_APP_HOST)
MAX_WAIT = 5
class NewVisitorTest(unittest.TestCase):
def setUp(self):
chrome_options = Options()
chrome_options.add_argument('--dns-prefetch-disable')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--headless')
chrome_options.add_argument('disable-gpu')
try:
self.browser = webdriver.Chrome('./chromedriver.exe', chrome_options=chrome_options)
except:
self.browser = webdriver.Chrome('./chromedriver', chrome_options=chrome_options)
super(NewVisitorTest, self).setUp()
def tearDown(self):
self.browser.quit()
def test_can_start_a_list_and_retrieve_it_later(self):
self.browser.get(HEROKU_APP_HOST)
inputbox = self.browser.find_element_by_id('id_new_item')
self.assertEqual(
inputbox.get_attribute('placeholder'),
'Enter a to-do item'
)
inputbox.send_keys('Buy peacock feathers')
inputbox.send_keys(Keys.ENTER)
inputbox = self.browser.find_element_by_id('id_new_item')
inputbox.send_keys('Use peacock feathers to make a fly')
inputbox.send_keys(Keys.ENTER)
for i in range(3):
inputbox = self.browser.find_element_by_id('id_new_item')
inputbox.send_keys('Activity' + str(i))
inputbox.send_keys(Keys.ENTER)
assert 'oh tidak' in self.browser.page_source
if __name__ == '__main__':
unittest.main(warnings='ignore')
\ No newline at end of file
stages:
- test
- deploy
- test_functional
Test:
image: python:3.7
stage: test
before_script:
- pip3 install --upgrade pip
- pip3 install -r requirements.txt
script:
- python3 manage.py makemigrations
- python3 manage.py migrate
- python3 manage.py test
tags:
- test
Deployment:
image: ruby:2.4
stage: deploy
before_script:
- gem install dpl
- wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
script:
- export HEROKU_API_KEY=$HEROKU_APIKEY
- dpl --provider=heroku --app=$HEROKU_APPNAME --api-key=$HEROKU_APIKEY
- heroku ps:scale web=1 migrate=1 --app $HEROKU_APPNAME
- heroku ps:restart --app=$HEROKU_APPNAME
environment:
name: production
url: $HEROKU_APP_HOST
TestFunctional:
image: python:3.7
stage: test_functional
before_script:
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
- echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list
- pip3 install -r requirements.txt
- apt-get update -qq && apt-get install -y -qq unzip
- apt-get install -y google-chrome-stable
- apt-get install -y xvfb
- wget https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip
- unzip chromedriver_linux64.zip
- python manage.py runserver 8000 &
when: on_success
script:
- python3 functional_tests_chrome.py
\ No newline at end of file
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