Read about our upcoming Code of Conduct on this issue

frontend.gitlab-ci.yml 7.57 KB
Newer Older
Stan Hu's avatar
Stan Hu committed
1
.assets-compile-cache:
Kamil Trzciński's avatar
Kamil Trzciński committed
2
3
4
  cache:
    paths:
      - vendor/ruby/
5
6
      - public/assets/webpack/
      - assets-hash.txt
Kamil Trzciński's avatar
Kamil Trzciński committed
7
8
      - .yarn-cache/
      - tmp/cache/assets/sprockets
9
10
      - tmp/cache/babel-loader
      - tmp/cache/vue-loader
11
      - tmp/cache/webpack-dlls
Kamil Trzciński's avatar
Kamil Trzciński committed
12

13
.gitlab:assets:compile-metadata:
Stan Hu's avatar
Stan Hu committed
14
15
16
  extends:
    - .default-retry
    - .default-before_script
17
    - .assets-compile-cache
18
    - .use-docker-in-docker
19
  image: registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.6.5-git-2.26-lfs-2.9-chrome-73.0-node-12.x-yarn-1.21-graphicsmagick-1.3.34-docker-19.03.1
20
  stage: prepare
Kamil Trzciński's avatar
Kamil Trzciński committed
21
22
23
24
25
26
27
28
  variables:
    NODE_ENV: "production"
    RAILS_ENV: "production"
    SETUP_DB: "false"
    SKIP_STORAGE_VALIDATION: "true"
    WEBPACK_REPORT: "true"
    # we override the max_old_space_size to prevent OOM errors
    NODE_OPTIONS: --max_old_space_size=3584
Stan Hu's avatar
Stan Hu committed
29
  cache:
30
    key: "assets-compile:production:v1"
Stan Hu's avatar
Stan Hu committed
31
32
33
34
35
  artifacts:
    name: webpack-report
    expire_in: 31d
    paths:
      - webpack-report/
36
      - assets-compile.log
37
38
      # We consume these files in GitLab UI for integration tests:
      # https://gitlab.com/gitlab-org/gitlab-ui/-/blob/e88493b3c855aea30bf60baee692a64606b0eb1e/.storybook/preview-head.pug#L1
39
40
41
      - public/assets/application-*.css
      - public/assets/application-*.css.gz
    when: always
Kamil Trzciński's avatar
Kamil Trzciński committed
42
43
  script:
    - node --version
Lukas Eipert's avatar
Lukas Eipert committed
44
    - retry yarn install --frozen-lockfile --production --cache-folder .yarn-cache --prefer-offline
Kamil Trzciński's avatar
Kamil Trzciński committed
45
    - free -m
46
47
48
49
    - time bin/rake gitlab:assets:compile > assets-compile.log 2>&1
    # TODO: Change the image tag to be the MD5 of assets files and skip image building if the image exists
    # We'll also need to pass GITLAB_ASSETS_TAG to the trigerred omnibus-gitlab pipeline similarly to how we do it for trigerred CNG pipelines
    # https://gitlab.com/gitlab-org/gitlab/issues/208389
Kamil Trzciński's avatar
Kamil Trzciński committed
50
51
    - time scripts/build_assets_image
    - scripts/clean-old-cached-assets
Kamil Trzciński's avatar
Kamil Trzciński committed
52
    - rm -f /etc/apt/sources.list.d/google*.list  # We don't need to update Chrome here
Kamil Trzciński's avatar
Kamil Trzciński committed
53

54
gitlab:assets:compile pull-push-cache:
55
56
57
  extends:
    - .gitlab:assets:compile-metadata
    - .frontend:rules:gitlab-assets-compile-pull-push-cache
58
59
60
61
  cache:
    policy: pull-push

gitlab:assets:compile pull-cache:
62
63
64
  extends:
    - .gitlab:assets:compile-metadata
    - .frontend:rules:gitlab-assets-compile-pull-cache
Stan Hu's avatar
Stan Hu committed
65
66
  cache:
    policy: pull
67
68

.compile-assets-metadata:
Stan Hu's avatar
Stan Hu committed
69
70
71
  extends:
    - .default-retry
    - .default-before_script
72
    - .assets-compile-cache
Kamil Trzciński's avatar
Kamil Trzciński committed
73
74
75
  stage: prepare
  script:
    - node --version
Lukas Eipert's avatar
Lukas Eipert committed
76
    - retry yarn install --frozen-lockfile --cache-folder .yarn-cache --prefer-offline
