frontend.gitlab-ci.yml 6.8 KB
Newer Older
S
Stan Hu 已提交
1
.assets-compile-cache:
K
Kamil Trzciński 已提交
2 3 4 5 6
  cache:
    paths:
      - vendor/ruby/
      - .yarn-cache/
      - tmp/cache/assets/sprockets
7 8
      - tmp/cache/babel-loader
      - tmp/cache/vue-loader
9
      - tmp/cache/webpack-dlls
K
Kamil Trzciński 已提交
10

11
.gitlab:assets:compile-metadata:
S
Stan Hu 已提交
12 13 14 15
  extends:
    - .default-tags
    - .default-retry
    - .default-before_script
16
    - .assets-compile-cache
17
  image: registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.6.5-git-2.24-lfs-2.9-chrome-73.0-node-12.x-yarn-1.21-graphicsmagick-1.3.34-docker-19.03.1
18
  stage: prepare
K
Kamil Trzciński 已提交
19
  services:
L
Lukas Eipert 已提交
20
    - docker:19.03.0-dind
K
Kamil Trzciński 已提交
21 22 23 24 25 26 27 28 29 30
  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
    DOCKER_DRIVER: overlay2
    DOCKER_HOST: tcp://docker:2375
S
Stan Hu 已提交
31
  cache:
32
    key: "assets-compile:production:vendor_ruby:.yarn-cache:tmp_cache_assets_sprockets:tmp_cache_webpack:v9"
S
Stan Hu 已提交
33 34 35 36 37 38
  artifacts:
    name: webpack-report
    expire_in: 31d
    paths:
      - webpack-report/
      - public/assets/
K
Kamil Trzciński 已提交
39 40
  script:
    - node --version
L
Lukas Eipert 已提交
41
    - retry yarn install --frozen-lockfile --production --cache-folder .yarn-cache --prefer-offline
K
Kamil Trzciński 已提交
42
    - free -m
43
    - retry bundle exec rake gitlab:assets:compile
K
Kamil Trzciński 已提交
44 45
    - time scripts/build_assets_image
    - scripts/clean-old-cached-assets
K
Kamil Trzciński 已提交
46
    - rm -f /etc/apt/sources.list.d/google*.list  # We don't need to update Chrome here
K
Kamil Trzciński 已提交
47 48
  tags:
    - gitlab-org
S
Stan Hu 已提交
49
    - docker
K
Kamil Trzciński 已提交
50

51
gitlab:assets:compile pull-push-cache:
52 53 54
  extends:
    - .gitlab:assets:compile-metadata
    - .frontend:rules:gitlab-assets-compile-pull-push-cache
55 56 57 58
  cache:
    policy: pull-push

gitlab:assets:compile pull-cache:
59 60 61
  extends:
    - .gitlab:assets:compile-metadata
    - .frontend:rules:gitlab-assets-compile-pull-cache
S
Stan Hu 已提交
62 63
  cache:
    policy: pull
64 65

.compile-assets-metadata:
S
Stan Hu 已提交
66 67 68 69
  extends:
    - .default-tags
    - .default-retry
    - .default-before_script
70
    - .assets-compile-cache
K
Kamil Trzciński 已提交
71 72 73
  stage: prepare
  script:
    - node --version
L
Lukas Eipert 已提交
74
    - retry yarn install --frozen-lockfile --cache-folder .yarn-cache --prefer-offline
K
Kamil Trzciński 已提交
75
    - free -m
76
    - retry bundle exec rake gitlab:assets:compile
K
Kamil Trzciński 已提交
77 78
    - scripts/clean-old-cached-assets
  variables:
79
    SETUP_DB: "false"
K
Kamil Trzciński 已提交
80 81
    # we override the max_old_space_size to prevent OOM errors
    NODE_OPTIONS: --max_old_space_size=3584
82
    WEBPACK_VENDOR_DLL: "true"
S
Stan Hu 已提交
83
  cache:
84
    key: "assets-compile:v9"
K
Kamil Trzciński 已提交
85 86 87 88 89
  artifacts:
    expire_in: 7d
    paths:
      - node_modules
      - public/assets
90

91
compile-assets pull-push-cache:
92 93 94
  extends:
    - .compile-assets-metadata
    - .frontend:rules:compile-assets-pull-push-cache
95 96 97
  cache:
    policy: pull-push

98
compile-assets pull-push-cache as-if-foss:
99 100
  extends:
    - .compile-assets-metadata
101
    - .frontend:rules:compile-assets-pull-push-cache-as-if-foss
102
    - .as-if-foss
103 104
  cache:
    policy: pull-push
105
    key: "assets-compile:v9:foss"
106 107

compile-assets pull-cache:
108 109 110
  extends:
    - .compile-assets-metadata
    - .frontend:rules:compile-assets-pull-cache
