Fakultas Ilmu Komputer UI

.gitlab-ci.yml 2.7 KB
Newer Older
1
2
3
4
image: node:12

stages:
  - setup
Shafiya Adzhani's avatar
Shafiya Adzhani committed
5
  - lint
6
  - test-build
Shafiya Adzhani's avatar
Shafiya Adzhani committed
7
  - sonarscanner
8
9
10
11
12
13
  - deploy

setup:
  stage: setup
  script:
    - npm ci
14
15
16
  except:
    changes:
      - "README.md"
17
18
19
20
21
  cache:
    key: dependency
    paths:
      - node_modules/

Shafiya Adzhani's avatar
Shafiya Adzhani committed
22
23
24
25
26
27
28
29
30
31
32
33
34
35
lint:
  stage: lint
  script:
    - npm install eslint eslint-plugin-jest eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-testing-library
    - node_modules/eslint/bin/eslint.js .
  except:
    changes:
      - "README.md"
  cache:
    key: dependency
    policy: pull
    paths:
      - node_modules/ 

36
37
38
39
test:
  stage: test-build
  script:
    - npm run test:coverage
40
41
42
  except:
    changes:
      - "README.md"
43
44
45
46
47
48
49
50
51
  artifacts:
    expire_in: 1 hour
    paths:
      - coverage/
  cache:
    key: dependency
    policy: pull
    paths:
      - node_modules/    
52
  coverage: /All\sfiles.*?\s+(\d+.\d+)/
53
54
55
56
57

build:
  stage: test-build
  script:
    - npm run build
58
59
60
  except:
    changes:
      - "README.md"
61
62
63
64
65
66
67
68
  artifacts:
    expire_in: 1 hour
    paths:
      - build/
  cache:
    key: dependency
    policy: pull
    paths:
Shafiya Adzhani's avatar
Shafiya Adzhani committed
69
70
      - node_modules/

71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
integration:
  image: cypress/browsers:node12.16.2-chrome81-ff75
  stage: test-build
  script:
    - apt-get install xvfb
    - npm run cypress:install
    - npm run start:gitlab
    - npm run cypress:gitlab
  except:
    changes:
      - "README.md"
  cache:
    key: dependency
    policy: pull
    paths:
      - node_modules/

Shafiya Adzhani's avatar
Shafiya Adzhani committed
88
89
90
91
92
93
SonarScanner Dev:
  image:
    name: sonarsource/sonar-scanner-cli:4.6
    entrypoint: [""]
  stage: sonarscanner
  script:
Shafiya Adzhani's avatar
Shafiya Adzhani committed
94
95
96
97
98
99
100
101
    - sonar-scanner
      -Dsonar.projectKey=$SONARQUBE_PROJECT_KEY
      -Dsonar.host.url=$SONARQUBE_HOST_URL
      -Dsonar.login=$SONARQUBE_TOKEN
      -Dsonar.branch.name=$CI_COMMIT_REF_NAME
      -Dsonar.branch.target=staging
  dependencies: 
    - test
Shafiya Adzhani's avatar
Shafiya Adzhani committed
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
  except:
    - master
    - staging

SonarScanner:
  image:
    name: sonarsource/sonar-scanner-cli:4.6
    entrypoint: [""]
  stage: sonarscanner
  script:
    - sonar-scanner
      -Dsonar.projectKey=$SONARQUBE_PROJECT_KEY
      -Dsonar.host.url=$SONARQUBE_HOST_URL
      -Dsonar.login=$SONARQUBE_TOKEN
      -Dsonar.branch.name=$CI_COMMIT_REF_NAME
Shafiya Adzhani's avatar
Shafiya Adzhani committed
117
118
  dependencies: 
    - test
Shafiya Adzhani's avatar
Shafiya Adzhani committed
119
120
121
  only:
    - master
    - staging  
122
123
124
  
deploy-staging:
  stage: deploy
125
126
127
  except:
    changes:
      - "README.md"
128
129
  script:
    - npm install netlify-cli -g --unsafe-perm=true
130
    - netlify deploy --site $NETLIFY_SITE_ID_STAGING --auth $NETLIFY_AUTH_TOKEN --prod
131
132
133
134
135
136
137
  dependencies:
    - build
  only:
    - staging

deploy-master:
  stage: deploy
138
139
140
  except:
    changes:
      - "README.md"
141
142
143
144
145
146
147
  script:
    - npm install netlify-cli -g --unsafe-perm=true
    - netlify deploy --site $NETLIFY_SITE_ID --auth $NETLIFY_AUTH_TOKEN --prod
  dependencies:
    - build
  only:
    - master