Fakultas Ilmu Komputer UI

.gitlab-ci.yml 4 KB
Newer Older
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
1
2
3
4
5
6
7
8
9
variables:
  POSTGRES_DB: $DB_NAME
  POSTGRES_USER: $DB_USER
  POSTGRES_PASSWORD: $DB_PASSWORD
  POSTGRES_HOST_AUTH_METHOD: $DB_HOST_AUTH_METHOD

services:
  - postgres:12.2-alpine

Bayukanta Iqbal Gunawan's avatar
a  
Bayukanta Iqbal Gunawan committed
10
stages:
Bayukanta Iqbal Gunawan's avatar
a    
Bayukanta Iqbal Gunawan committed
11
  - test
M. Abdurrahman's avatar
M. Abdurrahman committed
12
  - linter
13
  - sonarqube
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
14
15
  - staging
  - production
Bayukanta Iqbal Gunawan's avatar
a  
Bayukanta Iqbal Gunawan committed
16

Bayukanta Iqbal Gunawan's avatar
a    
Bayukanta Iqbal Gunawan committed
17
18
19
UnitTest:
  image: python:3.7
  stage: test
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
20
21
22
  only:
    refs:
      - staging
23
  coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+)%/'
Bayukanta Iqbal Gunawan's avatar
a    
Bayukanta Iqbal Gunawan committed
24
25
26
27
28
29
  before_script:
    - pip install -r requirements.txt
    - python manage.py migrate
    - python manage.py collectstatic --no-input
  when: on_success
  script:
30
    - coverage run --include="./*" --omit="manage.py,pplbackend/*" manage.py test
Bayukanta Iqbal Gunawan's avatar
a    
Bayukanta Iqbal Gunawan committed
31
    - coverage report -m
32
    - coverage xml
33
  artifacts:
34
    paths:
35
    - coverage.xml
36

M. Abdurrahman's avatar
M. Abdurrahman committed
37
38
39
Pylint:
  image: python:3.7
  stage: linter
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
40
41
42
  only:
    refs:
      - staging
M. Abdurrahman's avatar
M. Abdurrahman committed
43
44
45
46
47
  allow_failure: true
  before_script:
    - pip install -r requirements.txt
  when: on_success
  script:
48
    - pylint --load-plugins pylint_django --rcfile=./.pylintrc informasi_fasilitas layanan_khusus new_rest_api oauth registrasi
M. Abdurrahman's avatar
M. Abdurrahman committed
49

M. Abdurrahman's avatar
M. Abdurrahman committed
50
SonarScanner:
M. Abdurrahman's avatar
M. Abdurrahman committed
51
52
53
  image: 
    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: [""]
54
  stage: sonarqube
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
55
56
57
  only:
    refs:
      - staging
M. Abdurrahman's avatar
M. Abdurrahman committed
58
59
60
  script:
    - sonar-scanner
      -Dsonar.host.url=https://pmpl.cs.ui.ac.id/sonarqube
61
      -Dsonar.login=$SONARQUBE_TOKEN
M. Abdurrahman's avatar
M. Abdurrahman committed
62
63
      -Dsonar.branch.name=$CI_COMMIT_REF_NAME
      -Dsonar.projectKey=$SONARQUBE_PROJECT_KEY
Bayukanta Iqbal Gunawan's avatar
a    
Bayukanta Iqbal Gunawan committed
64

65
Staging:
66
  image: ruby:2.4
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
67
  stage: staging
68
69
70
71
72
73
  only:
    refs:
      - staging
  before_script:
    - gem install dpl
    - wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
74
  script:
75
76
77
78
79
80
81
    - dpl --provider=heroku --app=$HEROKU_APPNAME_STAGING --api-key=$HEROKU_APIKEY
    - export HEROKU_API_KEY=$HEROKU_APIKEY
    - heroku run --app $HEROKU_APPNAME_STAGING migrate
  environment:
    name: staging
    url: $HEROKU_APP_HOST_STAGING

82
  
Bayukanta Iqbal Gunawan's avatar
a  
Bayukanta Iqbal Gunawan committed
83
84
Deployment:
  image: ruby:2.4
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
85
  stage: production
86
87
  only:
    refs:
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
88
      - docker
