Last active
October 31, 2018 14:16
-
-
Save argaghulamahmad/57f76449b9249adf1218188ec72ddeaa to your computer and use it in GitHub Desktop.
func & unit test gitlab yml config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- test | |
- deploy | |
UnitTest: | |
image: python:3.6 | |
stage: test | |
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 | |
- pip install -r requirements.txt | |
- python manage.py makemigrations | |
- python manage.py migrate | |
- 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.43/chromedriver_linux64.zip | |
- unzip chromedriver_linux64.zip | |
- python manage.py collectstatic --no-input | |
- python manage.py runserver 8000 & | |
when: on_success | |
script: | |
- coverage run --include='*' manage.py test | |
- coverage report -m | |
Deployment: | |
image: ruby:2.4 | |
stage: deploy | |
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 | |
- heroku run --app $HEROKU_APPNAME migrate | |
environment: | |
name: production | |
url: $HEROKU_APP_HOST |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
service_log_path = "./chromedriver.log" | |
service_args = ['--verbose'] | |
self.selenium = webdriver.Chrome('./chromedriver', chrome_options=chrome_options) | |
self.selenium.implicitly_wait(25) | |
super(Story6FunctionalTest,self).setUp() | |
Link yang mungkin bermanfaat untuk dibaca pengguna Windows:
https://stackoverflow.com/questions/50143413/errorgpu-process-transport-factory-cc1007-lost-ui-shared-context-while-ini
mantap, terima kasih atas @laymonage
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sebenarnya seperti ini saja sudah cukup:
https://gist.github.com/laymonage/d6eba112de17645f194b3fea0ed72255
Bahkan bagian
runserver
bisa dihapus kalau kita menggunakanLiveServerTestCase
(atauStaticLiveServerTestCase
), dan menggunakanself.live_server_url
untuk mendapatkan root url dari server-nya (karena port yang digunakan default-nya berubah-ubah dan bukan 8000, contoh:self.selenium.get(self.live_server_url + "/status/"
).Cara ini justru yang direkomendasikan (best practice) untuk functional test, karena server yang dijalankan tidak akan menggunakan database dari local server yang biasa kita pakai di development.