.gitlab-ci.yml 6.96 KB
Newer Older
1 2 3
# Note that the rspec job below uses a different image that also
# includes chromedriver. If we update the Ruby version for this image,
# we should also update it for the rspec job.
4
image: dev.gitlab.org:5005/gitlab/gitlab-build-images:www-gitlab-com-2.4
5

6
variables:
7
  GIT_DEPTH: "10"
8 9
  # Speed up middleman
  NO_CONTRACTS: "true"
10

11 12 13
.install: &install
  bundle install --jobs 4 --path vendor

14 15 16 17 18 19 20 21 22
# This injects master, merge requests, and tags as default only behavior
# in order to have all jobs run in all cases for these refs, except where
# otherwise intended (for example, to only create review apps for MRs.)
.only-default: &only-default
  only:
    - master
    - merge_requests
    - tags

23
before_script: [*install]
Robert Speicher's avatar
Robert Speicher committed
24

25
cache:
Takuya Noguchi's avatar
Takuya Noguchi committed
26
  key: "web_ruby-2.4.4"
27
  paths:
28
    - tmp/cache
29
    - vendor
30

31
stages:
32
  - prepare
33
  - build
34 35
  - deploy

36
lint 0 2:
37
  <<: *only-default
38
  stage: build
39 40 41
  script:
    - bundle exec rake lint
  tags:
42
    - gitlab-org
43

44
lint 1 2:
45
  <<: *only-default
46 47
  cache: {}
  before_script: []
48
  stage: build
49 50 51
  script:
    - yarn install
    - yarn run eslint
52
    - yarn run yamllint
53 54 55
  tags:
    - gitlab-org

56
crop_pictures:
57
  <<: *only-default
58
  cache: {}
59
  before_script: []
60
  stage: prepare
61
  script:
62
    - bin/crop-team-pictures
63 64
  artifacts:
    paths:
65 66
      - data/team.yml
      - data/pets.yml
67
      - source/images/team/
68
      - source/community/alumni/index.html.haml
69 70 71
  tags:
    - gitlab-org

72 73 74 75
pngbot_commit:
  image: registry.gitlab.com/jramsay/pngbot:v0.1.0
  before_script: []
  cache: {}
76
  only:
77
    - merge_requests@gitlab-com/www-gitlab-com
78 79 80 81 82 83
  stage: prepare
  script:
    - pngbot
  tags:
    - gitlab-org

Matija Čupić's avatar
Matija Čupić committed
84
rubocop:
85
  <<: *only-default
86
  stage: build
Matija Čupić's avatar
Matija Čupić committed
87
  script:
Matija Čupić's avatar
Matija Čupić committed
88
    - bundle exec rubocop
Matija Čupić's avatar
Matija Čupić committed
89 90 91
  tags:
    - gitlab-org

92
.rspec_job: &rspec_job
93
  image: dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.4.5-git-2.18-chrome-69.0-docker-18.06.1
94
  stage: build
95 96
  script:
    - bundle exec rspec
97 98 99 100 101
  artifacts:
    expire_in: 7 days
    paths:
      - tmp/capybara
    when: on_failure
102 103 104
  tags:
    - gitlab-org

Sean McGivern's avatar
Sean McGivern committed
105
spec 0 2:
106 107
  <<: *rspec_job
  allow_failure: true
Sean McGivern's avatar
Sean McGivern committed
108
  only:
109
    - master
110

Sean McGivern's avatar
Sean McGivern committed
111
spec 0 2:
112 113
  <<: *rspec_job
  allow_failure: false
114 115 116
  only:
    - tags
    - merge_requests
117

Sean McGivern's avatar
Sean McGivern committed
118
spec 1 2:
119
  <<: *only-default
Sean McGivern's avatar
Sean McGivern committed
120 121 122 123 124 125 126 127 128
  cache: {}
  before_script: []
  stage: build
  script:
    - yarn install
    - yarn run test
  tags:
    - gitlab-org

129
enforce_relative_links:
130
  <<: *only-default
131
  stage: build
132
  image: alpine
133
  allow_failure: true
134
  cache: {}
135 136
  before_script:
    - apk add --update the_silver_searcher
137
  script:
138
    - set +o errexit
139
    - ag --filename --numbers --break --nogroup --depth -1 --stats --path-to-ignore ./.relative_links_ignore '(?<!`|")https?://about.gitlab.com(?!`|\S*")' ./source && rc="$?" || rc="$?"
140
    - if [ "$rc" -eq 0 ]; then exit 1; else exit 0; fi
141 142
  tags:
    - gitlab-org
143

Matija Čupić's avatar
Matija Čupić committed
144 145
check_links:
  before_script: []
146
  image: coala/base
147
  stage: build
Matija Čupić's avatar
Matija Čupić committed
148
  script:
Matija Čupić's avatar
Matija Čupić committed
149
    - git fetch --unshallow && git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" && git fetch origin master
Matija Čupić's avatar
Matija Čupić committed
150
    - git diff --numstat origin/master..$CI_COMMIT_REF_NAME -- | awk '/(.+\.md)|(.+\.haml)/ { print $3 }' > new_files
Matija Čupić's avatar
Matija Čupić committed
151
    - coala --no-config --ci --bears InvalidLinkBear --settings follow_redirects=True --files="$(paste -s -d, new_files)"
Matija Čupić's avatar
Matija Čupić committed
152
  when: manual