Bayukanta Iqbal Gunawan's avatar
a  
Bayukanta Iqbal Gunawan committed
89
  before_script:
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
90
91
92
93
    - apt-get update -qq
    - apt-get install -qq git
    - 'which ssh-agent || ( apt-get install -qq openssh-client )'
    - eval $(ssh-agent -s)
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
94
    - ssh-add <(echo "MIIEpAIBAAKCAQEAx8UXx4pOMmz2cmDHH9y7ymQaCMAFqU/l2f99MrLXaKGzJQ1fq/5hsyD9TKfidl8lLNp1ZM/thvYsRC9F2ysmYr2zeApTXhRdvLBsVd/gAxmDfaDGBBoQ63hQHa3lZG9f8VAI/REHC07MWBuiwelJYY7Sh561ssAfN5IIWlDRCuBpU8zJ4f5yS/M/ehkb/lUiX1jvo1q6t0BDGZV5FVJS5V9SMm5wxSYnmQbO6gERqEaDhQADWn7EIKtTtA4sOl/MvHfoPgwcJ5te2cTgCGrgbZlKsfYCZmj+bxnE4feqYcng/2EFkx0Wj5SWuakInTKwxcOv5+TP5Lf9qOFL9QoDxQIDAQABAoIBAQCrBban42WykcoifWu7gVNbn3sSRqISIw6aJLngL29uahBeBicDrdGicvmnKIsd37KJxbR+y+uDgTjAXuAlE7nXCqScfeqFPlZJdZgppHG49Zy2bm9Xj6EwlV2xKvCZnSe8BVLMpEktixYxz+b0r21dEdJ2vI69KvEOt/xipZFxBs4KfAL8/jFVUj8wNAOg15eCafGgJci3HtKm7rg78eMilrTq/TV+Cjf3jcWweXpGCTDGc90fNngCjrekIJ/KeNfu8FKYpa5yAI1joFc9ACGa4TQJCX6jbWcPm9+ZkecnocRNYZ5v9KUa6cNxIR8ziSApq1wA5goSbLOuNJPE4LNBAoGBAO+Xbv+PUH1CP0ZhtLvA47mAb2a09vu6r7Xf7m5bitRKgYhB1pprnCxSEVOqm00pEVXCOvCXE097OBCulNrgggtA/cqyruQWXsY38Zxxbu9x5+edKqpO4tS3LG1HSFCQWlxYzD3t7gFSbeafyzmedFB1L4ewFoUpM7SXDGorhqMNAoGBANVzf5NdNtSP6jaSgVKz7uKDxwyTkxOV8xc7hq+2lbNP6NeX0/atDsI+SnGu0yAJsN9RpWsocRuhcy3DmFhav58LGnjnwmhaLEX4xmlIDPwz+dAHzTdhsABkqTksRtwPgO4ZyGwgcDBtDnU1prmcYKO9dVBqPiPISf2f0xDsXJWZAoGAKHOf6QQQaeWae06Zzi1mBXba2DNrk9rUOdfiEL3h9a/SqOe8zPuoNY9xn3epmuB5LcqKWv6W4w+Bysc/GKlZK39Amk2K27WvMLZXU7uPKFxJ9EAD6RdCkvmORbEIU5nbt8XCTh5y1cROC+ckz8iiCMeQS89+LeNj+HScQvywUa0CgYAAt26KNBnnBMSogj1k5a27nO2iISyxOCOkxFJjbJ18CJyjfKL9hP8zr7nYP9n9lYq+dSu0/GHE0fntAWcVhNh31DW2ijCg4Qyc/4TK/a7tec8w35XUxcMtfSkERB3Ix1SLeBKwKju2LeeKhS+WF+xLIGuwZWrn+9gjvdGbkO+OoQKBgQDVaKNvDHNFE85VMBPEyxEFrcQqQFr9CALV0Od14tHSSdM7NVy0UAItzfkjncNhiozNunzCoI2x/yNH5ZdUmPZ4p4Ec+JadYvzrP4+7pWUbIt/932tXH71sYGzrLVcqfMyS1lfmuwIGKjgEyJtOXv+j96bHc5hyaASmnjNcSkMTTg==")
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
95
96
    - mkdir -p ~/.ssh
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
Bayukanta Iqbal Gunawan's avatar
a  
Bayukanta Iqbal Gunawan committed
97
  script:
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
98
    - >
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
99
      ssh admin@10.119.106.23 
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
100
101
102
103
104
105
      "cd poipole-dtb-beasiswa-miskin-dan-disabilitas &&
      git checkout docker &&
      git pull origin docker &&
      bash stop.sh &&
      bash start.sh &&
      exit"
Bayukanta Iqbal Gunawan's avatar
a  
Bayukanta Iqbal Gunawan committed
106
107
  environment:
    name: production
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
108
    url: $VM_URL