Kamil Trzciński's avatar
Kamil Trzciński committed
77
    - free -m
78
    - time bin/rake gitlab:assets:compile > assets-compile.log 2>&1
Kamil Trzciński's avatar
Kamil Trzciński committed
79
80
    - scripts/clean-old-cached-assets
  variables:
81
    SETUP_DB: "false"
Kamil Trzciński's avatar
Kamil Trzciński committed
82
83
    # we override the max_old_space_size to prevent OOM errors
    NODE_OPTIONS: --max_old_space_size=3584
84
    WEBPACK_VENDOR_DLL: "true"
Stan Hu's avatar
Stan Hu committed
85
  cache:
86
    key: "assets-compile:test:v1"
Kamil Trzciński's avatar
Kamil Trzciński committed
87
88
89
90
91
  artifacts:
    expire_in: 7d
    paths:
      - node_modules
      - public/assets
92
      - assets-compile.log
93
    when: always
94

95
compile-assets pull-push-cache:
96
97
98
  extends:
    - .compile-assets-metadata
    - .frontend:rules:compile-assets-pull-push-cache
99
100
101
  cache:
    policy: pull-push

102
compile-assets pull-push-cache as-if-foss:
103
104
  extends:
    - .compile-assets-metadata
105
    - .frontend:rules:compile-assets-pull-push-cache-as-if-foss
106
    - .as-if-foss
107
108
  cache:
    policy: pull-push
109
    key: "assets-compile:test:as-if-foss:v1"
110
111

compile-assets pull-cache:
112
113
114
  extends:
    - .compile-assets-metadata
    - .frontend:rules:compile-assets-pull-cache
115
116
117
  cache:
    policy: pull

118
compile-assets pull-cache as-if-foss:
119
120
  extends:
    - .compile-assets-metadata
121
    - .frontend:rules:compile-assets-pull-cache-as-if-foss
122
    - .as-if-foss
Stan Hu's avatar
Stan Hu committed
123
124
  cache:
    policy: pull
125
    key: "assets-compile:test:as-if-foss:v1"
Kamil Trzciński's avatar
Kamil Trzciński committed
126

127
.frontend-fixtures-base:
Stan Hu's avatar
Stan Hu committed
128
129
130
131
  extends:
    - .default-retry
    - .default-cache
    - .default-before_script
132
    - .use-pg11
133
  stage: fixtures
134
  needs: ["setup-test-env pg11", "compile-assets pull-cache"]
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
  script:
    - date
    - scripts/gitaly-test-spawn
    - date
    - bundle exec rake frontend:fixtures
  artifacts:
    name: frontend-fixtures
    expire_in: 31d
    when: always
    paths:
      - node_modules
      - public/assets
      - tmp/tests/frontend/

frontend-fixtures:
  extends:
    - .frontend-fixtures-base
    - .frontend:rules:default-frontend-jobs

frontend-fixtures-as-if-foss:
  extends:
    - .frontend-fixtures-base
157
    - .frontend:rules:default-frontend-jobs-no-foss
158
159
160
161
162
163
164
165
166
167
    - .as-if-foss

.frontend-job-base:
  extends:
    - .default-retry
    - .default-cache
    - .default-before_script
  variables:
    USE_BUNDLE_INSTALL: "false"
    SETUP_DB: "false"
168
  stage: test
169

170
.karma-base:
171
  extends: .frontend-job-base
Kamil Trzciński's avatar
Kamil Trzciński committed
172
173
174
175
176
177
  variables:
    # we override the max_old_space_size to prevent OOM errors
    NODE_OPTIONS: --max_old_space_size=3584
  script:
    - export BABEL_ENV=coverage CHROME_LOG_FILE=chrome_debug.log
    - date
178
    - yarn karma
179
180

karma:
181
182
183
  extends:
    - .karma-base
    - .frontend:rules:default-frontend-jobs
184
  needs: ["frontend-fixtures"]
Kamil Trzciński's avatar
Kamil Trzciński committed
185
186
187
188
189
190
191
192
  coverage: '/^Statements *: (\d+\.\d+%)/'
  artifacts:
    name: coverage-javascript
    expire_in: 31d
    when: always
    paths:
      - chrome_debug.log
      - coverage-javascript/
193
      - tmp/tests/frontend/
Steve Azzopardi's avatar
Steve Azzopardi committed
194
195
    reports:
      junit: junit_karma.xml
Kamil Trzciński's avatar
Kamil Trzciński committed
196

