This file contains 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
image: python:latest | |
stages: | |
- test | |
- flake8 | |
- build | |
- sonarqube | |
- deploy | |
variables: |
This file contains 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
dev-test: | |
stage: test | |
script: | |
- echo "SECRET_KEY=$SECRET_KEY_DJANGO" > .env.dev | |
- apt-get update -qq | |
- python manage.py collectstatic --settings=sip.settings.dev --no-input | |
- python manage.py runserver 8000 --settings=sip.settings.dev & | |
when: on_success | |
script: | |
- python manage.py test --settings=sip.settings.dev |
This file contains 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
... | |
lint: | |
stage: flake8 | |
script: | |
- flake8 | |
allow_failure: true | |
... |
This file contains 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
... | |
sonarqube: | |
image: nuga99/sonar-scanner-python | |
stage: sonarqube | |
before_script: | |
- python3 -V | |
- pip3 install -r requirements.txt | |
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.6/**,authentication/cas_wrapper.py,/usr/**' manage.py test --settings=${ENVIRON} |
This file contains 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
FROM ubuntu:18.04 | |
RUN mkdir /opt/sonar-scanner && \ | |
mkdir /opt/sonar-scanner/conf && \ | |
mkdir /opt/sonar-scanner/bin | |
WORKDIR /opt/sonar-scanner | |
RUN apt-get update -y && apt-get install -y \ | |
libpq-dev -y \ | |
unzip \ | |
wget \ | |
default-jre \ |
This file contains 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
backend-deploy: | |
image: ruby:2.4 | |
stage: deploy | |
only: | |
- staging | |
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 |
This file contains 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
#!/bin/bash | |
sonar.host.url=http://localhost:9000 | |
sonar.sourceEncoding=UTF-8 |
This file contains 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
class LembagaTestViews(APITestCase): | |
def setUp(self): | |
user_full = User.objects.create_user( | |
username="username2", | |
email="[email protected]", | |
password="password", | |
first_name="User", | |
last_name="Name" | |
) |
This file contains 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
... | |
factory = APIRequestFactory() | |
request = factory.get('/') | |
serializer_context = { | |
'request': Request(request), | |
} | |
class LembagaView(RetrieveAPIView): |
This file contains 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
from datetime import date | |
# Bad | |
x_time = date.now().isoformat() | |
# Good | |
currentDate = date.now().isoformat() |
OlderNewer