111 112 113
  cache:
    policy: pull

114
compile-assets pull-cache as-if-foss:
115 116
  extends:
    - .compile-assets-metadata
117
    - .frontend:rules:compile-assets-pull-cache-as-if-foss
118
    - .as-if-foss
S
Stan Hu 已提交
119 120
  cache:
    policy: pull
121
    key: "assets-compile:v9:foss"
K
Kamil Trzciński 已提交
122

123
.frontend-fixtures-base:
S
Stan Hu 已提交
124 125 126 127 128
  extends:
    - .default-tags
    - .default-retry
    - .default-cache
    - .default-before_script
129
    - .use-pg9
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
  stage: fixtures
  needs:
    - job: "setup-test-env"
      artifacts: true
    - job: "compile-assets pull-cache"
      artifacts: true
  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
    - .frontend:rules:default-frontend-jobs-as-if-foss
    - .as-if-foss

.frontend-job-base:
  extends:
    - .default-tags
    - .default-retry
    - .default-cache
    - .default-before_script
  variables:
    USE_BUNDLE_INSTALL: "false"
    SETUP_DB: "false"
170
  stage: test
171

172
.karma-base:
173
  extends: .frontend-job-base
K
Kamil Trzciński 已提交
174 175 176 177 178 179
  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
180
    - yarn karma
181 182

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

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

.jest-base:
207
  extends: .frontend-job-base
K
Kamil Trzciński 已提交
208 209 210
  script:
    - date
    - yarn jest --ci --coverage
211 212 213 214 215 216 217
  cache:
    key: jest
    paths:
      - tmp/jest/jest/
    policy: pull-push

jest:
218 219 220
  extends:
    - .jest-base
    - .frontend:rules:default-frontend-jobs
221
  needs: ["frontend-fixtures"]
K
Kamil Trzciński 已提交
222 223 224 225 226
  artifacts:
    name: coverage-frontend
    expire_in: 31d
    when: always
    paths:
K
Kamil Trzciński 已提交
227 228
      - coverage-frontend/
      - junit_jest.xml
229
      - tmp/tests/frontend/
S
Steve Azzopardi 已提交
230 231
    reports:
      junit: junit_jest.xml
232

233
jest-as-if-foss:
234 235
  extends:
    - .jest-base
236
    - .frontend:rules:default-frontend-jobs-as-if-foss
237
    - .as-if-foss
238
  needs: ["frontend-fixtures-as-if-foss"]
K
Kamil Trzciński 已提交
239
  cache:
240
    policy: pull
K
Kamil Trzciński 已提交
241

S
Stan Hu 已提交
242 243 244 245 246
.qa-frontend-node:
  extends:
    - .default-tags
    - .default-retry
    - .default-cache
247
    - .frontend:rules:qa-frontend-node
248
  stage: test
S
Stan Hu 已提交
249
  dependencies: []
K
Kamil Trzciński 已提交
250 251 252 253 254 255 256
  cache:
    key: "$CI_JOB_NAME"
    paths:
      - .yarn-cache/
    policy: pull-push
  script:
    - date
L
Lukas Eipert 已提交
257
    - yarn install --frozen-lockfile --cache-folder .yarn-cache --prefer-offline
K
Kamil Trzciński 已提交
258 259 260 261
    - date
    - yarn run webpack-prod

qa-frontend-node:8:
S
Stan Hu 已提交
262
  extends: .qa-frontend-node
263
  image: node:carbon
K
Kamil Trzciński 已提交
264 265

qa-frontend-node:10:
S
Stan Hu 已提交
266
  extends: .qa-frontend-node
267
  image: node:dubnium
K
Kamil Trzciński 已提交
268 269

qa-frontend-node:latest:
S
Stan Hu 已提交
270
  extends: .qa-frontend-node
271
  image: node:latest
K
Kamil Trzciński 已提交
272
  allow_failure: true
M
Mike Greiling 已提交
273 274 275 276 277 278

webpack-dev-server:
  extends:
    - .default-tags
    - .default-retry
    - .default-cache
279
    - .frontend:rules:default-frontend-jobs
280 281
  stage: test
  needs: ["setup-test-env", "compile-assets pull-cache"]
M
Mike Greiling 已提交
282 283
  variables:
    WEBPACK_MEMORY_TEST: "true"
284
    WEBPACK_VENDOR_DLL: "true"
M
Mike Greiling 已提交
285
  script:
286
    - yarn webpack-vendor
M
Mike Greiling 已提交
287
    - node --expose-gc node_modules/.bin/webpack-dev-server --config config/webpack.config.js
288 289 290 291 292
  artifacts:
    name: webpack-dev-server
    expire_in: 31d
    paths:
      - webpack-dev-server.json