Matija Čupić's avatar
Matija Čupić committed
153
  allow_failure: true
154 155 156
  only:
    - merge_requests
    - tags      
Matija Čupić's avatar
Matija Čupić committed
157 158 159 160 161
  except:
    - master
  tags:
    - gitlab-org

162
generate-handbook-changelog:
163 164
  stage: build
  script:
165
    - bundle exec bin/generate_handbook_changelog
166 167 168 169 170
  only:
    - schedules
  tags:
    - gitlab-org

171
.build_base: &build_base
172
  before_script:
173
    - find source/images/team -type f ! -name '*-crop.jpg' -delete
174
    - *install
175
  stage: build
176 177
  dependencies:
    - crop_pictures
178
  artifacts:
179
    expire_in: 7 days
180
    paths:
Mark Pundsack's avatar
Mark Pundsack committed
181
      - public/
182
      - source/images/team/
183
  tags:
184
    - gitlab-org
185 186 187 188 189

build_branch:
  <<: *build_base
  script:
    - bundle exec rake build
190 191 192
  only:
    - merge_requests
    - tags
193 194 195 196 197
  except:
    - master

build_master:
  <<: *build_base
198 199
  variables:
    MIDDLEMAN_ENV: 'production'
200 201 202 203
  script:
    - bundle exec rake build pdfs
  only:
    - master
204

205
codequality:
206
  <<: *only-default
207
  stage: build
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
  image: docker:stable
  allow_failure: true
  before_script: []
  cache: {}
  dependencies: []
  tags: []
  services:
    - docker:stable-dind
  variables:
    DOCKER_DRIVER: overlay2
  script:
    - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
    - docker run
        --env SOURCE_CODE="$PWD"
        --volume "$PWD":/code
        --volume /var/run/docker.sock:/var/run/docker.sock
        "registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
  artifacts:
    paths:
227 228
      - coffeelint.json
      - gl-code-quality-report.json
229 230

dependency_scanning:
231
  <<: *only-default
232
  stage: build
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
  image: docker:stable
  allow_failure: true
  before_script: []
  cache: {}
  dependencies: []
  tags: []
  services:
    - docker:stable-dind
  variables:
    DOCKER_DRIVER: overlay2
  script:
    - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
    - docker run
        --env DEP_SCAN_DISABLE_REMOTE_CHECKS="${DEP_SCAN_DISABLE_REMOTE_CHECKS:-false}"
        --volume "$PWD:/code"
        --volume /var/run/docker.sock:/var/run/docker.sock
        "registry.gitlab.com/gitlab-org/security-products/dependency-scanning:$SP_VERSION" /code
  artifacts:
251 252
    reports:
      dependency_scanning: gl-dependency-scanning-report.json
253

254 255
review:
  stage: deploy
256
  allow_failure: true
257 258
  before_script: []
  cache: {}
259 260 261
  dependencies:
    - build_branch
  variables:
262
    GIT_STRATEGY: none
263
  script:
264 265 266
    # We sometimes have absolute URLs, this replaces them with correct ones for the review app
    - >
      find public/ -regextype egrep -iregex ".*\.(html|js|css|json|xml|txt)" -exec \
267
        sed --in-place "s#https\?://about.gitlab.com#https://$CI_COMMIT_REF_SLUG.about-src.gitlab.com#g" "{}" +;
268
    - rsync --ignore-times --checksum --delete -avz public ~/pages/$CI_COMMIT_REF_SLUG
269
    - rm -rf ./public/
270
  environment:
271
    name: review/$CI_COMMIT_REF_SLUG
272
    url: https://$CI_COMMIT_REF_SLUG.about-src.gitlab.com
273 274
    on_stop: review_stop
  only:
275
    - merge_requests@gitlab-com/www-gitlab-com
276
  except:
277
    - master@gitlab-com/www-gitlab-com
278 279 280 281 282 283 284 285 286
  tags:
    - deploy
    - review-apps

review_stop:
  stage: deploy
  before_script: []
  artifacts: {}
  cache: {}
287
  dependencies: []
Mark Pundsack's avatar
Mark Pundsack committed
288 289
  variables:
    GIT_STRATEGY: none
290
  script:
291
    - rm -rf ~/pages/$CI_COMMIT_REF_SLUG
292 293
  when: manual
  environment:
294
    name: review/$CI_COMMIT_REF_SLUG
295 296
    action: stop
  only:
297
    - merge_requests@gitlab-com/www-gitlab-com
298
  except:
299
    - master@gitlab-com/www-gitlab-com
300 301 302 303
  tags:
    - deploy
    - review-apps

Robert Speicher's avatar
Robert Speicher committed
304
deploy:
305
  stage: deploy
Marin Jankovski's avatar
Marin Jankovski committed
306
  cache: {}
307
  variables:
308
    GIT_STRATEGY: none
309
  dependencies:
310
    - build_master
311
  before_script: []
Robert Speicher's avatar
Robert Speicher committed
312
  script:
313
    - rsync --ignore-times --checksum --delete -avz public/ ~/public/
314
    - rm -rf ./public/
315 316 317
  environment:
    name: production
    url: https://about.gitlab.com
Robert Speicher's avatar
Robert Speicher committed
318
  tags:
319
    - deploy
Robert Speicher's avatar
Robert Speicher committed
320
  only:
321
    - master@gitlab-com/www-gitlab-com