Fakultas Ilmu Komputer UI

.gitlab-ci.yml 2.36 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
20
  coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+)%/'
Bayukanta Iqbal Gunawan's avatar
a    
Bayukanta Iqbal Gunawan committed
21
22
23
24
25
26
  before_script:
    - pip install -r requirements.txt
    - python manage.py migrate
    - python manage.py collectstatic --no-input
  when: on_success
  script:
27
    - coverage run --include="./*" --omit="manage.py,pplbackend/*" manage.py test
Bayukanta Iqbal Gunawan's avatar
a    
Bayukanta Iqbal Gunawan committed
28
    - coverage report -m
29
    - coverage xml
30
  artifacts:
31
    paths:
32
    - coverage.xml
33

M. Abdurrahman's avatar
M. Abdurrahman committed
34
35
36
37
38
39
40
41
Pylint:
  image: python:3.7
  stage: linter
  allow_failure: true
  before_script:
    - pip install -r requirements.txt
  when: on_success
  script:
42
    - pylint --load-plugins pylint_django --rcfile=./.pylintrc informasi_fasilitas layanan_khusus new_rest_api oauth registrasi
M. Abdurrahman's avatar
M. Abdurrahman committed
43

M. Abdurrahman's avatar
M. Abdurrahman committed
44
SonarScanner:
M. Abdurrahman's avatar
M. Abdurrahman committed
45
46
47
  image: 
    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: [""]
48
  stage: sonarqube
M. Abdurrahman's avatar
M. Abdurrahman committed
49
50
51
  script:
    - sonar-scanner
      -Dsonar.host.url=https://pmpl.cs.ui.ac.id/sonarqube
52
      -Dsonar.login=$SONARQUBE_TOKEN
M. Abdurrahman's avatar
M. Abdurrahman committed
53
54
      -Dsonar.branch.name=$CI_COMMIT_REF_NAME
      -Dsonar.projectKey=$SONARQUBE_PROJECT_KEY
Bayukanta Iqbal Gunawan's avatar
a    
Bayukanta Iqbal Gunawan committed
55

56
Staging:
57
  image: ruby:2.4
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
58
  stage: staging
59
60
61
62
63
64
  only:
    refs:
      - staging
  before_script:
    - gem install dpl
    - wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
65
  script:
66
67
68
69
70
71
72
    - 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

73
  
Bayukanta Iqbal Gunawan's avatar
a  
Bayukanta Iqbal Gunawan committed
74
75
Deployment:
  image: ruby:2.4
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
76
  stage: production
77
78
  only:
    refs:
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
79
      - docker
Bayukanta Iqbal Gunawan's avatar
a  
Bayukanta Iqbal Gunawan committed
80
  before_script:
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
81
82
83
84
85
86
87
    - apt-get update -qq
    - apt-get install -qq git
    - 'which ssh-agent || ( apt-get install -qq openssh-client )'
    - eval $(ssh-agent -s)
    - ssh-add <(echo "$SSH_PRIVATE_KEY")
    - 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
88
  script:
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
89
90
91
92
93
94
95
96
    - >
      ssh admin@10.119.106.12 
      "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
97
98
  environment:
    name: production
Bayukanta Iqbal Gunawan's avatar
Bayukanta Iqbal Gunawan committed
99
    url: $VM_URL