197
karma-as-if-foss:
198
199
  extends:
    - .karma-base
200
    - .frontend:rules:default-frontend-jobs-no-foss
201
    - .as-if-foss
202
  needs: ["frontend-fixtures-as-if-foss"]
203
204

.jest-base:
205
  extends: .frontend-job-base
Kamil Trzciński's avatar
Kamil Trzciński committed
206
207
  script:
    - date
208
    - yarn jest --ci --coverage --testSequencer ./scripts/frontend/parallel_ci_sequencer.js
209
210
211
  cache:
    key: jest
    paths:
212
      - tmp/cache/jest/
213
214
215
    policy: pull-push

jest:
216
217
218
  extends:
    - .jest-base
    - .frontend:rules:default-frontend-jobs
219
  needs: ["frontend-fixtures"]
Kamil Trzciński's avatar
Kamil Trzciński committed
220
221
222
223
224
  artifacts:
    name: coverage-frontend
    expire_in: 31d
    when: always
    paths:
Kamil Trzciński's avatar
Kamil Trzciński committed
225
226
      - coverage-frontend/
      - junit_jest.xml
227
      - tmp/tests/frontend/
Steve Azzopardi's avatar
Steve Azzopardi committed
228
229
    reports:
      junit: junit_jest.xml
230
  parallel: 2
231

232
jest-as-if-foss:
233
234
  extends:
    - .jest-base
235
    - .frontend:rules:default-frontend-jobs-no-foss
236
    - .as-if-foss
237
  needs: ["frontend-fixtures-as-if-foss"]
Kamil Trzciński's avatar
Kamil Trzciński committed
238
  cache:
239
    policy: pull
Kamil Trzciński's avatar
Kamil Trzciński committed
240

241
242
243
coverage-frontend:
  extends:
    - .default-retry
244
    - .frontend:rules:default-frontend-jobs-no-foss
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
  needs: ["jest"]
  stage: post-test
  before_script:
    - yarn install --frozen-lockfile --cache-folder .yarn-cache --prefer-offline
  script:
    - yarn node scripts/frontend/merge_coverage_frontend.js
  artifacts:
    name: coverage-frontend
    expire_in: 31d
    paths:
      - coverage-frontend/
  cache:
    paths:
      - .yarn-cache/

Stan Hu's avatar
Stan Hu committed
260
261
262
.qa-frontend-node:
  extends:
    - .default-retry
263
    - .frontend:rules:qa-frontend-node
264
  stage: test
Stan Hu's avatar
Stan Hu committed
265
  dependencies: []
Kamil Trzciński's avatar
Kamil Trzciński committed
266
267
268
269
270
271
272
  cache:
    key: "$CI_JOB_NAME"
    paths:
      - .yarn-cache/
    policy: pull-push
  script:
    - date
Lukas Eipert's avatar
Lukas Eipert committed
273
    - yarn install --frozen-lockfile --cache-folder .yarn-cache --prefer-offline
Kamil Trzciński's avatar
Kamil Trzciński committed
274
275
276
277
    - date
    - yarn run webpack-prod

qa-frontend-node:10:
Stan Hu's avatar
Stan Hu committed
278
  extends: .qa-frontend-node
279
  image: node:dubnium
Kamil Trzciński's avatar
Kamil Trzciński committed
280
281

qa-frontend-node:latest:
Stan Hu's avatar
Stan Hu committed
282
  extends: .qa-frontend-node
283
  image: node:latest
Kamil Trzciński's avatar
Kamil Trzciński committed
284
  allow_failure: true
Mike Greiling's avatar
Mike Greiling committed
285
286
287
288
289

webpack-dev-server:
  extends:
    - .default-retry
    - .default-cache
290
    - .frontend:rules:default-frontend-jobs
291
  stage: test
292
  needs: ["setup-test-env pg11", "compile-assets pull-cache"]
Mike Greiling's avatar
Mike Greiling committed
293
294
  variables:
    WEBPACK_MEMORY_TEST: "true"
295
    WEBPACK_VENDOR_DLL: "true"
Mike Greiling's avatar
Mike Greiling committed
296
  script:
297
    - yarn webpack-vendor
Mike Greiling's avatar
Mike Greiling committed
298
    - node --expose-gc node_modules/.bin/webpack-dev-server --config config/webpack.config.js
299
300
301
302
303
  artifacts:
    name: webpack-dev-server
    expire_in: 31d
    paths:
      - webpack-dev-server.json