.gitlab-ci.yml 6.07 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 14
.install: &install
  bundle install --jobs 4 --path vendor

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

16
cache:
Takuya Noguchi's avatar
Takuya Noguchi committed
17
  key: "web_ruby-2.4.4"
18
  paths:
19
    - tmp/cache
20
    - vendor
21

22
stages:
23
  - prepare
24
  - build
25 26
  - deploy

27
lint 0 2:
28
  stage: build
29 30 31
  script:
    - bundle exec rake lint
  tags:
32
    - gitlab-org
33

34
lint 1 2:
35 36
  cache: {}
  before_script: []
37
  stage: build
38 39 40
  script:
    - yarn install
    - yarn run eslint
41
    - yarn run yamllint
42 43 44
  tags:
    - gitlab-org

45
crop_pictures:
46
  cache: {}
47
  before_script: []
48
  stage: prepare
49
  script:
50
    - bin/crop-team-pictures
51 52
  artifacts:
    paths:
53 54
      - data/team.yml
      - data/pets.yml
55
      - source/images/team/
56
      - source/community/alumni/index.html.haml
57 58 59
  tags:
    - gitlab-org

60 61 62 63 64
pngbot_commit:
  image: registry.gitlab.com/jramsay/pngbot:v0.1.0
  before_script: []
  cache: {}
  except:
James Ramsay's avatar
James Ramsay committed
65
    - master@gitlab-com/www-gitlab-com
66 67
  only:
    - branches@gitlab-com/www-gitlab-com
68 69 70 71 72 73
  stage: prepare
  script:
    - pngbot
  tags:
    - gitlab-org

Matija Čupić's avatar
Matija Čupić committed
74
rubocop:
75
  stage: build
Matija Čupić's avatar
Matija Čupić committed
76
  script:
Matija Čupić's avatar
Matija Čupić committed
77
    - bundle exec rubocop
Matija Čupić's avatar
Matija Čupić committed
78 79 80
  tags:
    - gitlab-org

81
rspec:
82
  image: dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.4.5-git-2.18-chrome-69.0-docker-18.06.1
83
  stage: build
84 85 86 87 88
  script:
    - bundle exec rspec
  tags:
    - gitlab-org

89
enforce_relative_links:
90
  stage: build
91
  image: alpine
92
  allow_failure: true
93
  cache: {}
94 95
  before_script:
    - apk add --update the_silver_searcher
96
  script:
97
    - set +o errexit
98
    - ag --filename --numbers --break --nogroup --depth -1 --stats --path-to-ignore ./.relative_links_ignore '(?<!`|")https?://about.gitlab.com(?!`|\S*")' ./source && rc="$?" || rc="$?"
99
    - if [ "$rc" -eq 0 ]; then exit 1; else exit 0; fi
100 101
  tags:
    - gitlab-org
102

Matija Čupić's avatar
Matija Čupić committed
103 104
check_links:
  before_script: []
105
  image: coala/base
106
  stage: build
Matija Čupić's avatar
Matija Čupić committed
107
  script:
Matija Čupić's avatar
Matija Čupić committed
108
    - git fetch --unshallow && git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" && git fetch origin master
Matija Čupić's avatar
Matija Čupić committed
109
    - git diff --numstat origin/master..$CI_COMMIT_REF_NAME -- | awk '/(.+\.md)|(.+\.haml)/ { print $3 }' > new_files
Matija Čupić's avatar
Matija Čupić committed
110
    - coala --no-config --ci --bears InvalidLinkBear --settings follow_redirects=True --files="$(paste -s -d, new_files)"
Matija Čupić's avatar
Matija Čupić committed
111
  when: manual
Matija Čupić's avatar
Matija Čupić committed
112
  allow_failure: true
Matija Čupić's avatar
Matija Čupić committed
113 114 115 116 117
  except:
    - master
  tags:
    - gitlab-org

118
generate-handbook-changelog:
119 120
  stage: build
  script:
121
    - bundle exec bin/generate_handbook_changelog
122 123 124 125 126
  only:
    - schedules
  tags:
    - gitlab-org

127
.build_base: &build_base
128
  before_script:
129
    - find source/images/team -type f ! -name '*-crop.jpg' -delete
130
    - *install
131
  stage: build
132 133
  dependencies:
    - crop_pictures
134
  artifacts:
135
    expire_in: 7 days
136
    paths:
Mark Pundsack's avatar
Mark Pundsack committed
137
      - public/
138
      - source/images/team/
139
  tags:
140
    - gitlab-org
141 142 143 144 145 146 147 148 149 150

build_branch:
  <<: *build_base
  script:
    - bundle exec rake build
  except:
    - master

build_master:
  <<: *build_base
151 152
  variables:
    MIDDLEMAN_ENV: 'production'
153 154 155 156
  script:
    - bundle exec rake build pdfs
  only:
    - master
157

158
codequality:
159
  stage: build
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
  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:
179 180
      - coffeelint.json
      - gl-code-quality-report.json
181 182

dependency_scanning:
183
  stage: build
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
  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:
202 203
    reports:
      dependency_scanning: gl-dependency-scanning-report.json
204

205 206
review:
  stage: deploy
207
  allow_failure: true
208 209
  before_script: []
  cache: {}
210 211 212
  dependencies:
    - build_branch
  variables:
213
    GIT_STRATEGY: none
214
  script:
215 216 217
    # 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 \
218
        sed --in-place "s#https\?://about.gitlab.com#https://$CI_COMMIT_REF_SLUG.about-src.gitlab.com#g" "{}" +;
219
    - rsync --ignore-times --checksum --delete -avz public ~/pages/$CI_COMMIT_REF_SLUG
220
    - rm -rf ./public/
221
  environment:
222
    name: review/$CI_COMMIT_REF_SLUG
223
    url: https://$CI_COMMIT_REF_SLUG.about-src.gitlab.com
224 225
    on_stop: review_stop
  only:
226
    - branches@gitlab-com/www-gitlab-com
227
  except:
228
    - master@gitlab-com/www-gitlab-com
229 230 231 232 233 234 235 236 237
  tags:
    - deploy
    - review-apps

review_stop:
  stage: deploy
  before_script: []
  artifacts: {}
  cache: {}
238
  dependencies: []
Mark Pundsack's avatar
Mark Pundsack committed
239 240
  variables:
    GIT_STRATEGY: none
241
  script:
242
    - rm -rf ~/pages/$CI_COMMIT_REF_SLUG
243 244
  when: manual
  environment:
245
    name: review/$CI_COMMIT_REF_SLUG
246 247
    action: stop
  only:
248
    - branches@gitlab-com/www-gitlab-com
249
  except:
250
    - master@gitlab-com/www-gitlab-com
251 252 253 254
  tags:
    - deploy
    - review-apps

Robert Speicher's avatar
Robert Speicher committed
255
deploy:
256
  stage: deploy
Marin Jankovski's avatar
Marin Jankovski committed
257
  cache: {}
258
  variables:
259
    GIT_STRATEGY: none
260
  dependencies:
261
    - build_master
262
  before_script: []
Robert Speicher's avatar
Robert Speicher committed
263
  script:
264
    - rsync --ignore-times --checksum --delete -avz public/ ~/public/
265
    - rm -rf ./public/
266 267 268
  environment:
    name: production
    url: https://about.gitlab.com
Robert Speicher's avatar
Robert Speicher committed
269
  tags:
270
    - deploy
Robert Speicher's avatar
Robert Speicher committed
271
  only:
272
    - master@gitlab-com/www-gitlab-com